Minecraft-Server-Launcher/Server.java

57 lines
1.3 KiB
Java

import java.util.ArrayList;
//Contains all necessary information to create, run and manage a Minecraft server.
public class Server {
private static String[] 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;
private long pid;
public Server(String name) {
this.name = name;
this.path = "";
this.enabled = false;
this.playerList = new ArrayList<String>();
this.type = null;
this.serverVersion = null;
this.maxRam = ramList[0];
this.pid = -1;
}
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;
}
public String getType() {
return this.type.getName() + this.serverVersion;
}
public boolean isEnabled() {
return this.enabled;
}
public String maxRam() {
return this.maxRam;
}
public void updatePid(long pid) {
this.pid = pid;
}
}