Improves string storage and variable names in the main GUI. Also adds the fallback web browsing method
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good
This commit is contained in:
parent
83f8834530
commit
52946c9aec
@ -18,9 +18,7 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import static java.awt.Frame.NORMAL;
|
import static java.awt.Frame.NORMAL;
|
||||||
@ -39,31 +37,53 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
|
|
||||||
private final JLabel lblStatuslabel = new JLabel("Servers are stopped");
|
private final JLabel lblStatuslabel = new JLabel("Servers are stopped");
|
||||||
private final ArrayList<String> globalPlayers;
|
private final ArrayList<String> globalPlayers;
|
||||||
|
private Controller controller;
|
||||||
|
private Map<String, String> textStrings;
|
||||||
|
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
private JTabbedPane tabbedPane;
|
private JTabbedPane tabbedPane;
|
||||||
private JTabbedPane serversPane;
|
private JTabbedPane serversPane;
|
||||||
//Menu
|
/*******
|
||||||
private JCheckBoxMenuItem chckbxmntmRunInBackground, chckbxmntmDelayStartup, chckbxmntmDownloadJars; //Options
|
* Menu
|
||||||
private JMenuItem mntmErrors, mntmSetup, mntmManualUpdate; //Help
|
********/
|
||||||
private JMenuItem mntmRunInBackground, mntmDelayStartup, mntmDownloadJars; //Info/options
|
//Options
|
||||||
private JMenuItem mntmAbout, mntmStory; //Info/about
|
private JCheckBoxMenuItem runInBackgroundCheckBoxMenuItem;
|
||||||
|
private JCheckBoxMenuItem delayStartupCheckBoxMenuItem;
|
||||||
|
private JCheckBoxMenuItem downloadJarsCheckBoxMenuItem;
|
||||||
|
//Help
|
||||||
|
private JMenuItem errorsMenuItem;
|
||||||
|
private JMenuItem setupMenuItem;
|
||||||
|
private JMenuItem manualUpdateMenuItem;
|
||||||
|
//Info/options
|
||||||
|
private JMenuItem runInBackgroundMenuItem;
|
||||||
|
private JMenuItem delayStartupMenuItem;
|
||||||
|
private JMenuItem downloadJarsMenuItem;
|
||||||
|
//Info/about
|
||||||
|
private JMenuItem aboutMenuItem;
|
||||||
|
private JMenuItem storyMenuItem;
|
||||||
//Basic controls
|
//Basic controls
|
||||||
private JButton btnStartServer, btnStopServer, addServer, backup, addProfile, delProfile;
|
private JButton startServerButton;
|
||||||
|
private JButton stopServerButton;
|
||||||
|
private JButton addServerButton;
|
||||||
|
private JButton backupButton;
|
||||||
|
private JButton addProfileButton;
|
||||||
|
private JButton deleteProfileButton;
|
||||||
private JComboBox<String> profiles;
|
private JComboBox<String> profiles;
|
||||||
//Server controls
|
//Server controls
|
||||||
private JComboBox<String> targetServer;
|
private JComboBox<String> targetServerCombo;
|
||||||
private JComboBox<String> targetPlayer;
|
private JComboBox<String> targetPlayerCombo;
|
||||||
private JButton btnKick, btnBan, btnOp, btnDeop, btnCustomCommand, btnSaveserver, btnReload, btnServerConsoles;
|
private JButton kickButton;
|
||||||
private JTextField customCommand;
|
private JButton banButton;
|
||||||
//Text
|
private JButton opButton;
|
||||||
private String setupText;
|
private JButton deopButton;
|
||||||
private String runInBackgroundText;
|
private JButton customCommandButton;
|
||||||
private String delayStartupText;
|
private JButton saveServerButton;
|
||||||
private String downloadJarsText;
|
private JButton reloadButton;
|
||||||
private String aboutText;
|
private JButton showConsolesButton;
|
||||||
|
private JTextField customCommandTextField;
|
||||||
|
//Tray
|
||||||
private SystemTray tray;
|
private SystemTray tray;
|
||||||
private TrayIcon trayIcon;
|
private TrayIcon trayIcon;
|
||||||
private Controller controller;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the application window
|
* Creates the application window
|
||||||
@ -93,7 +113,7 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
/**
|
/**
|
||||||
* Gets the pane used for server configurations
|
* Gets the pane used for server configurations
|
||||||
*
|
*
|
||||||
* @return A JTabbedPane
|
* @return <p>The pane used for server configurations</p>
|
||||||
*/
|
*/
|
||||||
public JTabbedPane getPane() {
|
public JTabbedPane getPane() {
|
||||||
return this.serversPane;
|
return this.serversPane;
|
||||||
@ -125,9 +145,9 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a player to the global playerlist, and updates the players combo.
|
* Adds a player to the global player list, and updates the players combo
|
||||||
*
|
*
|
||||||
* @param name The name of the player to add
|
* @param name <p>The name of the player to add</p>
|
||||||
*/
|
*/
|
||||||
public void addPlayer(String name) {
|
public void addPlayer(String name) {
|
||||||
this.globalPlayers.add(name);
|
this.globalPlayers.add(name);
|
||||||
@ -135,9 +155,9 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a player from the global list of players.
|
* Removes a player from the global list of players
|
||||||
*
|
*
|
||||||
* @param name The name of the player to remove.
|
* @param name <p>The name of the player to remove</p>
|
||||||
*/
|
*/
|
||||||
public void removePlayer(String name) {
|
public void removePlayer(String name) {
|
||||||
globalPlayers.removeIf(playerName -> playerName.equals(name));
|
globalPlayers.removeIf(playerName -> playerName.equals(name));
|
||||||
@ -145,7 +165,7 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the profiles combo.
|
* Updates the profiles combo
|
||||||
*/
|
*/
|
||||||
public void updateProfiles() {
|
public void updateProfiles() {
|
||||||
String selectedProfile = Main.getController().getCurrentProfile().getName();
|
String selectedProfile = Main.getController().getCurrentProfile().getName();
|
||||||
@ -159,31 +179,31 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
/**
|
/**
|
||||||
* Gets the size of the main JFrame
|
* Gets the size of the main JFrame
|
||||||
*
|
*
|
||||||
* @return The Dimension of the frame
|
* @return <p>The Dimension of the main JFrame</p>
|
||||||
*/
|
*/
|
||||||
public Dimension getSize() {
|
public Dimension getSize() {
|
||||||
return frame.getContentPane().getSize();
|
return frame.getContentPane().getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates ServerLauncherGUI according to current profile settings.
|
* Updates ServerLauncherGUI according to current profile settings
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
Controller controller = Main.getController();
|
Controller controller = Main.getController();
|
||||||
serversPane.removeAll();
|
serversPane.removeAll();
|
||||||
chckbxmntmRunInBackground.setState(controller.getRunInBackground());
|
runInBackgroundCheckBoxMenuItem.setState(controller.getRunInBackground());
|
||||||
chckbxmntmDelayStartup.setState(controller.getDelayStartup() > 0);
|
delayStartupCheckBoxMenuItem.setState(controller.getDelayStartup() > 0);
|
||||||
chckbxmntmDownloadJars.setState(controller.getDownloadAllJars());
|
downloadJarsCheckBoxMenuItem.setState(controller.getDownloadAllJars());
|
||||||
this.targetServer.removeAllItems();
|
this.targetServerCombo.removeAllItems();
|
||||||
this.targetServer.addItem("All");
|
this.targetServerCombo.addItem("All");
|
||||||
for (Collection collection : controller.getCurrentProfile().getCollections()) {
|
for (Collection collection : controller.getCurrentProfile().getCollections()) {
|
||||||
serversPane.addTab(collection.getName(), collection.getServerTab().getPanel());
|
serversPane.addTab(collection.getName(), collection.getServerTab().getPanel());
|
||||||
this.targetServer.addItem(collection.getName());
|
this.targetServerCombo.addItem(collection.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the ServerLauncherGUI,
|
* Creates the ServerLauncherGUI
|
||||||
*/
|
*/
|
||||||
private void initialize(int width, int height) throws IOException {
|
private void initialize(int width, int height) throws IOException {
|
||||||
try {
|
try {
|
||||||
@ -210,32 +230,32 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
JMenu mnOptions = new JMenu("Options");
|
JMenu mnOptions = new JMenu("Options");
|
||||||
menuBar.add(mnOptions);
|
menuBar.add(mnOptions);
|
||||||
|
|
||||||
chckbxmntmRunInBackground = new JCheckBoxMenuItem("Run in background on exit");
|
runInBackgroundCheckBoxMenuItem = new JCheckBoxMenuItem("Run in background on exit");
|
||||||
mnOptions.add(chckbxmntmRunInBackground);
|
mnOptions.add(runInBackgroundCheckBoxMenuItem);
|
||||||
chckbxmntmRunInBackground.addActionListener(this);
|
runInBackgroundCheckBoxMenuItem.addActionListener(this);
|
||||||
|
|
||||||
chckbxmntmDelayStartup = new JCheckBoxMenuItem("Delay Startup");
|
delayStartupCheckBoxMenuItem = new JCheckBoxMenuItem("Delay Startup");
|
||||||
mnOptions.add(chckbxmntmDelayStartup);
|
mnOptions.add(delayStartupCheckBoxMenuItem);
|
||||||
chckbxmntmDelayStartup.addActionListener(this);
|
delayStartupCheckBoxMenuItem.addActionListener(this);
|
||||||
|
|
||||||
chckbxmntmDownloadJars = new JCheckBoxMenuItem("Download jars");
|
downloadJarsCheckBoxMenuItem = new JCheckBoxMenuItem("Download jars");
|
||||||
mnOptions.add(chckbxmntmDownloadJars);
|
mnOptions.add(downloadJarsCheckBoxMenuItem);
|
||||||
chckbxmntmDownloadJars.addActionListener(this);
|
downloadJarsCheckBoxMenuItem.addActionListener(this);
|
||||||
|
|
||||||
JMenu mnHelp = new JMenu("Help");
|
JMenu mnHelp = new JMenu("Help");
|
||||||
menuBar.add(mnHelp);
|
menuBar.add(mnHelp);
|
||||||
|
|
||||||
mntmErrors = new JMenuItem("Errors");
|
errorsMenuItem = new JMenuItem("Errors");
|
||||||
mnHelp.add(mntmErrors);
|
mnHelp.add(errorsMenuItem);
|
||||||
mntmErrors.addActionListener(this);
|
errorsMenuItem.addActionListener(this);
|
||||||
|
|
||||||
mntmSetup = new JMenuItem("Setup");
|
setupMenuItem = new JMenuItem("Setup");
|
||||||
mnHelp.add(mntmSetup);
|
mnHelp.add(setupMenuItem);
|
||||||
mntmSetup.addActionListener(this);
|
setupMenuItem.addActionListener(this);
|
||||||
|
|
||||||
mntmManualUpdate = new JMenuItem("Manual update");
|
manualUpdateMenuItem = new JMenuItem("Manual update");
|
||||||
mnHelp.add(mntmManualUpdate);
|
mnHelp.add(manualUpdateMenuItem);
|
||||||
mntmManualUpdate.addActionListener(this);
|
manualUpdateMenuItem.addActionListener(this);
|
||||||
|
|
||||||
JMenu mnInfo = new JMenu("Info");
|
JMenu mnInfo = new JMenu("Info");
|
||||||
menuBar.add(mnInfo);
|
menuBar.add(mnInfo);
|
||||||
@ -243,28 +263,28 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
JMenu mnOptionsInfo = new JMenu("Options");
|
JMenu mnOptionsInfo = new JMenu("Options");
|
||||||
mnInfo.add(mnOptionsInfo);
|
mnInfo.add(mnOptionsInfo);
|
||||||
|
|
||||||
mntmRunInBackground = new JMenuItem("Run in background on exit");
|
runInBackgroundMenuItem = new JMenuItem("Run in background on exit");
|
||||||
mnOptionsInfo.add(mntmRunInBackground);
|
mnOptionsInfo.add(runInBackgroundMenuItem);
|
||||||
mntmRunInBackground.addActionListener(this);
|
runInBackgroundMenuItem.addActionListener(this);
|
||||||
|
|
||||||
mntmDelayStartup = new JMenuItem("Delay Startup");
|
delayStartupMenuItem = new JMenuItem("Delay Startup");
|
||||||
mnOptionsInfo.add(mntmDelayStartup);
|
mnOptionsInfo.add(delayStartupMenuItem);
|
||||||
mntmDelayStartup.addActionListener(this);
|
delayStartupMenuItem.addActionListener(this);
|
||||||
|
|
||||||
mntmDownloadJars = new JMenuItem("Download jars");
|
downloadJarsMenuItem = new JMenuItem("Download jars");
|
||||||
mnOptionsInfo.add(mntmDownloadJars);
|
mnOptionsInfo.add(downloadJarsMenuItem);
|
||||||
mntmDownloadJars.addActionListener(this);
|
downloadJarsMenuItem.addActionListener(this);
|
||||||
|
|
||||||
JMenu mnAbout = new JMenu("About");
|
JMenu mnAbout = new JMenu("About");
|
||||||
mnInfo.add(mnAbout);
|
mnInfo.add(mnAbout);
|
||||||
|
|
||||||
mntmAbout = new JMenuItem("About");
|
aboutMenuItem = new JMenuItem("About");
|
||||||
mnAbout.add(mntmAbout);
|
mnAbout.add(aboutMenuItem);
|
||||||
mntmAbout.addActionListener(this);
|
aboutMenuItem.addActionListener(this);
|
||||||
|
|
||||||
mntmStory = new JMenuItem("Story");
|
storyMenuItem = new JMenuItem("Story");
|
||||||
mnAbout.add(mntmStory);
|
mnAbout.add(storyMenuItem);
|
||||||
mntmStory.addActionListener(this);
|
storyMenuItem.addActionListener(this);
|
||||||
|
|
||||||
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
||||||
frame.getContentPane().add(tabbedPane);
|
frame.getContentPane().add(tabbedPane);
|
||||||
@ -278,159 +298,159 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
sl_panel.putConstraint(SpringLayout.NORTH, lblBasicControls, 10, SpringLayout.NORTH, panelBasic);
|
sl_panel.putConstraint(SpringLayout.NORTH, lblBasicControls, 10, SpringLayout.NORTH, panelBasic);
|
||||||
panelBasic.add(lblBasicControls);
|
panelBasic.add(lblBasicControls);
|
||||||
|
|
||||||
btnStartServer = new JButton("Start servers");
|
startServerButton = new JButton("Start servers");
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, lblBasicControls, 0, SpringLayout.WEST, btnStartServer);
|
sl_panel.putConstraint(SpringLayout.WEST, lblBasicControls, 0, SpringLayout.WEST, startServerButton);
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, btnStartServer, 6, SpringLayout.SOUTH, lblBasicControls);
|
sl_panel.putConstraint(SpringLayout.NORTH, startServerButton, 6, SpringLayout.SOUTH, lblBasicControls);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, btnStartServer, 10, SpringLayout.WEST, panelBasic);
|
sl_panel.putConstraint(SpringLayout.WEST, startServerButton, 10, SpringLayout.WEST, panelBasic);
|
||||||
panelBasic.add(btnStartServer);
|
panelBasic.add(startServerButton);
|
||||||
btnStartServer.addActionListener(this);
|
startServerButton.addActionListener(this);
|
||||||
|
|
||||||
btnStopServer = new JButton("Stop servers");
|
stopServerButton = new JButton("Stop servers");
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, btnStopServer, 0, SpringLayout.NORTH, btnStartServer);
|
sl_panel.putConstraint(SpringLayout.NORTH, stopServerButton, 0, SpringLayout.NORTH, startServerButton);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, btnStopServer, 6, SpringLayout.EAST, btnStartServer);
|
sl_panel.putConstraint(SpringLayout.WEST, stopServerButton, 6, SpringLayout.EAST, startServerButton);
|
||||||
panelBasic.add(btnStopServer);
|
panelBasic.add(stopServerButton);
|
||||||
btnStopServer.addActionListener(this);
|
stopServerButton.addActionListener(this);
|
||||||
|
|
||||||
JLabel lblProfile = new JLabel("Profile");
|
JLabel lblProfile = new JLabel("Profile");
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, lblProfile, 6, SpringLayout.SOUTH, btnStartServer);
|
sl_panel.putConstraint(SpringLayout.NORTH, lblProfile, 6, SpringLayout.SOUTH, startServerButton);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, lblProfile, 10, SpringLayout.WEST, panelBasic);
|
sl_panel.putConstraint(SpringLayout.WEST, lblProfile, 10, SpringLayout.WEST, panelBasic);
|
||||||
panelBasic.add(lblProfile);
|
panelBasic.add(lblProfile);
|
||||||
|
|
||||||
addProfile = new JButton("+");
|
addProfileButton = new JButton("+");
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, addProfile, 6, SpringLayout.SOUTH, lblProfile);
|
sl_panel.putConstraint(SpringLayout.NORTH, addProfileButton, 6, SpringLayout.SOUTH, lblProfile);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, addProfile, 10, SpringLayout.WEST, panelBasic);
|
sl_panel.putConstraint(SpringLayout.WEST, addProfileButton, 10, SpringLayout.WEST, panelBasic);
|
||||||
panelBasic.add(addProfile);
|
panelBasic.add(addProfileButton);
|
||||||
addProfile.addActionListener(this);
|
addProfileButton.addActionListener(this);
|
||||||
|
|
||||||
delProfile = new JButton("-");
|
deleteProfileButton = new JButton("-");
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, delProfile, 0, SpringLayout.NORTH, addProfile);
|
sl_panel.putConstraint(SpringLayout.NORTH, deleteProfileButton, 0, SpringLayout.NORTH, addProfileButton);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, delProfile, 6, SpringLayout.EAST, addProfile);
|
sl_panel.putConstraint(SpringLayout.WEST, deleteProfileButton, 6, SpringLayout.EAST, addProfileButton);
|
||||||
panelBasic.add(delProfile);
|
panelBasic.add(deleteProfileButton);
|
||||||
delProfile.addActionListener(this);
|
deleteProfileButton.addActionListener(this);
|
||||||
|
|
||||||
profiles = new JComboBox<>();
|
profiles = new JComboBox<>();
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, profiles, 0, SpringLayout.NORTH, addProfile);
|
sl_panel.putConstraint(SpringLayout.NORTH, profiles, 0, SpringLayout.NORTH, addProfileButton);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, profiles, 6, SpringLayout.EAST, delProfile);
|
sl_panel.putConstraint(SpringLayout.WEST, profiles, 6, SpringLayout.EAST, deleteProfileButton);
|
||||||
sl_panel.putConstraint(SpringLayout.EAST, profiles, 124, SpringLayout.EAST, delProfile);
|
sl_panel.putConstraint(SpringLayout.EAST, profiles, 124, SpringLayout.EAST, deleteProfileButton);
|
||||||
panelBasic.add(profiles);
|
panelBasic.add(profiles);
|
||||||
profiles.addActionListener(this);
|
profiles.addActionListener(this);
|
||||||
|
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 6, SpringLayout.SOUTH, addProfile);
|
sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 6, SpringLayout.SOUTH, addProfileButton);
|
||||||
sl_panel.putConstraint(SpringLayout.SOUTH, lblStatuslabel, -10, SpringLayout.SOUTH, panelBasic);
|
sl_panel.putConstraint(SpringLayout.SOUTH, lblStatuslabel, -10, SpringLayout.SOUTH, panelBasic);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, lblStatuslabel, 10, SpringLayout.WEST, panelBasic);
|
sl_panel.putConstraint(SpringLayout.WEST, lblStatuslabel, 10, SpringLayout.WEST, panelBasic);
|
||||||
sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, -10, SpringLayout.EAST, panelBasic);
|
sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, -10, SpringLayout.EAST, panelBasic);
|
||||||
panelBasic.add(lblStatuslabel);
|
panelBasic.add(lblStatuslabel);
|
||||||
|
|
||||||
addServer = new JButton("Add server");
|
addServerButton = new JButton("Add server");
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, addServer, 0, SpringLayout.NORTH, btnStartServer);
|
sl_panel.putConstraint(SpringLayout.NORTH, addServerButton, 0, SpringLayout.NORTH, startServerButton);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, addServer, 6, SpringLayout.EAST, btnStopServer);
|
sl_panel.putConstraint(SpringLayout.WEST, addServerButton, 6, SpringLayout.EAST, stopServerButton);
|
||||||
panelBasic.add(addServer);
|
panelBasic.add(addServerButton);
|
||||||
addServer.addActionListener(this);
|
addServerButton.addActionListener(this);
|
||||||
|
|
||||||
backup = new JButton("Backup");
|
backupButton = new JButton("Backup");
|
||||||
sl_panel.putConstraint(SpringLayout.NORTH, backup, 0, SpringLayout.NORTH, btnStartServer);
|
sl_panel.putConstraint(SpringLayout.NORTH, backupButton, 0, SpringLayout.NORTH, startServerButton);
|
||||||
sl_panel.putConstraint(SpringLayout.WEST, backup, 6, SpringLayout.EAST, addServer);
|
sl_panel.putConstraint(SpringLayout.WEST, backupButton, 6, SpringLayout.EAST, addServerButton);
|
||||||
panelBasic.add(backup);
|
panelBasic.add(backupButton);
|
||||||
backup.addActionListener(this);
|
backupButton.addActionListener(this);
|
||||||
|
|
||||||
JPanel controlServers = new JPanel();
|
JPanel controlServers = new JPanel();
|
||||||
tabbedPane.addTab("Control servers", null, controlServers, null);
|
tabbedPane.addTab("Control servers", null, controlServers, null);
|
||||||
SpringLayout sl_panel_1 = new SpringLayout();
|
SpringLayout sl_panel_1 = new SpringLayout();
|
||||||
controlServers.setLayout(sl_panel_1);
|
controlServers.setLayout(sl_panel_1);
|
||||||
|
|
||||||
targetServer = new JComboBox<>();
|
targetServerCombo = new JComboBox<>();
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, targetServer, 10, SpringLayout.NORTH, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, targetServerCombo, 10, SpringLayout.NORTH, controlServers);
|
||||||
controlServers.add(targetServer);
|
controlServers.add(targetServerCombo);
|
||||||
targetServer.addActionListener(this);
|
targetServerCombo.addActionListener(this);
|
||||||
|
|
||||||
targetPlayer = new JComboBox<>();
|
targetPlayerCombo = new JComboBox<>();
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, targetPlayer, 6, SpringLayout.SOUTH, targetServer);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, targetPlayerCombo, 6, SpringLayout.SOUTH, targetServerCombo);
|
||||||
targetPlayer.setEditable(true);
|
targetPlayerCombo.setEditable(true);
|
||||||
controlServers.add(targetPlayer);
|
controlServers.add(targetPlayerCombo);
|
||||||
|
|
||||||
btnKick = new JButton("Kick");
|
kickButton = new JButton("Kick");
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnKick, 10, SpringLayout.NORTH, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, kickButton, 10, SpringLayout.NORTH, controlServers);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnKick, 6, SpringLayout.EAST, targetServer);
|
sl_panel_1.putConstraint(SpringLayout.WEST, kickButton, 6, SpringLayout.EAST, targetServerCombo);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnKick, 104, SpringLayout.WEST, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.EAST, kickButton, 104, SpringLayout.WEST, kickButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetServer, 0, SpringLayout.SOUTH, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetServerCombo, 0, SpringLayout.SOUTH, kickButton);
|
||||||
controlServers.add(btnKick);
|
controlServers.add(kickButton);
|
||||||
btnKick.addActionListener(this);
|
kickButton.addActionListener(this);
|
||||||
|
|
||||||
btnBan = new JButton("Ban");
|
banButton = new JButton("Ban");
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnBan, 6, SpringLayout.SOUTH, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, banButton, 6, SpringLayout.SOUTH, kickButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnBan, 6, SpringLayout.EAST, targetPlayer);
|
sl_panel_1.putConstraint(SpringLayout.WEST, banButton, 6, SpringLayout.EAST, targetPlayerCombo);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnBan, 104, SpringLayout.WEST, btnBan);
|
sl_panel_1.putConstraint(SpringLayout.EAST, banButton, 104, SpringLayout.WEST, banButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetPlayer, 0, SpringLayout.SOUTH, btnBan);
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetPlayerCombo, 0, SpringLayout.SOUTH, banButton);
|
||||||
controlServers.add(btnBan);
|
controlServers.add(banButton);
|
||||||
btnBan.addActionListener(this);
|
banButton.addActionListener(this);
|
||||||
|
|
||||||
btnOp = new JButton("OP");
|
opButton = new JButton("OP");
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnOp, 10, SpringLayout.NORTH, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, opButton, 10, SpringLayout.NORTH, controlServers);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnOp, 6, SpringLayout.EAST, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.WEST, opButton, 6, SpringLayout.EAST, kickButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnOp, -10, SpringLayout.EAST, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.EAST, opButton, -10, SpringLayout.EAST, controlServers);
|
||||||
controlServers.add(btnOp);
|
controlServers.add(opButton);
|
||||||
btnOp.addActionListener(this);
|
opButton.addActionListener(this);
|
||||||
|
|
||||||
btnDeop = new JButton("DEOP");
|
deopButton = new JButton("DEOP");
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnDeop, 6, SpringLayout.EAST, btnBan);
|
sl_panel_1.putConstraint(SpringLayout.WEST, deopButton, 6, SpringLayout.EAST, banButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnDeop, 5, SpringLayout.SOUTH, btnOp);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, deopButton, 5, SpringLayout.SOUTH, opButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnDeop, -10, SpringLayout.EAST, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.EAST, deopButton, -10, SpringLayout.EAST, controlServers);
|
||||||
controlServers.add(btnDeop);
|
controlServers.add(deopButton);
|
||||||
btnDeop.addActionListener(this);
|
deopButton.addActionListener(this);
|
||||||
|
|
||||||
JLabel lblTargetServer = new JLabel("Target server");
|
JLabel lblTargetServer = new JLabel("Target server");
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, targetServer, 6, SpringLayout.EAST, lblTargetServer);
|
sl_panel_1.putConstraint(SpringLayout.WEST, targetServerCombo, 6, SpringLayout.EAST, lblTargetServer);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, targetServer, 121, SpringLayout.EAST, lblTargetServer);
|
sl_panel_1.putConstraint(SpringLayout.EAST, targetServerCombo, 121, SpringLayout.EAST, lblTargetServer);
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, lblTargetServer, 10, SpringLayout.NORTH, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, lblTargetServer, 10, SpringLayout.NORTH, controlServers);
|
||||||
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblTargetServer, 0, SpringLayout.SOUTH, targetServer);
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblTargetServer, 0, SpringLayout.SOUTH, targetServerCombo);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, lblTargetServer, 10, SpringLayout.WEST, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.WEST, lblTargetServer, 10, SpringLayout.WEST, controlServers);
|
||||||
controlServers.add(lblTargetServer);
|
controlServers.add(lblTargetServer);
|
||||||
|
|
||||||
JLabel lblTargetPlayer = new JLabel("Target player");
|
JLabel lblTargetPlayer = new JLabel("Target player");
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, targetPlayer, 7, SpringLayout.EAST, lblTargetPlayer);
|
sl_panel_1.putConstraint(SpringLayout.WEST, targetPlayerCombo, 7, SpringLayout.EAST, lblTargetPlayer);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, targetPlayer, 122, SpringLayout.EAST, lblTargetPlayer);
|
sl_panel_1.putConstraint(SpringLayout.EAST, targetPlayerCombo, 122, SpringLayout.EAST, lblTargetPlayer);
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, lblTargetPlayer, 6, SpringLayout.SOUTH, lblTargetServer);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, lblTargetPlayer, 6, SpringLayout.SOUTH, lblTargetServer);
|
||||||
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblTargetPlayer, 0, SpringLayout.SOUTH, targetPlayer);
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, lblTargetPlayer, 0, SpringLayout.SOUTH, targetPlayerCombo);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, lblTargetPlayer, 0, SpringLayout.WEST, lblTargetServer);
|
sl_panel_1.putConstraint(SpringLayout.WEST, lblTargetPlayer, 0, SpringLayout.WEST, lblTargetServer);
|
||||||
controlServers.add(lblTargetPlayer);
|
controlServers.add(lblTargetPlayer);
|
||||||
|
|
||||||
btnCustomCommand = new JButton("Custom command");
|
customCommandButton = new JButton("Custom command");
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnCustomCommand, 250, SpringLayout.WEST, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.WEST, customCommandButton, 250, SpringLayout.WEST, controlServers);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnCustomCommand, 0, SpringLayout.EAST, btnOp);
|
sl_panel_1.putConstraint(SpringLayout.EAST, customCommandButton, 0, SpringLayout.EAST, opButton);
|
||||||
controlServers.add(btnCustomCommand);
|
controlServers.add(customCommandButton);
|
||||||
btnCustomCommand.addActionListener(this);
|
customCommandButton.addActionListener(this);
|
||||||
frame.getRootPane().setDefaultButton(btnCustomCommand);
|
frame.getRootPane().setDefaultButton(customCommandButton);
|
||||||
|
|
||||||
customCommand = new JTextField();
|
customCommandTextField = new JTextField();
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, customCommand, 10, SpringLayout.WEST, controlServers);
|
sl_panel_1.putConstraint(SpringLayout.WEST, customCommandTextField, 10, SpringLayout.WEST, controlServers);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, customCommand, -6, SpringLayout.WEST, btnCustomCommand);
|
sl_panel_1.putConstraint(SpringLayout.EAST, customCommandTextField, -6, SpringLayout.WEST, customCommandButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnCustomCommand, 0, SpringLayout.NORTH, customCommand);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, customCommandButton, 0, SpringLayout.NORTH, customCommandTextField);
|
||||||
sl_panel_1.putConstraint(SpringLayout.SOUTH, customCommand, 0, SpringLayout.SOUTH, btnCustomCommand);
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, customCommandTextField, 0, SpringLayout.SOUTH, customCommandButton);
|
||||||
controlServers.add(customCommand);
|
controlServers.add(customCommandTextField);
|
||||||
customCommand.setColumns(10);
|
customCommandTextField.setColumns(10);
|
||||||
|
|
||||||
btnSaveserver = new JButton("Save server");
|
saveServerButton = new JButton("Save server");
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, customCommand, 6, SpringLayout.SOUTH, btnSaveserver);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, customCommandTextField, 6, SpringLayout.SOUTH, saveServerButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnSaveserver, 6, SpringLayout.SOUTH, btnBan);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, saveServerButton, 6, SpringLayout.SOUTH, banButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnSaveserver, 0, SpringLayout.WEST, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.WEST, saveServerButton, 0, SpringLayout.WEST, kickButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 104, SpringLayout.WEST, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.EAST, saveServerButton, 104, SpringLayout.WEST, kickButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 104, SpringLayout.WEST, btnKick);
|
sl_panel_1.putConstraint(SpringLayout.EAST, saveServerButton, 104, SpringLayout.WEST, kickButton);
|
||||||
controlServers.add(btnSaveserver);
|
controlServers.add(saveServerButton);
|
||||||
btnSaveserver.addActionListener(this);
|
saveServerButton.addActionListener(this);
|
||||||
|
|
||||||
btnReload = new JButton("Reload");
|
reloadButton = new JButton("Reload");
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnReload, 6, SpringLayout.SOUTH, btnDeop);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, reloadButton, 6, SpringLayout.SOUTH, deopButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnReload, 0, SpringLayout.WEST, btnDeop);
|
sl_panel_1.putConstraint(SpringLayout.WEST, reloadButton, 0, SpringLayout.WEST, deopButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnReload, 0, SpringLayout.EAST, btnOp);
|
sl_panel_1.putConstraint(SpringLayout.EAST, reloadButton, 0, SpringLayout.EAST, opButton);
|
||||||
controlServers.add(btnReload);
|
controlServers.add(reloadButton);
|
||||||
btnReload.addActionListener(this);
|
reloadButton.addActionListener(this);
|
||||||
|
|
||||||
btnServerConsoles = new JButton("View server consoles");
|
showConsolesButton = new JButton("View server consoles");
|
||||||
sl_panel_1.putConstraint(SpringLayout.NORTH, btnServerConsoles, 0, SpringLayout.NORTH, btnSaveserver);
|
sl_panel_1.putConstraint(SpringLayout.NORTH, showConsolesButton, 0, SpringLayout.NORTH, saveServerButton);
|
||||||
sl_panel_1.putConstraint(SpringLayout.WEST, btnServerConsoles, 0, SpringLayout.WEST, lblTargetServer);
|
sl_panel_1.putConstraint(SpringLayout.WEST, showConsolesButton, 0, SpringLayout.WEST, lblTargetServer);
|
||||||
sl_panel_1.putConstraint(SpringLayout.EAST, btnServerConsoles, 0, SpringLayout.EAST, targetServer);
|
sl_panel_1.putConstraint(SpringLayout.EAST, showConsolesButton, 0, SpringLayout.EAST, targetServerCombo);
|
||||||
controlServers.add(btnServerConsoles);
|
controlServers.add(showConsolesButton);
|
||||||
btnServerConsoles.addActionListener(this);
|
showConsolesButton.addActionListener(this);
|
||||||
|
|
||||||
JPanel panel_2 = new JPanel();
|
JPanel panel_2 = new JPanel();
|
||||||
tabbedPane.addTab("Servers", null, panel_2, null);
|
tabbedPane.addTab("Servers", null, panel_2, null);
|
||||||
@ -455,7 +475,7 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the system tray if available.
|
* Prepares the system tray if available
|
||||||
*/
|
*/
|
||||||
private void tray() {
|
private void tray() {
|
||||||
if (SystemTray.isSupported()) {
|
if (SystemTray.isSupported()) {
|
||||||
@ -535,7 +555,7 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the gui to the tray,
|
* Hides the gui to the tray
|
||||||
*/
|
*/
|
||||||
public void hide() {
|
public void hide() {
|
||||||
frame.setVisible(false);
|
frame.setVisible(false);
|
||||||
@ -549,42 +569,42 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
String selectedServerValue = null, selectedPlayerValue = null;
|
String selectedServerValue = null, selectedPlayerValue = null;
|
||||||
Object selectedServer = targetServer.getSelectedItem();
|
Object selectedServer = targetServerCombo.getSelectedItem();
|
||||||
if (selectedServer != null) {
|
if (selectedServer != null) {
|
||||||
selectedServerValue = selectedServer.toString();
|
selectedServerValue = selectedServer.toString();
|
||||||
}
|
}
|
||||||
Object selectedPlayer = targetPlayer.getSelectedItem();
|
Object selectedPlayer = targetPlayerCombo.getSelectedItem();
|
||||||
if (selectedPlayer != null) {
|
if (selectedPlayer != null) {
|
||||||
selectedPlayerValue = selectedPlayer.toString();
|
selectedPlayerValue = selectedPlayer.toString();
|
||||||
}
|
}
|
||||||
if (e.getSource() == chckbxmntmRunInBackground) {
|
if (e.getSource() == runInBackgroundCheckBoxMenuItem) {
|
||||||
background();
|
background();
|
||||||
} else if (e.getSource() == chckbxmntmDelayStartup) {
|
} else if (e.getSource() == delayStartupCheckBoxMenuItem) {
|
||||||
delay();
|
delay();
|
||||||
} else if (e.getSource() == chckbxmntmDownloadJars) {
|
} else if (e.getSource() == downloadJarsCheckBoxMenuItem) {
|
||||||
downloadJars();
|
downloadJars();
|
||||||
} else if (e.getSource() == mntmErrors) {
|
} else if (e.getSource() == errorsMenuItem) {
|
||||||
CommonFunctions.goToURL("https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherInfo/");
|
CommonFunctions.goToURL(textStrings.get("infoURL"));
|
||||||
} else if (e.getSource() == mntmSetup) {
|
} else if (e.getSource() == setupMenuItem) {
|
||||||
showMessage("Setup", setupText);
|
showMessage("Setup", textStrings.get("setupText"));
|
||||||
} else if (e.getSource() == mntmManualUpdate) {
|
} else if (e.getSource() == manualUpdateMenuItem) {
|
||||||
CommonFunctions.goToURL("https://git.knarcraft.net/KnarCraft/Minecraft-Server-Launcher/releases");
|
CommonFunctions.goToURL(textStrings.get("manualUpdateURL"));
|
||||||
} else if (e.getSource() == mntmRunInBackground) {
|
} else if (e.getSource() == runInBackgroundMenuItem) {
|
||||||
showMessage("Run in background", runInBackgroundText);
|
showMessage("Run in background", textStrings.get("runInBackgroundText"));
|
||||||
} else if (e.getSource() == mntmDelayStartup) {
|
} else if (e.getSource() == delayStartupMenuItem) {
|
||||||
showMessage("Delay startup", delayStartupText);
|
showMessage("Delay startup", textStrings.get("delayStartupText"));
|
||||||
} else if (e.getSource() == mntmDownloadJars) {
|
} else if (e.getSource() == downloadJarsMenuItem) {
|
||||||
showMessage("Download jars", downloadJarsText);
|
showMessage("Download jars", textStrings.get("downloadJarsText"));
|
||||||
} else if (e.getSource() == mntmAbout) {
|
} else if (e.getSource() == aboutMenuItem) {
|
||||||
showMessage("About", aboutText);
|
showMessage("About", textStrings.get("aboutText"));
|
||||||
} else if (e.getSource() == mntmStory) {
|
} else if (e.getSource() == storyMenuItem) {
|
||||||
CommonFunctions.goToURL("https://archive.knarcraft.net/Scripts/BungeeMinecraftServerLauncherStory/");
|
CommonFunctions.goToURL(textStrings.get("storyURL"));
|
||||||
} else if (e.getSource() == btnStartServer) {
|
} else if (e.getSource() == startServerButton) {
|
||||||
controller.saveState();
|
controller.saveState();
|
||||||
Executors.newSingleThreadExecutor().execute(Server::startServers);
|
Executors.newSingleThreadExecutor().execute(Server::startServers);
|
||||||
} else if (e.getSource() == btnStopServer) {
|
} else if (e.getSource() == stopServerButton) {
|
||||||
stop();
|
stop();
|
||||||
} else if (e.getSource() == addServer) {
|
} else if (e.getSource() == addServerButton) {
|
||||||
String serverName = JOptionPane.showInputDialog("Name of server: ");
|
String serverName = JOptionPane.showInputDialog("Name of server: ");
|
||||||
try {
|
try {
|
||||||
controller.getCurrentProfile().addCollection(serverName);
|
controller.getCurrentProfile().addCollection(serverName);
|
||||||
@ -593,12 +613,12 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
this.update();
|
this.update();
|
||||||
controller.getCurrentProfile().updateConsoles();
|
controller.getCurrentProfile().updateConsoles();
|
||||||
} else if (e.getSource() == backup) {
|
} else if (e.getSource() == backupButton) {
|
||||||
CommonFunctions.backup(this);
|
CommonFunctions.backup(this);
|
||||||
} else if (e.getSource() == addProfile) {
|
} else if (e.getSource() == addProfileButton) {
|
||||||
controller.addProfile(JOptionPane.showInputDialog("Profile name: "));
|
controller.addProfile(JOptionPane.showInputDialog("Profile name: "));
|
||||||
updateProfiles();
|
updateProfiles();
|
||||||
} else if (e.getSource() == delProfile) {
|
} else if (e.getSource() == deleteProfileButton) {
|
||||||
Object selected = profiles.getSelectedItem();
|
Object selected = profiles.getSelectedItem();
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
controller.removeProfile(selected.toString());
|
controller.removeProfile(selected.toString());
|
||||||
@ -606,60 +626,60 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
} else if (e.getSource() == profiles) {
|
} else if (e.getSource() == profiles) {
|
||||||
changeProfile();
|
changeProfile();
|
||||||
} else if (e.getSource() == btnKick) {
|
} else if (e.getSource() == kickButton) {
|
||||||
if (selectedServerValue != null && selectedPlayerValue != null) {
|
if (selectedServerValue != null && selectedPlayerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, "kick " + selectedPlayerValue);
|
controller.getCurrentProfile().sendCommand(selectedServerValue, "kick " + selectedPlayerValue);
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnBan) {
|
} else if (e.getSource() == banButton) {
|
||||||
if (selectedServerValue != null && selectedPlayerValue != null) {
|
if (selectedServerValue != null && selectedPlayerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, "ban " + selectedPlayerValue);
|
controller.getCurrentProfile().sendCommand(selectedServerValue, "ban " + selectedPlayerValue);
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnOp) {
|
} else if (e.getSource() == opButton) {
|
||||||
if (selectedServerValue != null && selectedPlayerValue != null) {
|
if (selectedServerValue != null && selectedPlayerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, "op " + selectedPlayerValue);
|
controller.getCurrentProfile().sendCommand(selectedServerValue, "op " + selectedPlayerValue);
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnDeop) {
|
} else if (e.getSource() == deopButton) {
|
||||||
if (selectedServerValue != null && selectedPlayerValue != null) {
|
if (selectedServerValue != null && selectedPlayerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, "deop " + selectedPlayerValue);
|
controller.getCurrentProfile().sendCommand(selectedServerValue, "deop " + selectedPlayerValue);
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnCustomCommand) {
|
} else if (e.getSource() == customCommandButton) {
|
||||||
if (selectedServerValue != null) {
|
if (selectedServerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, customCommand.getText());
|
controller.getCurrentProfile().sendCommand(selectedServerValue, customCommandTextField.getText());
|
||||||
customCommand.setText("");
|
customCommandTextField.setText("");
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnSaveserver) {
|
} else if (e.getSource() == saveServerButton) {
|
||||||
if (selectedServerValue != null) {
|
if (selectedServerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, "save-all");
|
controller.getCurrentProfile().sendCommand(selectedServerValue, "save-all");
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnReload) {
|
} else if (e.getSource() == reloadButton) {
|
||||||
if (selectedServerValue != null) {
|
if (selectedServerValue != null) {
|
||||||
controller.getCurrentProfile().sendCommand(selectedServerValue, "reload");
|
controller.getCurrentProfile().sendCommand(selectedServerValue, "reload");
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == btnServerConsoles) {
|
} else if (e.getSource() == showConsolesButton) {
|
||||||
ServerConsoles.setAsVisible();
|
ServerConsoles.setAsVisible();
|
||||||
} else if (e.getSource() == targetServer) {
|
} else if (e.getSource() == targetServerCombo) {
|
||||||
updatePlayers();
|
updatePlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the ServerLauncherGUI components to block a user from doing illegal actions.
|
* Updates the ServerLauncherGUI components to block a user from doing illegal actions
|
||||||
*
|
*
|
||||||
* @param running Are the servers currently running?
|
* @param running <p>Whether the servers are currently running</p>
|
||||||
*/
|
*/
|
||||||
public void updateRunning(boolean running) {
|
public void updateRunning(boolean running) {
|
||||||
boolean stopped = !running; //Most gui is only enabled when the server is stopped rather than running.
|
boolean stopped = !running; //Most gui is only enabled when the server is stopped rather than running.
|
||||||
profiles.setEnabled(stopped);
|
profiles.setEnabled(stopped);
|
||||||
addProfile.setEnabled(stopped);
|
addProfileButton.setEnabled(stopped);
|
||||||
delProfile.setEnabled(stopped);
|
deleteProfileButton.setEnabled(stopped);
|
||||||
btnStartServer.setEnabled(stopped);
|
startServerButton.setEnabled(stopped);
|
||||||
addServer.setEnabled(stopped);
|
addServerButton.setEnabled(stopped);
|
||||||
tabbedPane.setEnabledAt(2, stopped);
|
tabbedPane.setEnabledAt(2, stopped);
|
||||||
btnStopServer.setEnabled(running);
|
stopServerButton.setEnabled(running);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the previous profile and loads data from the new profile.
|
* Saves the previous profile and loads data from the new profile
|
||||||
*/
|
*/
|
||||||
private void changeProfile() {
|
private void changeProfile() {
|
||||||
controller.saveState();
|
controller.saveState();
|
||||||
@ -685,16 +705,16 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asks the user for a delay if checked, and sets the value to the current profile.
|
* Asks the user for a delay if checked, and sets the value to the current profile
|
||||||
*/
|
*/
|
||||||
private void delay() {
|
private void delay() {
|
||||||
Object selected = profiles.getSelectedItem();
|
Object selected = profiles.getSelectedItem();
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
Profile profile = controller.getProfileByName(selected.toString());
|
Profile profile = controller.getProfileByName(selected.toString());
|
||||||
if (chckbxmntmDelayStartup.isSelected()) {
|
if (delayStartupCheckBoxMenuItem.isSelected()) {
|
||||||
String response = JOptionPane.showInputDialog("Seconds to delay: ");
|
String response = JOptionPane.showInputDialog("Seconds to delay: ");
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
chckbxmntmDelayStartup.setState(false);
|
delayStartupCheckBoxMenuItem.setState(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int parsed = Integer.parseInt(response);
|
int parsed = Integer.parseInt(response);
|
||||||
@ -708,76 +728,62 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the runInBackground setting to the current profile.
|
* Saves the runInBackground setting to the current profile
|
||||||
*/
|
*/
|
||||||
private void background() {
|
private void background() {
|
||||||
Object selected = profiles.getSelectedItem();
|
Object selected = profiles.getSelectedItem();
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
Profile profile = controller.getProfileByName(selected.toString());
|
Profile profile = controller.getProfileByName(selected.toString());
|
||||||
Objects.requireNonNull(profile).setRunInBackground(chckbxmntmRunInBackground.isSelected());
|
Objects.requireNonNull(profile).setRunInBackground(runInBackgroundCheckBoxMenuItem.isSelected());
|
||||||
} else {
|
} else {
|
||||||
showError("No profile selected");
|
showError("No profile selected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the downloadJars setting to the current profile.
|
* Saves the downloadJars setting to the current profile
|
||||||
*/
|
*/
|
||||||
private void downloadJars() {
|
private void downloadJars() {
|
||||||
Object selected = profiles.getSelectedItem();
|
Object selected = profiles.getSelectedItem();
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
controller.setDownloadAllJars(chckbxmntmDownloadJars.isSelected());
|
controller.setDownloadAllJars(downloadJarsCheckBoxMenuItem.isSelected());
|
||||||
} else {
|
} else {
|
||||||
showError("No profile selected");
|
showError("No profile selected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the list of players currently online on the selected server,
|
* Updates the list of players currently online on the selected server
|
||||||
*/
|
*/
|
||||||
private void updatePlayers() {
|
private void updatePlayers() {
|
||||||
String selectedServerValue;
|
String selectedServerValue;
|
||||||
Object selectedServer = targetServer.getSelectedItem();
|
Object selectedServer = targetServerCombo.getSelectedItem();
|
||||||
if (selectedServer != null) {
|
if (selectedServer != null) {
|
||||||
targetPlayer.removeAllItems();
|
targetPlayerCombo.removeAllItems();
|
||||||
selectedServerValue = selectedServer.toString();
|
selectedServerValue = selectedServer.toString();
|
||||||
if (selectedServerValue.equals("All")) {
|
if (selectedServerValue.equals("All")) {
|
||||||
for (String player : this.globalPlayers) {
|
for (String player : this.globalPlayers) {
|
||||||
targetPlayer.addItem(player);
|
targetPlayerCombo.addItem(player);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (String player : controller.getCurrentProfile().getCollection(selectedServerValue).getServer().getPlayers()) {
|
for (String player : controller.getCurrentProfile().getCollection(selectedServerValue).getServer().getPlayers()) {
|
||||||
targetPlayer.addItem(player);
|
targetPlayerCombo.addItem(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads popup messages from a text file.
|
* Loads popup messages from a text file
|
||||||
*/
|
*/
|
||||||
private void loadMessages() throws FileNotFoundException {
|
private void loadMessages() throws FileNotFoundException {
|
||||||
|
textStrings = new HashMap<>();
|
||||||
Scanner file = getResourceAsScanner("menumsg.csv");
|
Scanner file = getResourceAsScanner("menumsg.csv");
|
||||||
while (file.hasNextLine()) {
|
while (file.hasNextLine()) {
|
||||||
String nextLine = file.nextLine();
|
String nextLine = file.nextLine();
|
||||||
String[] line = nextLine.split("=");
|
String[] line = nextLine.split("=");
|
||||||
String content = line[1].replaceAll("_BREAK_", System.getProperty("line.separator"));
|
String content = line[1].replaceAll("_BREAK_", System.getProperty("line.separator"));
|
||||||
switch (line[0]) {
|
textStrings.put(line[0], content);
|
||||||
case "setup":
|
|
||||||
setupText = content;
|
|
||||||
break;
|
|
||||||
case "runinbk":
|
|
||||||
runInBackgroundText = content;
|
|
||||||
break;
|
|
||||||
case "delaystartup":
|
|
||||||
delayStartupText = content;
|
|
||||||
break;
|
|
||||||
case "downloadjars":
|
|
||||||
downloadJarsText = content;
|
|
||||||
break;
|
|
||||||
case "about":
|
|
||||||
aboutText = content;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import net.knarcraft.minecraftserverlauncher.Main;
|
|||||||
import net.knarcraft.minecraftserverlauncher.profile.Collection;
|
import net.knarcraft.minecraftserverlauncher.profile.Collection;
|
||||||
import net.knarcraft.minecraftserverlauncher.server.Server;
|
import net.knarcraft.minecraftserverlauncher.server.Server;
|
||||||
import net.knarcraft.minecraftserverlauncher.userinterface.GUI;
|
import net.knarcraft.minecraftserverlauncher.userinterface.GUI;
|
||||||
|
import net.knarcraft.minecraftserverlauncher.userinterface.WebBrowser;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -181,8 +182,8 @@ public final class CommonFunctions {
|
|||||||
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
|
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
|
||||||
try {
|
try {
|
||||||
desktop.browse(new URI(url));
|
desktop.browse(new URI(url));
|
||||||
} catch (URISyntaxException | IOException e1) {
|
} catch (URISyntaxException | IOException | UnsupportedOperationException e1) {
|
||||||
e1.printStackTrace();
|
WebBrowser.displayPage(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user