|
|
|
@ -1,10 +1,12 @@
|
|
|
|
|
package net.knarcraft.serverlauncher.userinterface;
|
|
|
|
|
|
|
|
|
|
import net.knarcraft.serverlauncher.profile.Collection;
|
|
|
|
|
import net.knarcraft.serverlauncher.server.Server;
|
|
|
|
|
import net.knarcraft.serverlauncher.profile.Profile;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
|
|
|
import java.awt.event.WindowAdapter;
|
|
|
|
@ -107,7 +109,7 @@ public class GUI implements ActionListener {
|
|
|
|
|
for (int i = 0; i < this.serverTabs.size(); i++) {
|
|
|
|
|
if(this.serverTabs.get(i) == tab) {
|
|
|
|
|
serversPane.remove(i);
|
|
|
|
|
currentProfile().removeServer(i);
|
|
|
|
|
currentProfile().removeCollection(i);
|
|
|
|
|
this.serverTabs.remove(i);
|
|
|
|
|
i = serverTabs.size();
|
|
|
|
|
}
|
|
|
|
@ -119,14 +121,13 @@ public class GUI implements ActionListener {
|
|
|
|
|
* Initialize the contents of the frame.
|
|
|
|
|
*/
|
|
|
|
|
private void initialize() {
|
|
|
|
|
try {
|
|
|
|
|
/*try {
|
|
|
|
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
|
|
|
} catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
frame = new JFrame("Minecraft server launcher");
|
|
|
|
|
frame.setBounds(100, 100, 470, 219);
|
|
|
|
|
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
|
|
|
|
frame.setResizable(false);
|
|
|
|
|
ImageIcon img;
|
|
|
|
@ -204,7 +205,6 @@ public class GUI implements ActionListener {
|
|
|
|
|
|
|
|
|
|
mntmStory = new JMenuItem("Story");
|
|
|
|
|
mnAbout.add(mntmStory);
|
|
|
|
|
frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.X_AXIS));
|
|
|
|
|
mntmStory.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
|
|
@ -221,8 +221,7 @@ public class GUI implements ActionListener {
|
|
|
|
|
|
|
|
|
|
btnStartServer = new JButton("Start servers");
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.WEST, lblBasicControls, 0, SpringLayout.WEST, btnStartServer);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.SOUTH, lblBasicControls, -6, SpringLayout.NORTH, btnStartServer);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.NORTH, btnStartServer, 30, SpringLayout.NORTH, panelBasic);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.NORTH, btnStartServer, 6, SpringLayout.SOUTH, lblBasicControls);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.WEST, btnStartServer, 10, SpringLayout.WEST, panelBasic);
|
|
|
|
|
panelBasic.add(btnStartServer);
|
|
|
|
|
btnStartServer.addActionListener(this);
|
|
|
|
@ -251,15 +250,16 @@ public class GUI implements ActionListener {
|
|
|
|
|
delProfile.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
profiles = new JComboBox<>();
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.NORTH, profiles, 1, SpringLayout.NORTH, addProfile);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.NORTH, profiles, 0, SpringLayout.NORTH, addProfile);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.WEST, profiles, 6, SpringLayout.EAST, delProfile);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.EAST, profiles, 124, SpringLayout.EAST, delProfile);
|
|
|
|
|
panelBasic.add(profiles);
|
|
|
|
|
profiles.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 8, SpringLayout.SOUTH, addProfile);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.NORTH, lblStatuslabel, 6, SpringLayout.SOUTH, addProfile);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.SOUTH, lblStatuslabel, -10, SpringLayout.SOUTH, panelBasic);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.WEST, lblStatuslabel, 10, SpringLayout.WEST, panelBasic);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, 386, SpringLayout.WEST, panelBasic);
|
|
|
|
|
sl_panel.putConstraint(SpringLayout.EAST, lblStatuslabel, -10, SpringLayout.EAST, panelBasic);
|
|
|
|
|
panelBasic.add(lblStatuslabel);
|
|
|
|
|
|
|
|
|
|
addServer = new JButton("Add server");
|
|
|
|
@ -291,15 +291,15 @@ public class GUI implements ActionListener {
|
|
|
|
|
btnKick = new JButton("Kick");
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.NORTH, btnKick, 10, SpringLayout.NORTH, controlServers);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.WEST, btnKick, 6, SpringLayout.EAST, targetServer);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnKick, 124, SpringLayout.WEST, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnKick, 104, SpringLayout.WEST, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetServer, 0, SpringLayout.SOUTH, btnKick);
|
|
|
|
|
controlServers.add(btnKick);
|
|
|
|
|
btnKick.addActionListener(this);
|
|
|
|
|
|
|
|
|
|
btnBan = new JButton("Ban");
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.NORTH, btnBan, 5, SpringLayout.SOUTH, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.NORTH, btnBan, 6, SpringLayout.SOUTH, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.WEST, btnBan, 6, SpringLayout.EAST, targetPlayer);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnBan, 124, SpringLayout.WEST, btnBan);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnBan, 104, SpringLayout.WEST, btnBan);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.SOUTH, targetPlayer, 0, SpringLayout.SOUTH, btnBan);
|
|
|
|
|
controlServers.add(btnBan);
|
|
|
|
|
btnBan.addActionListener(this);
|
|
|
|
@ -307,7 +307,6 @@ public class GUI implements ActionListener {
|
|
|
|
|
btnOp = new JButton("OP");
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.NORTH, btnOp, 10, SpringLayout.NORTH, controlServers);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.WEST, btnOp, 6, SpringLayout.EAST, btnKick);
|
|
|
|
|
//sl_panel_1.putConstraint(SpringLayout.SOUTH, btnOp, 32, SpringLayout.NORTH, controlServers);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnOp, -10, SpringLayout.EAST, controlServers);
|
|
|
|
|
controlServers.add(btnOp);
|
|
|
|
|
btnOp.addActionListener(this);
|
|
|
|
@ -353,7 +352,8 @@ public class GUI implements ActionListener {
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.NORTH, customCommand, 6, SpringLayout.SOUTH, btnSaveserver);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.NORTH, btnSaveserver, 6, SpringLayout.SOUTH, btnBan);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.WEST, btnSaveserver, 0, SpringLayout.WEST, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 120, SpringLayout.WEST, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 104, SpringLayout.WEST, btnKick);
|
|
|
|
|
sl_panel_1.putConstraint(SpringLayout.EAST, btnSaveserver, 104, SpringLayout.WEST, btnKick);
|
|
|
|
|
controlServers.add(btnSaveserver);
|
|
|
|
|
btnSaveserver.addActionListener(this);
|
|
|
|
|
|
|
|
|
@ -386,13 +386,14 @@ public class GUI implements ActionListener {
|
|
|
|
|
this.serversPane = tabbedPane_1;
|
|
|
|
|
tabbedPane_1.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
|
|
|
|
|
|
|
|
|
|
frame.setPreferredSize(frame.getPreferredSize());
|
|
|
|
|
frame.getContentPane().setPreferredSize(new Dimension(440, 170));
|
|
|
|
|
frame.validate();
|
|
|
|
|
frame.pack();
|
|
|
|
|
frame.setVisible(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addServer(String name) {
|
|
|
|
|
serverTabs.add(new ServerTab(name));
|
|
|
|
|
public void addServer(ServerTab serverTab) {
|
|
|
|
|
serverTabs.add(serverTab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -421,11 +422,11 @@ public class GUI implements ActionListener {
|
|
|
|
|
} else if (e.getSource() == mntmRunInBackground) {
|
|
|
|
|
JOptionPane.showMessageDialog(null, runInBackgroundText, "Run in background", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
} else if (e.getSource() == mntmDelayStartup) {
|
|
|
|
|
JOptionPane.showMessageDialog(null, delayStartupText, "Run in background", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
JOptionPane.showMessageDialog(null, delayStartupText, "Delay startup", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
} else if (e.getSource() == mntmDownloadJars) {
|
|
|
|
|
JOptionPane.showMessageDialog(null, downloadJarsText, "Run in background", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
JOptionPane.showMessageDialog(null, downloadJarsText, "Download jars", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
} else if (e.getSource() == mntmAbout) {
|
|
|
|
|
JOptionPane.showMessageDialog(null, aboutText, "Run in background", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
JOptionPane.showMessageDialog(null, aboutText, "About", JOptionPane.INFORMATION_MESSAGE);
|
|
|
|
|
} else if (e.getSource() == mntmStory) {
|
|
|
|
|
goToURL("https://knarcraft.net/Bungeeminecraftserverlauncher/Story/");
|
|
|
|
|
} else if (e.getSource() == btnStartServer) {
|
|
|
|
@ -435,11 +436,7 @@ public class GUI implements ActionListener {
|
|
|
|
|
stop();
|
|
|
|
|
} else if (e.getSource() == addServer) {
|
|
|
|
|
String serverName = JOptionPane.showInputDialog("Name of server: ");
|
|
|
|
|
if (!serverName.equals("") && !currentProfile().serverExists(serverName)) {
|
|
|
|
|
new Server(serverName, this);
|
|
|
|
|
} else {
|
|
|
|
|
JOptionPane.showMessageDialog(null, "A server name must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
this.currentProfile().addCollection(serverName);
|
|
|
|
|
} else if (e.getSource() == backup) {
|
|
|
|
|
backup();
|
|
|
|
|
} else if (e.getSource() == addProfile) {
|
|
|
|
@ -479,6 +476,7 @@ public class GUI implements ActionListener {
|
|
|
|
|
}
|
|
|
|
|
} else if (e.getSource() == btnServerConsoles) {
|
|
|
|
|
//TODO: Make server consoles window, and toggle visibility on this action.
|
|
|
|
|
ServerConsoles.getGUI().show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -486,7 +484,7 @@ public class GUI implements ActionListener {
|
|
|
|
|
* Reads all combo boxes, updates variables and saves to disk
|
|
|
|
|
*/
|
|
|
|
|
private void save() {
|
|
|
|
|
currentProfile().save(serverTabs);
|
|
|
|
|
currentProfile().save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -562,10 +560,10 @@ public class GUI implements ActionListener {
|
|
|
|
|
|
|
|
|
|
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
|
|
|
|
File path = chooser.getSelectedFile();
|
|
|
|
|
for (Server server : currentProfile().getServers()) {
|
|
|
|
|
if (!server.getPath().equals("") && server.isEnabled()) {
|
|
|
|
|
String name = server.getName();
|
|
|
|
|
File srcFolder = new File(server.getPath());
|
|
|
|
|
for (Collection collection : currentProfile().getCollections()) {
|
|
|
|
|
if (!collection.getServer().getPath().equals("") && collection.getServer().isEnabled()) {
|
|
|
|
|
String name = collection.getServer().getName();
|
|
|
|
|
File srcFolder = new File(collection.getServer().getPath());
|
|
|
|
|
File destFolder = new File(path, name);
|
|
|
|
|
if (!destFolder.exists()) {
|
|
|
|
|
if (destFolder.mkdirs()) {
|
|
|
|
|