Add more necessary methods
This commit is contained in:
parent
745ff4350a
commit
d1fca3ca9d
38
Main.java
38
Main.java
@ -1,21 +1,49 @@
|
||||
import java.lang.Runtime;
|
||||
import java.util.ArrayList;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
public class Main {
|
||||
public ArrayList<Server> servers;
|
||||
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/";
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
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", {""}));
|
||||
}
|
||||
|
||||
public static void startServers() {
|
||||
for (Server server : servers) {
|
||||
if (server.isEnabled()) {
|
||||
String path = server.getPath();
|
||||
ServerType = this.type;
|
||||
|
||||
String type = server.getType();
|
||||
String ram = server.maxRam();
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
Process pr = rt.exec("java -Xmx" + $MemoryValue + " -Xms512M -jar " + '"' + $loc + "\\" + $Type + '" nogui');
|
||||
Process pr = rt.exec("java -Xmx" + ram + " -Xms512M -jar " + '"' + path + "\\" + type + '" nogui');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
# Minecraft-Server-Launcher
|
||||
I originally created this software in 2013 using AutoIt. Since I am now learning Java, and I have wanted to rewrite it for a long time, I am trying to recreate it in Java. It is currently missing mostly everything, but it's nothing a lot of work can't fix.
|
||||
I originally created this software in 2013 using AutoIt. Since I am now learning Java, and I have wanted to rewrite it for a long time, I am trying to recreate it in Java. It is currently missing mostly everything, but it's nothing a lot of work can't fix.
|
||||
The original version can be found at: https://knarcraft.net/Downloads/Bungeeminecraftserverlauncher/
|
||||
Its goal is to do everything the original does, just better. The original is 1595 lines of code repetition and dirty code. I had no prior programming experience when I first started working on the original, which is why it became such a mess.
|
15
Server.java
15
Server.java
@ -1,11 +1,13 @@
|
||||
import java.util.ArrayList;
|
||||
public class Server {
|
||||
private static String[17] ramList = {"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G", "11G", "12G", "13G", "14G", "15G", "16G"};
|
||||
private String name;
|
||||
private String path;
|
||||
private boolean enabled;
|
||||
private ArrayList<String> playerList;
|
||||
private ServerType type;
|
||||
private String serverVersion;
|
||||
private String maxRam;
|
||||
|
||||
public Server(String name) {
|
||||
this.name = name;
|
||||
@ -14,6 +16,7 @@ public class Server {
|
||||
this.playerList = new ArrayList<String>();
|
||||
this.type = null;
|
||||
this.serverVersion = null;
|
||||
this.maxRam = ramList[0];
|
||||
}
|
||||
|
||||
public void addPlayer(String name) {
|
||||
@ -33,17 +36,15 @@ public class Server {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public ServerType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
public String getType() {
|
||||
return this.type.getName() + this.version;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
|
||||
public String maxRam() {
|
||||
return this.maxRam;
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
public class ServerType {
|
||||
private String name;
|
||||
private ArrayList<String> versions;
|
||||
private String[] versions;
|
||||
|
||||
public ServerType(String name, ArrayList<String> versions) {
|
||||
public ServerType(String name, String[] versions) {
|
||||
this.name = name;
|
||||
this.versions = versions;
|
||||
}
|
||||
@ -14,8 +14,4 @@ public class ServerType {
|
||||
public ArrayList<String> getVersions() {
|
||||
return this.versions;
|
||||
}
|
||||
|
||||
public boolean validVersion() {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user