Added the title and icon again
This commit is contained in:
parent
559e7bb38a
commit
89f0962c2d
@ -1,7 +1,9 @@
|
|||||||
package net.knarcraft.serverlauncher.profile;
|
package net.knarcraft.serverlauncher.profile;
|
||||||
|
|
||||||
import net.knarcraft.serverlauncher.server.Server;
|
import net.knarcraft.serverlauncher.server.Server;
|
||||||
|
import net.knarcraft.serverlauncher.server.ServerType;
|
||||||
import net.knarcraft.serverlauncher.userinterface.GUI;
|
import net.knarcraft.serverlauncher.userinterface.GUI;
|
||||||
|
import net.knarcraft.serverlauncher.userinterface.ServerTab;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -173,4 +175,16 @@ public class Profile {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(ArrayList<ServerTab> serverTabs) {
|
||||||
|
for (int i = 0; i < this.servers.size(); i++) {
|
||||||
|
Server server = servers.get(i);
|
||||||
|
ServerTab serverTab = serverTabs.get(i);
|
||||||
|
server.setPath(serverTab.getPath());
|
||||||
|
server.setMaxRam(serverTab.getMaxRam());
|
||||||
|
server.setType(ServerType.getByName(serverTab.getType()));
|
||||||
|
server.setServerVersion(serverTab.getVersion());
|
||||||
|
server.toggle(serverTab.enabled());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,9 @@ public class Server {
|
|||||||
public void toggle() {
|
public void toggle() {
|
||||||
this.enabled = !this.enabled;
|
this.enabled = !this.enabled;
|
||||||
}
|
}
|
||||||
|
public void toggle(boolean value) {
|
||||||
|
this.enabled = value;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPath(String path) {
|
public void setPath(String path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
@ -140,7 +143,7 @@ public class Server {
|
|||||||
* Runs all enabled servers with their settings.
|
* Runs all enabled servers with their settings.
|
||||||
*/
|
*/
|
||||||
public static void startServers() {
|
public static void startServers() {
|
||||||
System.out.println("Starting servers.");
|
GUI.getGUI().setStatus("Starting servers");
|
||||||
for (Server server : GUI.getGUI().currentProfile().getServers()) {
|
for (Server server : GUI.getGUI().currentProfile().getServers()) {
|
||||||
if (!server.run()) {
|
if (!server.run()) {
|
||||||
GUI.getGUI().setStatus("An error occurred. Start aborted");
|
GUI.getGUI().setStatus("An error occurred. Start aborted");
|
||||||
@ -169,7 +172,8 @@ public class Server {
|
|||||||
"-Djline.terminal=jline.UnsupportedTerminal",
|
"-Djline.terminal=jline.UnsupportedTerminal",
|
||||||
"-Dcom.mojang.eula.agree=true",
|
"-Dcom.mojang.eula.agree=true",
|
||||||
"-jar",
|
"-jar",
|
||||||
"\"" + this.path + "\\" + this.getType() + "\""
|
"\"" + this.path + "\\" + this.getType() + "\"",
|
||||||
|
"nogui"
|
||||||
);
|
);
|
||||||
builder.directory(new File(this.path));
|
builder.directory(new File(this.path));
|
||||||
builder.redirectErrorStream(true);
|
builder.redirectErrorStream(true);
|
||||||
|
@ -51,6 +51,15 @@ public class ServerType {
|
|||||||
return serverTypes;
|
return serverTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ServerType getByName(String name) {
|
||||||
|
for (ServerType serverType : serverTypes) {
|
||||||
|
if (serverType.getName().equals(name)) {
|
||||||
|
return serverType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads valid server types and version from a file, and creates their objects.
|
* Reads valid server types and version from a file, and creates their objects.
|
||||||
*
|
*
|
||||||
|
@ -3,6 +3,7 @@ package net.knarcraft.serverlauncher.userinterface;
|
|||||||
import net.knarcraft.serverlauncher.server.Server;
|
import net.knarcraft.serverlauncher.server.Server;
|
||||||
import net.knarcraft.serverlauncher.profile.Profile;
|
import net.knarcraft.serverlauncher.profile.Profile;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@ -94,10 +95,6 @@ public class GUI implements ActionListener {
|
|||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ServerTab> getServerTabs() {
|
|
||||||
return this.serverTabs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a server's tab, removes it from the list of tabs, and removes the server from Profile.java
|
* Removes a server's tab, removes it from the list of tabs, and removes the server from Profile.java
|
||||||
*
|
*
|
||||||
@ -125,10 +122,17 @@ public class GUI implements ActionListener {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
frame = new JFrame();
|
frame = new JFrame("Minecraft server launcher");
|
||||||
frame.setBounds(100, 100, 398, 219);
|
frame.setBounds(100, 100, 398, 219);
|
||||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
frame.setResizable(false);
|
frame.setResizable(false);
|
||||||
|
ImageIcon img;
|
||||||
|
try {
|
||||||
|
img = new ImageIcon(ImageIO.read(GUI.class.getResourceAsStream("/files/GUIIcon.png")));
|
||||||
|
} catch (IOException | IllegalArgumentException e) {
|
||||||
|
img = new ImageIcon("files/GUIIcon.png");
|
||||||
|
}
|
||||||
|
frame.setIconImage(img.getImage());
|
||||||
|
|
||||||
frame.addWindowListener(new WindowAdapter() {
|
frame.addWindowListener(new WindowAdapter() {
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
@ -394,7 +398,6 @@ public class GUI implements ActionListener {
|
|||||||
if (selectedPlayer != null) {
|
if (selectedPlayer != null) {
|
||||||
selectedPlayerValue = selectedPlayer.toString();
|
selectedPlayerValue = selectedPlayer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.getSource() == chckbxmntmRunInBackground) {
|
if (e.getSource() == chckbxmntmRunInBackground) {
|
||||||
background();
|
background();
|
||||||
} else if (e.getSource() == chckbxmntmDelayStartup) {
|
} else if (e.getSource() == chckbxmntmDelayStartup) {
|
||||||
@ -418,7 +421,7 @@ public class GUI implements ActionListener {
|
|||||||
} else if (e.getSource() == mntmStory) {
|
} else if (e.getSource() == mntmStory) {
|
||||||
goToURL("https://knarcraft.net/Bungeeminecraftserverlauncher/Story/");
|
goToURL("https://knarcraft.net/Bungeeminecraftserverlauncher/Story/");
|
||||||
} else if (e.getSource() == btnStartServer) {
|
} else if (e.getSource() == btnStartServer) {
|
||||||
save();
|
this.save();
|
||||||
Server.startServers();
|
Server.startServers();
|
||||||
} else if (e.getSource() == btnStopServer) {
|
} else if (e.getSource() == btnStopServer) {
|
||||||
stop();
|
stop();
|
||||||
@ -427,7 +430,7 @@ public class GUI implements ActionListener {
|
|||||||
if (!serverName.equals("") && !currentProfile().serverExists(serverName)) {
|
if (!serverName.equals("") && !currentProfile().serverExists(serverName)) {
|
||||||
new Server(serverName, this);
|
new Server(serverName, this);
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "A servername must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "A server name must my unique and not empty.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
} else if (e.getSource() == backup) {
|
} else if (e.getSource() == backup) {
|
||||||
backup();
|
backup();
|
||||||
@ -475,8 +478,7 @@ public class GUI implements ActionListener {
|
|||||||
* Reads all combo boxes, updates variables and saves to disk
|
* Reads all combo boxes, updates variables and saves to disk
|
||||||
*/
|
*/
|
||||||
private void save() {
|
private void save() {
|
||||||
//TODO: Finish save
|
currentProfile().save(serverTabs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,7 @@ import javax.swing.*;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
class ServerTab implements ActionListener {
|
public class ServerTab implements ActionListener {
|
||||||
private final JComboBox<String> serverTypes;
|
private final JComboBox<String> serverTypes;
|
||||||
private final JComboBox<String> serverVersions;
|
private final JComboBox<String> serverVersions;
|
||||||
private final JComboBox<String> maxRam;
|
private final JComboBox<String> maxRam;
|
||||||
@ -16,8 +16,6 @@ class ServerTab implements ActionListener {
|
|||||||
private final JButton btnBrowse;
|
private final JButton btnBrowse;
|
||||||
private final JTextField directory;
|
private final JTextField directory;
|
||||||
|
|
||||||
//TODO: Add custom input field + update combo boxes on version change.
|
|
||||||
|
|
||||||
public ServerTab(String name) {
|
public ServerTab(String name) {
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
GUI.getGUI().getPane().addTab(name, null, panel, null);
|
GUI.getGUI().getPane().addTab(name, null, panel, null);
|
||||||
@ -101,6 +99,41 @@ class ServerTab implements ActionListener {
|
|||||||
btnBrowse.addActionListener(this);
|
btnBrowse.addActionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return this.directory.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMaxRam() {
|
||||||
|
Object selected = this.maxRam.getSelectedItem();
|
||||||
|
if (selected != null) {
|
||||||
|
return selected.toString();
|
||||||
|
} else {
|
||||||
|
return "512M";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
Object selected = this.serverTypes.getSelectedItem();
|
||||||
|
if (selected != null) {
|
||||||
|
return selected.toString();
|
||||||
|
} else {
|
||||||
|
return "Vanilla";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
Object selected = this.serverVersions.getSelectedItem();
|
||||||
|
if (selected != null) {
|
||||||
|
return selected.toString();
|
||||||
|
} else {
|
||||||
|
return "Vanilla";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean enabled() {
|
||||||
|
return this.chckbxEnabled.isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (e.getSource() == btnRemoveServer) {
|
if (e.getSource() == btnRemoveServer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user