Add unfinished gui
This commit is contained in:
parent
0752f0808b
commit
fec74bb295
@ -11,14 +11,15 @@ import javax.naming.ConfigurationException;
|
||||
* @version 0.0.0.1
|
||||
* @since 0.0.0.1
|
||||
*/
|
||||
public class Main {
|
||||
@SuppressWarnings("SpellCheckingInspection")
|
||||
class Main {
|
||||
public static void main(String[] args) {
|
||||
setup();
|
||||
GUI gui = new GUI();
|
||||
new GUI();
|
||||
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
private static void setup() {
|
||||
try {
|
||||
ServerType.loadServerTypes();
|
||||
} catch (ConfigurationException e) {
|
||||
|
@ -7,11 +7,11 @@ package net.knarcraft.serverlauncher.server;
|
||||
* @version 0.0.0.1
|
||||
* @since 0.0.0.1
|
||||
*/
|
||||
public class AdvancedServerType extends ServerType {
|
||||
private String versionURL;
|
||||
private String downloadURLPart;
|
||||
private String srcStart;
|
||||
private String srcEnd;
|
||||
class AdvancedServerType extends ServerType {
|
||||
private final String versionURL;
|
||||
private final String downloadURLPart;
|
||||
private final String srcStart;
|
||||
private final String srcEnd;
|
||||
|
||||
public AdvancedServerType(String name, String[] versions, String versionURL, String srcStart, String srcEnd, String downloadURL, String downloadURLPart) {
|
||||
super(name, versions, downloadURL);
|
||||
|
@ -3,7 +3,6 @@ package net.knarcraft.serverlauncher.server;
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.nio.file.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -18,12 +17,12 @@ import java.util.ArrayList;
|
||||
public class Server {
|
||||
/** Available ram sizes. For GUI dropdown */
|
||||
private static final String[] ramList = {"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G", "11G", "12G", "13G", "14G", "15G", "16G"};
|
||||
private static ArrayList<Server> servers = new ArrayList<>();
|
||||
private static final ArrayList<Server> servers = new ArrayList<>();
|
||||
|
||||
private String name;
|
||||
private String path;
|
||||
private boolean enabled;
|
||||
private ArrayList<String> playerList;
|
||||
private final ArrayList<String> playerList;
|
||||
private ServerType type;
|
||||
private String serverVersion;
|
||||
private String maxRam;
|
||||
@ -129,8 +128,7 @@ public class Server {
|
||||
ProcessBuilder builder = new ProcessBuilder("java", "-Xmx" + this.maxRam, "-Xms512M", "-Djline.terminal=jline.UnsupportedTerminal", "-Dcom.mojang.eula.agree=true", "-jar", "\"" + this.path + "\\" + this.getType() + "\"");
|
||||
builder.directory(new File(this.path));
|
||||
builder.redirectErrorStream(true);
|
||||
Process pr = builder.start();
|
||||
this.process = pr;
|
||||
this.process = builder.start();
|
||||
System.out.println("Success");
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error");
|
||||
@ -228,7 +226,7 @@ public class Server {
|
||||
* This is used to find the newest version of the software.
|
||||
*
|
||||
* @param path The full url of the file to read.
|
||||
* @return True if successfull. False otherwise.
|
||||
* @return True if successful. False otherwise.
|
||||
*/
|
||||
private static String readFile(String path) throws IOException {
|
||||
URL url = new URL(path);
|
||||
|
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* Contains the bare minimum to be a functional servertype.
|
||||
* Contains the bare minimum to be a functional server type.
|
||||
*
|
||||
* @author Kristian Knarvik <kristian.knarvik@knett.no>
|
||||
* @version 0.0.0.1
|
||||
@ -17,9 +17,9 @@ public class ServerType {
|
||||
private final String name;
|
||||
private final String[] versions;
|
||||
private final String downloadURL;
|
||||
private static ArrayList<ServerType> serverTypes = new ArrayList<>();
|
||||
private static final ArrayList<ServerType> serverTypes = new ArrayList<>();
|
||||
|
||||
public ServerType(String name, String[] versions, String downloadURL) {
|
||||
ServerType(String name, String[] versions, String downloadURL) {
|
||||
this.name = name;
|
||||
this.versions = versions;
|
||||
this.downloadURL = downloadURL;
|
||||
@ -59,11 +59,14 @@ public class ServerType {
|
||||
} else {
|
||||
ver = new String[]{str[1]};
|
||||
}
|
||||
if (len == 7) {
|
||||
switch (len) {
|
||||
case 7:
|
||||
new AdvancedServerType(str[0], ver, str[2], str[3], str[4], str[5], str[6]);
|
||||
} else if (len == 3) {
|
||||
break;
|
||||
case 3:
|
||||
new ServerType(str[0], ver, str[2]);
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
throw new ConfigurationException("Error: Configuration file invalid.");
|
||||
}
|
||||
}
|
||||
|
@ -84,13 +84,4 @@ public class GUI {
|
||||
Insets insets = frame.getInsets();
|
||||
frame.setSize(450 + 2 * insets.left, 170 + insets.top + insets.bottom);
|
||||
}
|
||||
|
||||
protected JComponent makeTextPanel(String text) {
|
||||
JPanel panel = new JPanel(false);
|
||||
JLabel filler = new JLabel(text);
|
||||
filler.setHorizontalAlignment(JLabel.CENTER);
|
||||
panel.setLayout(new GridLayout(1, 1));
|
||||
panel.add(filler);
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.io.*;
|
||||
* @version 0.0.0.1
|
||||
* @since 0.0.0.1
|
||||
*/
|
||||
public class ServerTest {
|
||||
class ServerTest {
|
||||
public static void main(String[] args) throws IOException {
|
||||
try {
|
||||
ServerType.loadServerTypes();
|
||||
|
Loading…
Reference in New Issue
Block a user