More gui added, and profiles half implemented
This commit is contained in:
80
src/net/knarcraft/serverlauncher/profile/Profile.java
Normal file
80
src/net/knarcraft/serverlauncher/profile/Profile.java
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user