Minecraft-Server-Launcher/Main.java

49 lines
1.9 KiB
Java
Raw Normal View History

2018-01-18 23:18:45 +01:00
import java.lang.Runtime;
import java.util.ArrayList;
2018-01-19 00:43:33 +01:00
import java.net.URL;
import java.util.Scanner;
2018-01-18 23:18:45 +01:00
public class Main {
2018-01-19 00:43:33 +01:00
public ArrayList<Server> servers = new ArrayList<Server>();
public ArrayList<ServerType> serverTypes = new ArrayList<ServerType>();
private final BASEURL = "https://knarcraft.net/Api/Download/bungeeminecraftserverlauncher/jars";
private final BUKKITURL = BASEURL + "/Bukkit/";
private final MCPCURL = BASEURL + "/MCPC+/";
private final SPIGOT = BASEURL + "/Spigot/";
2018-01-18 23:18:45 +01:00
public static void main(String[] args) {
2018-01-19 00:43:33 +01:00
addServerTypes();
}
public static void addServerTypes() {
serverTypes.add(new ServerType("Vanilla", {"Latest", "1.12", "1.11.2", "1.10.2", "1.9.4", "1.8.9", "1.7.10", "1.6.4", "1.5.2", "1.4.7", "1.3.2", "1.2.5"}));
serverTypes.add(new ServerType("Snapshot", {"Latest"}));
serverTypes.add(new ServerType("SpongeVanilla", {"1.11.2", "1.10.2", "1.8.9"}));
serverTypes.add(new ServerType("Spigot", {"1.12", "1.11.2", "1.10.2", "1.9.4", "1.9", "1.8.8", "1.7.10", "1.6.4", "1.5.2", "1.4.7"}));
serverTypes.add(new ServerType("MCPCplus", {"1.6.4", "1.6.2", "1.5.2", "1.4.7"}));
serverTypes.add(new ServerType("Craftbukkit", {"1.12", "1.11.2", "1.10.2", "1.9.4", "1.8.8", "1.7.10", "1.6.4", "1.5.2", "1.4.6", "1.3.2", "1.2.5", "1.1", "1.0"}));
serverTypes.add(new ServerType("Custom", {""}));
2018-01-18 23:18:45 +01:00
}
public static void startServers() {
for (Server server : servers) {
if (server.isEnabled()) {
String path = server.getPath();
2018-01-19 00:43:33 +01:00
String type = server.getType();
String ram = server.maxRam();
2018-01-18 23:18:45 +01:00
Runtime rt = Runtime.getRuntime();
2018-01-19 00:43:33 +01:00
Process pr = rt.exec("java -Xmx" + ram + " -Xms512M -jar " + '"' + path + "\\" + type + '" nogui');
2018-01-18 23:18:45 +01:00
}
}
}
2018-01-19 00:43:33 +01:00
public static void readFile(String path) {
try {
URL url = new URL(path);
Scanner s = new Scanner(url.openStream());
System.out.println(s.next());
} catch (java.io.IOException e) {
System.out.println(e);
}
}
2018-01-18 23:18:45 +01:00
}