More gui added, and profiles half implemented

This commit is contained in:
2018-01-28 19:06:50 +01:00
parent bcaf8640d4
commit b0979c6e0f
5 changed files with 249 additions and 39 deletions

View File

@ -0,0 +1,80 @@
package net.knarcraft.serverlauncher.profile;
import net.knarcraft.serverlauncher.server.Server;
import net.knarcraft.serverlauncher.userinterface.GUI;
import java.util.ArrayList;
public class Profile {
private static final GUI gui = Server.getGUI();
private static final ArrayList<Profile> profiles = new ArrayList<>();
private final ArrayList<Server> servers;
private final String name;
private boolean runInBackground;
private int delayStartup;
private boolean downloadJars;
private Profile(String name) {
this.servers = new ArrayList<>();
this.name = name;
this.runInBackground = false;
this.delayStartup = 0;
this.downloadJars = false;
profiles.add(this);
}
public void addServer(Server server) {
this.servers.add(server);
}
public ArrayList<Server> getServers() {
return this.servers;
}
public static void addProfile(String name) {
if (name.equals("")) {
return;
}
for (Profile profile : profiles) {
if (profile.name.equals(name)) {
return;
}
}
new Profile(name);
gui.addProfile(name);
}
public static Profile getProfile(String name) {
for (Profile profile : profiles) {
if (profile.name.equals(name)) {
return profile;
}
}
return null;
}
public static void deleteProfile(String name) {
if (profiles.size() > 1) {
for (int i = 0; i < profiles.size(); i++) {
if (profiles.get(i).name.equals((name))) {
profiles.remove(i);
gui.removeProfile(i);
}
}
}
}
public void setRunInBackground(boolean value) {
this.runInBackground = value;
}
public void setDelayStartup(int value) {
if (value >= 0) {
this.delayStartup = value;
}
}
public void setDownloadJars(boolean value) {
this.downloadJars = value;
}
}