forked from 2009Scape/Server
Removed panel
This commit is contained in:
parent
101b8314c9
commit
d650b93c91
34 changed files with 215 additions and 939 deletions
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.PasswordField?>
|
||||
<?import javafx.scene.control.TextArea?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox fx:id="legendFrame" prefHeight="556.0" prefWidth="694.0" xmlns="http://javafx.com/javafx/8.0.91" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.crandor.tools.panel.Controller">
|
||||
<children>
|
||||
<AnchorPane fx:id="mainFrame" maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="670.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<Label layoutX="48.0" layoutY="21.0" prefHeight="26.0" prefWidth="55.0" text="Players">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextArea fx:id="systemLogger" editable="false" layoutX="147.0" layoutY="236.0" prefHeight="148.0" prefWidth="433.0" wrapText="true" />
|
||||
<ComboBox fx:id="punishmentBox" layoutX="149.0" layoutY="47.0" prefWidth="150.0" promptText="Punishments" />
|
||||
<ComboBox fx:id="toolsBox" layoutX="288.0" layoutY="175.0" prefWidth="150.0" promptText="Tools" />
|
||||
<ComboBox fx:id="ranksBox" layoutX="408.0" layoutY="47.0" prefWidth="150.0" promptText="Ranks" />
|
||||
<Label layoutX="338.0" layoutY="216.0" text="Console">
|
||||
<font>
|
||||
<Font size="14.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextArea fx:id="playersList" layoutX="14.0" layoutY="47.0" prefHeight="337.0" prefWidth="123.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
<AnchorPane fx:id="vali" maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" VBox.vgrow="ALWAYS">
|
||||
<children>
|
||||
<PasswordField fx:id="validationKey" layoutX="199.0" layoutY="147.0" prefHeight="25.0" prefWidth="243.0" />
|
||||
<Label layoutX="232.0" layoutY="6.0" prefHeight="74.0" prefWidth="178.0" text="Staff Validation">
|
||||
<font>
|
||||
<Font name="Times New Roman" size="27.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="90.0" layoutY="151.0" text="Validation Key :">
|
||||
<font>
|
||||
<Font name="Times New Roman" size="15.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<Button fx:id="submitButton" layoutX="455.0" layoutY="147.0" mnemonicParsing="false" text="Submit" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</VBox>
|
||||
|
|
@ -21,7 +21,7 @@ import org.crandor.tools.backup.AutoBackup;
|
|||
* @author Vexia
|
||||
*
|
||||
*/
|
||||
public final class Main extends Application {
|
||||
public final class Main {
|
||||
|
||||
/**
|
||||
* The time stamp of when the server started running.
|
||||
|
|
@ -50,7 +50,7 @@ public final class Main extends Application {
|
|||
// }
|
||||
startTime = System.currentTimeMillis();
|
||||
final TimeStamp t = new TimeStamp();
|
||||
backup = new AutoBackup();
|
||||
// backup = new AutoBackup();
|
||||
GameWorld.prompt(true);
|
||||
SQLManager.init();
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new SystemShutdownHook()));
|
||||
|
|
@ -78,12 +78,4 @@ public final class Main extends Application {
|
|||
public static void setStartTime(long startTime) {
|
||||
Main.startTime = startTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
Parent root = FXMLLoader.load(getClass().getResource("Main Frame.fxml"));
|
||||
primaryStage.setTitle("Management Panel");
|
||||
primaryStage.setScene(new Scene(root, 600, 450));
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
||||
|
|
@ -77,8 +77,6 @@ import org.crandor.net.packet.out.SkillLevel;
|
|||
import org.crandor.net.packet.out.UpdateSceneGraph;
|
||||
import org.crandor.plugin.Plugin;
|
||||
import org.crandor.tools.StringUtils;
|
||||
import org.crandor.tools.panel.Controller;
|
||||
import org.crandor.tools.panel.PlayerListPulse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -250,7 +248,6 @@ public class Player extends Entity {
|
|||
*/
|
||||
private final HunterManager hunterManager = new HunterManager(this);
|
||||
|
||||
private final PlayerListPulse playerListPulse = new PlayerListPulse(this);
|
||||
|
||||
/**
|
||||
* The treasure trail manager.
|
||||
|
|
@ -277,7 +274,6 @@ public class Player extends Entity {
|
|||
*/
|
||||
private final IronmanManager ironmanManager = new IronmanManager(this);
|
||||
|
||||
private final Controller controller = new Controller(this);
|
||||
|
||||
/**
|
||||
* The logout plugins.
|
||||
|
|
@ -1261,13 +1257,6 @@ public class Player extends Entity {
|
|||
this.skillTasks = skillTasks;
|
||||
}
|
||||
|
||||
public Controller getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
public PlayerListPulse getPlayerListPulse() {
|
||||
return playerListPulse;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
package org.crandor.tools.panel;
|
||||
|
||||
/**
|
||||
* Package -> ethan
|
||||
* Created on -> 8/31/2016 @9:54 PM for CP
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
public enum BoxOptions {
|
||||
|
||||
PUNISHMENTS(new String[] {"Temp. Mute", "Perm. Mute", "IP Mute", "Un-mute", "Temp. Ban", "Perm. Ban", "IP Ban", "Un-ban"}),
|
||||
TOOLS(new String[] {"NPC Definitions", "Item Definitions "}),
|
||||
RANKS(new String[] {"Promote", "Demote"});
|
||||
|
||||
private String[] options;
|
||||
|
||||
BoxOptions(String[] options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public String[] getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package org.crandor.tools.panel;
|
||||
|
||||
import javafx.scene.control.TextArea;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class Console extends OutputStream {
|
||||
|
||||
private TextArea output;
|
||||
|
||||
public Console(TextArea ta) {
|
||||
this.output = ta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int i) throws IOException {
|
||||
output.appendText(String.valueOf((char) i));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
package org.crandor.tools.panel;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import org.crandor.tools.TimeStamp;
|
||||
import org.crandor.ServerConstants;
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.system.SystemLogger;
|
||||
import org.crandor.game.system.SystemShutdownHook;
|
||||
import org.crandor.game.system.mysql.SQLManager;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
import org.crandor.net.NioReactor;
|
||||
import org.crandor.net.amsc.WorldCommunicator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Scanner;
|
||||
|
||||
import static javafx.scene.layout.VBoxBuilder.create;
|
||||
|
||||
public class Controller extends AnchorPane implements Initializable {
|
||||
|
||||
private ObservableList<String> rankData = FXCollections.observableArrayList();
|
||||
private ObservableList<String> punishmentData = FXCollections.observableArrayList();
|
||||
private ObservableList<String> toolsData = FXCollections.observableArrayList();
|
||||
private ObservableList<String> playerListData = FXCollections.observableArrayList();
|
||||
|
||||
@FXML
|
||||
private PasswordField validationKey;
|
||||
|
||||
@FXML
|
||||
private AnchorPane vali;
|
||||
|
||||
@FXML
|
||||
private AnchorPane mainFrame;
|
||||
|
||||
@FXML
|
||||
private VBox legendFrame;
|
||||
|
||||
@FXML
|
||||
private Button submitButton;
|
||||
|
||||
@FXML
|
||||
private TextArea playersList;
|
||||
|
||||
@FXML
|
||||
private TextArea systemLogger;
|
||||
|
||||
@FXML
|
||||
private ComboBox<String> punishmentBox;
|
||||
|
||||
@FXML
|
||||
private ComboBox<String> toolsBox;
|
||||
|
||||
@FXML
|
||||
private ComboBox<String> ranksBox;
|
||||
|
||||
public static long startTime;
|
||||
|
||||
public static NioReactor reactor;
|
||||
|
||||
private Player player;
|
||||
|
||||
|
||||
public Controller() {
|
||||
for (String options : BoxOptions.RANKS.getOptions()) {
|
||||
rankData.add(options);
|
||||
}
|
||||
for (String options : BoxOptions.PUNISHMENTS.getOptions()) {
|
||||
punishmentData.add(options);
|
||||
}
|
||||
for (String options : BoxOptions.TOOLS.getOptions()) {
|
||||
toolsData.add(options);
|
||||
}
|
||||
}
|
||||
|
||||
public Controller(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
private EventHandler<ActionEvent> loginEventHandler = event -> {
|
||||
try {
|
||||
Scanner scanner = new Scanner(new File("key.cfg"));
|
||||
String key = scanner.next();
|
||||
String sha1Encryption = Encrypt.encryptSHA1(validationKey.getText());
|
||||
if (sha1Encryption.length() == key.length()) {
|
||||
if (sha1Encryption.equalsIgnoreCase(key)) {
|
||||
Stage accessMessage = new Stage();
|
||||
Button okayButton = new Button("Ok");
|
||||
okayButton.setOnAction((closeErrorEvent) -> {
|
||||
legendFrame.getChildren().remove(vali);
|
||||
legendFrame.getChildren().add(mainFrame);
|
||||
accessMessage.close();
|
||||
try {
|
||||
startTime = System.currentTimeMillis();
|
||||
final TimeStamp t = new TimeStamp();
|
||||
GameWorld.prompt(true);
|
||||
SQLManager.init();
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new SystemShutdownHook()));
|
||||
SystemLogger.log("Starting NIO reactor...");
|
||||
reactor = NioReactor.configure(43593 + GameWorld.getSettings().getWorldId());
|
||||
WorldCommunicator.connect();
|
||||
reactor.start();
|
||||
SystemLogger.log(GameWorld.getName() + " flags " + GameWorld.getSettings().toString());
|
||||
SystemLogger.log(GameWorld.getName() + " started in " + t.duration(false, "") + " milliseconds.");
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
});
|
||||
accessMessage.initModality(Modality.NONE);
|
||||
accessMessage.setScene(new Scene(create().children(new Text("[Success] - Access granted.\n"), okayButton).alignment(Pos.CENTER).padding(new Insets(5)).build()));
|
||||
accessMessage.show();
|
||||
} else {
|
||||
Stage errorMessage = new Stage();
|
||||
Button okayButton = new Button("Ok");
|
||||
okayButton.setOnAction((closeErrorEvent) -> errorMessage.close());
|
||||
errorMessage.initModality(Modality.WINDOW_MODAL);
|
||||
errorMessage.setScene(new Scene(create().children(new Text("[Error] - Incorrect validation key.\n"), okayButton).alignment(Pos.CENTER).padding(new Insets(5)).build()));
|
||||
errorMessage.show();
|
||||
ServerConstants.VALIDATED = false;
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
};
|
||||
|
||||
private EventHandler<ActionEvent> comboBoxEventHandler = event -> {
|
||||
|
||||
if (event.getSource() == ranksBox) {
|
||||
|
||||
}
|
||||
|
||||
if (event.getSource() == punishmentBox) {
|
||||
|
||||
}
|
||||
|
||||
if (event.getSource() == toolsBox) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
|
||||
legendFrame.getChildren().remove(mainFrame);
|
||||
|
||||
submitButton.setOnAction(loginEventHandler);
|
||||
|
||||
validationKey.setOnAction(loginEventHandler);
|
||||
|
||||
ranksBox.setOnAction(comboBoxEventHandler);
|
||||
|
||||
ranksBox.setItems(rankData);
|
||||
|
||||
punishmentBox.setItems(punishmentData);
|
||||
|
||||
toolsBox.setItems(toolsData);
|
||||
|
||||
|
||||
Console console = new Console(systemLogger);
|
||||
PrintStream ps = new PrintStream(console, true);
|
||||
System.setOut(ps);
|
||||
System.setErr(ps);
|
||||
|
||||
}
|
||||
|
||||
public TextArea getPlayersList() {
|
||||
return playersList;
|
||||
}
|
||||
|
||||
public ObservableList<String> getPlayerListData() {
|
||||
return playerListData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
package org.crandor.tools.panel;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
/**
|
||||
* Handles the encryption of player passwords.
|
||||
*
|
||||
* @author Apache Ah64
|
||||
*/
|
||||
public class Encrypt {
|
||||
|
||||
/**
|
||||
* Encrypt the string using the SHA-1 encryption algorithm.
|
||||
*
|
||||
* @param string
|
||||
* The string.
|
||||
* @return The encrypted string.
|
||||
*/
|
||||
public static String encryptSHA1(String string) {
|
||||
String hash = null;
|
||||
try {
|
||||
hash = byteArrayToHexString(hash(string));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypt the string to a SHA-1 hash.
|
||||
*
|
||||
* @param x
|
||||
* The string to encrypt.
|
||||
* @return The byte array.
|
||||
* @throws Exception
|
||||
* when an exception occurs.
|
||||
*/
|
||||
public static byte[] hash(String x) throws Exception {
|
||||
MessageDigest string;
|
||||
string = MessageDigest.getInstance("SHA-1");
|
||||
string.reset();
|
||||
string.update(x.getBytes());
|
||||
return string.digest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a byte array to hex string.
|
||||
*
|
||||
* @param b
|
||||
* The byte array.
|
||||
* @return The hex string.
|
||||
*/
|
||||
public static String byteArrayToHexString(byte[] b) {
|
||||
StringBuffer string = new StringBuffer(b.length * 2);
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
int v = b[i] & 0xff;
|
||||
if (v < 16) {
|
||||
string.append('0');
|
||||
}
|
||||
string.append(Integer.toHexString(v));
|
||||
}
|
||||
return string.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
package org.crandor.tools.panel;
|
||||
|
||||
import org.crandor.game.node.entity.player.Player;
|
||||
import org.crandor.game.system.task.Pulse;
|
||||
import org.crandor.game.world.GameWorld;
|
||||
import org.crandor.game.world.callback.CallBack;
|
||||
|
||||
/**
|
||||
* Package -> org.keldagrim.tools.panel
|
||||
* Created on -> 9/1/2016 @2:09 AM for Server
|
||||
*
|
||||
* @author Ethan Kyle Millard
|
||||
*/
|
||||
public final class PlayerListPulse extends Pulse implements CallBack {
|
||||
|
||||
private Player player;
|
||||
|
||||
public PlayerListPulse(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pulse() {
|
||||
System.out.println("new pulse");
|
||||
player.getController().getPlayersList().appendText(player.getName() + "\n");
|
||||
System.out.println(player.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean call() {
|
||||
GameWorld.submit(this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue