Minecraft-Server-Launcher/Server.java

57 lines
1.3 KiB
Java
Raw Normal View History

2018-01-18 23:18:45 +01:00
import java.util.ArrayList;
2018-01-19 21:43:03 +01:00
//Contains all necessary information to create, run and manage a Minecraft server.
2018-01-18 23:18:45 +01:00
public class Server {
2018-01-19 21:43:03 +01:00
private static String[] ramList = {"512M", "1G", "2G", "3G", "4G", "5G", "6G", "7G", "8G", "9G", "10G", "11G", "12G", "13G", "14G", "15G", "16G"};
2018-01-18 23:18:45 +01:00
private String name;
private String path;
private boolean enabled;
private ArrayList<String> playerList;
private ServerType type;
private String serverVersion;
2018-01-19 00:43:33 +01:00
private String maxRam;
2018-01-19 21:43:03 +01:00
private long pid;
2018-01-18 23:18:45 +01:00
public Server(String name) {
this.name = name;
this.path = "";
2018-01-19 21:43:03 +01:00
this.enabled = false;
2018-01-18 23:18:45 +01:00
this.playerList = new ArrayList<String>();
this.type = null;
this.serverVersion = null;
2018-01-19 00:43:33 +01:00
this.maxRam = ramList[0];
2018-01-19 21:43:03 +01:00
this.pid = -1;
2018-01-18 23:18:45 +01:00
}
public void addPlayer(String name) {
this.playerList.add(name);
}
public void removePlayer(String name) {
for (int i = 0; i < playerList.size(); i++) {
if (name.equals(playerList.get(i))) {
playerList.remove(i);
return;
}
}
}
public String getPath() {
return this.path;
}
2018-01-19 00:43:33 +01:00
public String getType() {
2018-01-19 21:43:03 +01:00
return this.type.getName() + this.serverVersion;
2018-01-18 23:18:45 +01:00
}
public boolean isEnabled() {
return this.enabled;
}
2018-01-19 00:43:33 +01:00
public String maxRam() {
return this.maxRam;
}
2018-01-19 21:43:03 +01:00
public void updatePid(long pid) {
this.pid = pid;
}
2018-01-18 23:18:45 +01:00
}