Skip to content

Commit

Permalink
Version 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeOnuke committed Nov 7, 2020
1 parent 0ef25a1 commit d113444
Show file tree
Hide file tree
Showing 37 changed files with 258 additions and 153 deletions.
2 changes: 1 addition & 1 deletion AdminTools/build/built-jar.properties
@@ -1,4 +1,4 @@
#Wed, 04 Nov 2020 14:55:59 +0100
#Sat, 07 Nov 2020 02:24:44 +0100


C\:\\Users\\lukak\\Documents\\NetBeansProjects\\AdminTools=
Expand Down
Binary file modified AdminTools/build/classes/app/admintools/RconClient.class
Binary file not shown.
Binary file not shown.
Expand Up @@ -13,7 +13,7 @@

<AnchorPane id="AnchorPane" fx:id="rootPane" prefHeight="650.0" prefWidth="973.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.admintools.gui.RconWindowController">
<!---<stylesheets>
<URL value="@../../../Assets/Themes/Default/style.css" />
<URL value="@../../../Assets/themes/Default/style.css" />
</stylesheets>-->
<children>
<AnchorPane fx:id="rconPane" layoutX="71.0" prefHeight="593.0" prefWidth="902.0" styleClass="rconPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="71.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Expand Up @@ -14,7 +14,7 @@

<AnchorPane id="AnchorPane" fx:id="rootPane" onKeyPressed="#onKeyPressed" prefHeight="650.0" prefWidth="973.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.admintools.gui.SettingsWindowController">
<!---<stylesheets>
<URL value="@../../../Assets/Themes/Default/style.css" />
<URL value="@../../../Assets/themes/Default/style.css" />
</stylesheets>-->
<children>
<AnchorPane layoutX="71.0" prefHeight="593.0" prefWidth="902.0" styleClass="pane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="71.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
Expand Down
Binary file not shown.
Expand Up @@ -14,7 +14,7 @@

<AnchorPane id="AnchorPane" fx:id="rootPane" prefHeight="650.0" prefWidth="973.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.admintools.gui.StatusWindowController">
<!---<stylesheets>
<URL value="@../../../Assets/Themes/Default/style.css" />
<URL value="@../../../Assets/themes/Default/style.css" />
</stylesheets>-->
<children>
<AnchorPane layoutX="71.0" prefHeight="593.0" prefWidth="902.0" styleClass="settingsPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="71.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified AdminTools/build/classes/app/admintools/util/Utill.class
Binary file not shown.
Binary file modified AdminTools/build/classes/app/admintools/util/WindowLoader.class
Binary file not shown.
Binary file added AdminTools/dist/AdminTools-6-0-0.zip
Binary file not shown.
5 changes: 2 additions & 3 deletions AdminTools/nbproject/private/private.xml
Expand Up @@ -3,11 +3,10 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/Assets/Themes/Aqua/style.css</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/src/app/admintools/util/Utill.java</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/src/app/admintools/gui/StatusWindowController.java</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/src/app/admintools/gui/RconWindowController.java</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/src/app/admintools/RconClient.java</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/Assets/Themes/Default/style.css</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/src/app/admintools/gui/theme/ThemeReader.java</file>
<file>file:/C:/Users/lukak/Documents/NetBeansProjects/AdminTools/src/app/admintools/gui/HomeWindowController.java</file>
</group>
</open-files>
Expand Down
2 changes: 1 addition & 1 deletion AdminTools/nbproject/project.properties
Expand Up @@ -69,7 +69,7 @@ javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
javafx.application.implementation.version=5.3.0
javafx.application.implementation.version=6.0.0
javafx.binarycss=false
javafx.classpath.extension=\
${java.home}/lib/javaws.jar:\
Expand Down
6 changes: 4 additions & 2 deletions AdminTools/src/app/admintools/RconClient.java
Expand Up @@ -68,7 +68,7 @@ public void start(Stage stage) throws Exception {
root = FXMLLoader.load(getClass().getResource("/app/admintools/gui/HomeWindow.fxml"));

//Set selected theme css
root.getStylesheets().add("file:Assets/Themes/" + d.getSelectedTheme() + "/style.css");
root.getStylesheets().add("file:Assets/themes/" + d.getSelectedTheme() + "/style.css");

Scene scene = new Scene(root);

Expand All @@ -86,8 +86,10 @@ public void start(Stage stage) throws Exception {
cr.command(TellrawFormatter.assembleLogoutTellraw(d.getMessageUsername()));
}
cr.disconnect();
} catch (IOException | AuthenticationException | NullPointerException ex) {
} catch (IOException | AuthenticationException ex) {
AtLogger.logException(ex);
} catch (NullPointerException ex) {
//Its normal for it to trow a null pointer exception on exit if no connection is avalable
}
Platform.exit();
System.exit(0);
Expand Down
Expand Up @@ -112,6 +112,7 @@ private void addNew() {
AtLogger.logException(ex);
}
}

isWizardOpen.set(false);
}
}
Expand Down
2 changes: 1 addition & 1 deletion AdminTools/src/app/admintools/gui/RconWindow.fxml
Expand Up @@ -13,7 +13,7 @@

<AnchorPane id="AnchorPane" fx:id="rootPane" prefHeight="650.0" prefWidth="973.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.admintools.gui.RconWindowController">
<!---<stylesheets>
<URL value="@../../../Assets/Themes/Default/style.css" />
<URL value="@../../../Assets/themes/Default/style.css" />
</stylesheets>-->
<children>
<AnchorPane fx:id="rconPane" layoutX="71.0" prefHeight="593.0" prefWidth="902.0" styleClass="rconPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="71.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
Expand Down
175 changes: 123 additions & 52 deletions AdminTools/src/app/admintools/gui/RconWindowController.java
Expand Up @@ -35,6 +35,9 @@
import com.google.gson.JsonObject;
import com.lukeonuke.simplefxdialog.Dialog;
import com.lukeonuke.simplefxdialog.img.DialogImage;
import java.io.File;
import java.util.Arrays;
import java.util.Scanner;

/**
*
Expand Down Expand Up @@ -113,7 +116,7 @@ public void changed(ObservableValue<? extends Worker.State> observable, Worker.S
if (!updateStats.get("draft").getAsBoolean()) {
if (!updateStats.get("tag_name").getAsString().equals("v" + this.getClass().getPackage().getImplementationVersion())) {
write("§a[AVCS] §4Newer version found §9" + updateStats.get("tag_name").getAsString() + "\n §f" + updateStats.get("name").getAsString() + "\n Get it from github: §ahttps://get.admintools.app/");

isUpToDate = false;
}
}
Expand Down Expand Up @@ -166,6 +169,7 @@ public void changed(ObservableValue<? extends Worker.State> observable, Worker.S

Data d = Data.getInstance();
write("§bConnecting to " + d.getSelectedCredentials().getIP() + ":" + d.getSelectedCredentials().getPort());
AtLogger.log(Level.INFO, "Connecting to server");
try {
CustomRcon cr = CustomRcon.getInstance();
//write connected message if its enabled
Expand Down Expand Up @@ -238,6 +242,11 @@ public void refresh() {
});
}

/**
* 1-st layer interpreter command send
*
* @param command the command to be sent
*/
private void sendCommand(String command) {
CustomRcon cRcon;
try {
Expand All @@ -248,66 +257,77 @@ private void sendCommand(String command) {
//Internal command interpreter
boolean isRightToSend = true; //Boolean that is checked when sending commands to server

switch (command) {
//Stop command
case "stop":
if (Dialog.okCancelDialog(DialogImage.WARNING, "Are you sure?", "Do you realy want to stop the server?"
+ System.lineSeparator()
+ "By pressing on you will be issuing a stop command to the server")) {

isRightToSend = false;
write("§bStopping the server and exiting in 2 (two) seconds");
cRcon.command("stop");
sendButton.disableProperty().set(true);
rconSend.disableProperty().set(true);
Thread t = new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
AtLogger.logException(ex);
}
Utill.exit(0);
});
t.start();
}
break;
//Help command
case "!help":
isRightToSend = false;
write("§bAdmin Tools internal command interpreter help: " + System.lineSeparator()
+ "\t!help - Help command" + System.lineSeparator()
+ "\t!clear - Clear the console" + System.lineSeparator()
+ "\t!exit - Exit the program and close the rcon connection" + System.lineSeparator());
break;
//Clear command - clears the console
case "!clear":
isRightToSend = false;
Data.rconTextData.clear();
write("§bCleared console");
break;
//Clear command - clears the console
case "!login":
isRightToSend = false;
Data.rconTextData.clear();
WindowLoader.loadHome(rootPane);
break;
ArrayList<String> splitCommand = new ArrayList<>(Arrays.asList(command.trim().split("\\s+")));

if (command.equals("stop")) {
if (Dialog.okCancelDialog(DialogImage.WARNING, "Are you sure?", "Do you realy want to stop the server?"
+ System.lineSeparator()
+ "By pressing on you will be issuing a stop command to the server")) {

//Exit command - exits the program
case "!exit":
isRightToSend = false;
write("§bStopping the server and exiting in 2 (two) seconds");
cRcon.command("stop");
sendButton.disableProperty().set(true);
rconSend.disableProperty().set(true);
Thread t = new Thread(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
AtLogger.logException(ex);
}
Utill.exit(0);
});
t.start();

write("§bClosing connection and exiting...");
}
} else if (command.equals("!help")) {
isRightToSend = false;
write("§bAdmin Tools internal command interpreter help: " + System.lineSeparator()
+ "\t!help - Help command" + System.lineSeparator()
+ "\t!clear - Clear the console" + System.lineSeparator()
+ "\t!exit - Exit the program and close the rcon connection" + System.lineSeparator());
} else if (command.equals("!clear")) {
isRightToSend = false;
Data.rconTextData.clear();
write("§bCleared console");
} else if (command.equals("!exit")) {
isRightToSend = false;

write("§bClosing connection and exiting...");

Utill.exit(commandHistoryDeviation);
} else if (splitCommand.get(0).equals("!if")) {
isRightToSend = false;
if (logicalOperations(splitCommand.get(1))) {
splitCommand.remove(0);
splitCommand.remove(0);
/*
*Send the command that is after the if instruction ex. &if yes==yes <command>
*Send it this way so that it allows for nested if-s
*/
sendCommand(Utill.removeArrrayFormatting(splitCommand.toString()));
}
//Print statement
} else if (splitCommand.get(0).equals("!print")) {
isRightToSend = false;
splitCommand.remove(0);
write(Utill.removeArrrayFormatting(splitCommand.toString())); //Send the text after the print instruction

cRcon.disconnect();
System.exit(0);
break;
default:
break;
}

for (int i = 0; i < listScripts().size(); i++) {
if (command.startsWith("@" + Utill.stripExtension(listScripts().get(i)))) {
isRightToSend = false;
ArrayList<String> args = new ArrayList<>(Arrays.asList(command.split("[ ]")));
args.remove(0);
executeScript(getScript(listScripts().get(i)), args);
}
}

if (isRightToSend) {
//Send and recive recsponce
write(cRcon.command(command));
AtLogger.log(Level.INFO, "Command sent to server : " + command);
}
}
} catch (IOException | AuthenticationException ex) {
Expand Down Expand Up @@ -341,4 +361,55 @@ private void loadStatus() {
private void loadHome() {
WindowLoader.loadHome(rootPane);
}

public static ArrayList<String> listScripts() {
ArrayList<String> themeDir = new ArrayList<String>(); //Netbeans takes a shite than complaians
File[] themes = new File("Assets/scripts/").listFiles(); //Get a array of all files in the script folder
for (File theme : themes) { //Go through them all
if (theme.isFile()) {
themeDir.add(theme.getName()); //Add its name to the returning arraylist if its a directory
}
}
return themeDir;
}

public static String getScript(String scriptName) {
return "Assets/scripts/" + scriptName;
}

private void executeScript(String scriptPath, ArrayList<String> args) throws FileNotFoundException {
// pass the path to the file as a parameter
File file = new File(scriptPath);
Scanner sc = new Scanner(file);

write("┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉");

while (sc.hasNextLine()) {
String instruction = sc.nextLine();
if (instruction != null) {
for (int i = 0; i < args.size(); i++) {
instruction = instruction.replace("arg" + i, args.get(i));
}

if (instruction.startsWith("#")) {
//Comment
} else if (instruction.startsWith("@")) {
//Call to new script, ignored

} else {
//Minecraft command, or 1-st layer interpreter command
sendCommand(instruction);
}
}
}
}

public static boolean logicalOperations(String operation) {
if (operation.contains("==")) {
return operation.split("==")[0].equals(operation.split("==")[1]); //Return true if the bit before the == is equal to the bit after the ==
} else if (operation.contains("!=")) {
return !operation.split("!=")[0].equals(operation.split("!=")[1]); //Return true if the bit before the != is not equal to the bit after the !=
}
return false;
}
}
2 changes: 1 addition & 1 deletion AdminTools/src/app/admintools/gui/SettingsWindow.fxml
Expand Up @@ -14,7 +14,7 @@

<AnchorPane id="AnchorPane" fx:id="rootPane" onKeyPressed="#onKeyPressed" prefHeight="650.0" prefWidth="973.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.admintools.gui.SettingsWindowController">
<!---<stylesheets>
<URL value="@../../../Assets/Themes/Default/style.css" />
<URL value="@../../../Assets/themes/Default/style.css" />
</stylesheets>-->
<children>
<AnchorPane layoutX="71.0" prefHeight="593.0" prefWidth="902.0" styleClass="pane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="71.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
Expand Down
Expand Up @@ -114,7 +114,7 @@ private void apply() {

//Actualy have to refresh the theme
//And refresh the Data singleton
rootPane.getStylesheets().add("file:Assets/Themes/" + Data.refresh().getSelectedTheme() + "/style.css");
rootPane.getStylesheets().add("file:Assets/themes/" + Data.refresh().getSelectedTheme() + "/style.css");
}

@FXML
Expand Down
2 changes: 1 addition & 1 deletion AdminTools/src/app/admintools/gui/StatusWindow.fxml
Expand Up @@ -14,7 +14,7 @@

<AnchorPane id="AnchorPane" fx:id="rootPane" prefHeight="650.0" prefWidth="973.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.admintools.gui.StatusWindowController">
<!---<stylesheets>
<URL value="@../../../Assets/Themes/Default/style.css" />
<URL value="@../../../Assets/themes/Default/style.css" />
</stylesheets>-->
<children>
<AnchorPane layoutX="71.0" prefHeight="593.0" prefWidth="902.0" styleClass="settingsPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="71.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
Expand Down
21 changes: 11 additions & 10 deletions AdminTools/src/app/admintools/gui/StatusWindowController.java
Expand Up @@ -152,7 +152,6 @@ private void tickApi() {
} catch (InterruptedException ex) {
AtLogger.logException(ex);
}
System.out.println(Data.isOnStatusWindow);
tickApi();
}
});
Expand Down Expand Up @@ -181,16 +180,18 @@ private void mcStatusRefresh() {

//Set player list
Platform.runLater(() -> {
try {
if (sOnlinePlayers.getItems() != null) {
sOnlinePlayers.getItems().clear();
if (data.getPlayers().getSample() != null) {
try {
if (sOnlinePlayers.getItems() != null) {
sOnlinePlayers.getItems().clear();
}
for (int i = 0; i < data.getPlayers().getSample().size(); i++) {
sOnlinePlayers.getItems().add(data.getPlayers().getSample().get(i).getName());
}

} catch (Exception e) {
AtLogger.logException(e);
}
for (int i = 0; i < data.getPlayers().getSample().size(); i++) {
sOnlinePlayers.getItems().add(data.getPlayers().getSample().get(i).getName());
}

} catch (Exception e) {
AtLogger.logException(e);
}
});

Expand Down
Expand Up @@ -176,7 +176,7 @@ public static Credentials showCredWizard(Credentials credentials) {

//Create window
Scene scene = new Scene(ap);
scene.getStylesheets().add("file:Assets/Themes/" + Data.getInstance().getSelectedTheme() + "/style.css"); //Themes
scene.getStylesheets().add("file:Assets/themes/" + Data.getInstance().getSelectedTheme() + "/style.css"); //Themes
Stage stage = new Stage();
stage.setScene(scene);
stage.setAlwaysOnTop(true);
Expand Down

0 comments on commit d113444

Please sign in to comment.