Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
- When server has no favicon it will display no default icon
- Depricated mojang api status
  • Loading branch information
LukeOnuke committed Mar 17, 2022
1 parent 86bce0a commit 9c159e6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 103 deletions.
78 changes: 3 additions & 75 deletions src/main/java/app/admintools/gui/StatusWindowController.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.ResourceBundle;

import app.admintools.AdminTools;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
Expand Down Expand Up @@ -48,22 +50,6 @@ public class StatusWindowController implements Initializable {
d-dot
statusDot<number> but shortened
*/
@FXML
private Pane sd1;
@FXML
private Pane sd2;
@FXML
private Pane sd3;
@FXML
private Pane sd4;
@FXML
private Pane sd5;
@FXML
private Pane sd6;
@FXML
private Pane sd7;
@FXML
private ProgressBar pbApi;

//For mc serv status
@FXML
Expand All @@ -84,7 +70,6 @@ public class StatusWindowController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle rb) {
tickMcRefresh();
tickApi();
}

@FXML
Expand All @@ -102,63 +87,6 @@ private void loadHome() {
WindowLoader.loadHome(rootPane);
}

@FXML
public void handleMouseClick(MouseEvent arg0) {
System.out.println("clicked on " + sOnlinePlayers.getSelectionModel().getSelectedItem());
}

private void refreshApiStatus() {
//set progressbar to spin
pbApi.setProgress(ProgressBar.INDETERMINATE_PROGRESS);
Thread st = new Thread(() -> { //new thread worker
//Initilse array list
ArrayList<String> arrStatus = new ArrayList<String>();
try {
arrStatus = ApiQuerry.querry(); //querry
} catch (IOException ex) {
AtLogger.logger.warning(AtLogger.formatException(ex));
}
final ArrayList<String> arrStatus_ = arrStatus; //final arraylist
Platform.runLater(() -> {
//
sd1.setStyle("-fx-background-color : " + arrStatus_.get(0) + ";");
sd2.setStyle("-fx-background-color : " + arrStatus_.get(2) + ";");
sd3.setStyle("-fx-background-color : " + arrStatus_.get(3) + ";");
sd4.setStyle("-fx-background-color : " + arrStatus_.get(4) + ";");
sd5.setStyle("-fx-background-color : " + arrStatus_.get(5) + ";");
sd6.setStyle("-fx-background-color : " + arrStatus_.get(6) + ";");
sd7.setStyle("-fx-background-color : " + arrStatus_.get(7) + ";");
pbApi.setProgress(0);
});
});
st.start();
}

private void tickApi() {
Thread ratf = new Thread(() -> {
if (Data.isOnStatusWindow) {
Platform.runLater(() -> {
refreshApiStatus();
});
Data data = Data.getInstance();
try {
int timeSleep = (int) data.getQuerryMojangApiRefreshRate() * 1000;
for (int i = 0; i < timeSleep / 500; i++) {
if (!Data.isOnStatusWindow) {
return;
}
Thread.sleep(500);
}
} catch (InterruptedException | IOException ex) {
AtLogger.logger.warning(AtLogger.formatException(ex));
}
tickApi();
}
});
ratf.setName("ApiTick");
ThreadManager.startThread(ratf, ThreadType.ASYNCJOB);
}

@FXML
private void mcStatusRefresh() {
Thread mcsr = new Thread(() -> {
Expand All @@ -174,7 +102,7 @@ private void mcStatusRefresh() {
if (data.getFavicon() != null) {
sFavicon.setImage(QuerryUtils.convertToImage(data.getFavicon()));
} else {
sFavicon.setImage(new Image(StatusWindowController.class.getResourceAsStream("/app/admintools/img/unknown_server.png")));
sFavicon.setImage(new Image(AdminTools.class.getResourceAsStream("/img/unknown-server.png")));
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/app/admintools/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import java.util.concurrent.atomic.AtomicInteger;

public class Version {
private final String VERSION_NUMBER = "7.0.0";
private final String VERSION_NUMBER = "7.1.0";
/**
* Snapshot version, only used if isDevelopmentVersion is true
*
* Version number goes like 23d12m2020y001v . So its [Day Of Release]d[Month Of Release]m[Year Of Release]y[Snapshot Number]v
*/
private final String SNAPSHOT_VER = "8d3m2021y001v";
private final String SNAPSHOT_VER = "17d3m2022y000v";
private final boolean isDevelopmentVersion = false;
private static Version instance = null;

Expand Down
28 changes: 2 additions & 26 deletions src/main/resources/gui/fxml/StatusWindow.fxml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import java.net.URL?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.control.ToggleButton?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.shape.SVGPath?>
<?import javafx.scene.text.Text?>

Expand All @@ -24,35 +21,14 @@
<Text layoutX="14.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="title" text="Status" />
</children>
</AnchorPane>
<AnchorPane layoutX="465.0" layoutY="85.0" prefHeight="488.0" prefWidth="420.0" styleClass="borderPane" AnchorPane.bottomAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="85.0">
<children>
<Text layoutY="14.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="borderPaneText" text="Services status" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Label layoutX="73.0" layoutY="37.0" styleClass="text" text="minecraft.net" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="37.0" />
<Label layoutX="73.0" layoutY="77.0" styleClass="text" text="session.minecraft.net" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="77.0" />
<Label layoutX="73.0" layoutY="117.0" styleClass="text" text="account.mojang.com" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="117.0" />
<Label layoutX="73.0" layoutY="157.0" styleClass="text" text="authserver.mojang.com" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="157.0" />
<Label layoutX="73.0" layoutY="197.0" styleClass="text" text="api.mojang.com" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="197.0" />
<Label layoutX="73.0" layoutY="237.0" styleClass="text" text="textures.minecraft.net" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="237.0" />
<Label layoutX="73.0" layoutY="277.0" styleClass="text" text="mojang.com" AnchorPane.leftAnchor="73.0" AnchorPane.topAnchor="277.0" />
<Pane fx:id="sd1" layoutX="26.0" layoutY="40.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="40.0" />
<Pane fx:id="sd2" layoutX="27.0" layoutY="80.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="80.0" />
<Pane fx:id="sd3" layoutX="27.0" layoutY="120.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="120.0" />
<Pane fx:id="sd4" layoutX="27.0" layoutY="160.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="160.0" />
<Pane fx:id="sd5" layoutX="27.0" layoutY="200.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="200.0" />
<Pane fx:id="sd6" layoutX="27.0" layoutY="240.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="240.0" />
<Pane fx:id="sd7" layoutX="27.0" layoutY="280.0" prefHeight="17.0" prefWidth="17.0" styleClass="statusDot" AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="280.0" />
<Label layoutX="16.0" layoutY="358.0" prefHeight="63.0" prefWidth="388.0" styleClass="text" text="Beware that status is set by a human so even though &#10;the fetch is automatized , somebody in mojang needs to &#10;update the data &#10; " AnchorPane.bottomAnchor="67.0" AnchorPane.leftAnchor="16.0" AnchorPane.rightAnchor="16.0" />
<ProgressBar fx:id="pbApi" layoutX="15.0" layoutY="454.0" prefHeight="20.0" prefWidth="390.0" progress="0.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" />
</children>
</AnchorPane>
<AnchorPane layoutX="14.0" layoutY="85.0" prefHeight="488.0" prefWidth="420.0" styleClass="borderPane" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="461.0" AnchorPane.topAnchor="85.0">
<AnchorPane layoutX="14.0" layoutY="85.0" prefHeight="488.0" prefWidth="420.0" styleClass="borderPane" AnchorPane.bottomAnchor="20.0" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="85.0">
<children>
<Text layoutY="14.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="borderPaneText" text="Server status" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0" />
<ImageView fx:id="sFavicon" fitHeight="64.0" fitWidth="64.0" layoutX="14.0" layoutY="18.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="24.0" />
<Label fx:id="sVer" layoutX="18.0" layoutY="96.0" styleClass="text" text="Version: " AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="100.0" />
<Label fx:id="sPlayers" layoutX="18.0" layoutY="127.0" styleClass="text" text="Players online: " AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="140.0" />
<Label layoutX="373.0" layoutY="461.0" onMouseClicked="#mcStatusRefresh" styleClass="labelButton" text="Refresh" AnchorPane.bottomAnchor="12.0" AnchorPane.rightAnchor="14.0" />
<ListView fx:id="sOnlinePlayers" layoutX="14.0" layoutY="168.0" onMouseClicked="#handleMouseClick" prefHeight="274.0" prefWidth="384.0" AnchorPane.bottomAnchor="46.0" AnchorPane.leftAnchor="13.0" AnchorPane.rightAnchor="22.0" AnchorPane.topAnchor="167.0" />
<ListView fx:id="sOnlinePlayers" layoutX="14.0" layoutY="168.0" prefHeight="274.0" prefWidth="384.0" AnchorPane.bottomAnchor="46.0" AnchorPane.leftAnchor="13.0" AnchorPane.rightAnchor="22.0" AnchorPane.topAnchor="167.0" />
</children>
</AnchorPane>
</children>
Expand Down
Binary file added src/main/resources/img/unknown-server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9c159e6

Please sign in to comment.