package net.knarcraft.minecraftserverlauncher.profile; import net.knarcraft.minecraftserverlauncher.server.Server; import net.knarcraft.minecraftserverlauncher.userinterface.Console; import net.knarcraft.minecraftserverlauncher.userinterface.ServerConsoles; import net.knarcraft.minecraftserverlauncher.userinterface.ServerTab; import javax.naming.ConfigurationException; import java.io.Serializable; /** * Acts as a wrapper for objects necessary for each server. * * @author Kristian Knarvik * @version 1.0.0 * @since 1.0.0 */ public class Collection implements Serializable { private final Server server; private final transient ServerTab serverTab; private final Console serverConsole; private final String name; /** * Creates a new collection with the given name * * @param name

The name identifying the server, server tab, collection and server console

*/ Collection(String name) throws ConfigurationException { this.serverTab = new ServerTab(name); this.server = new Server(name); this.serverConsole = ServerConsoles.addConsoleTab(name); this.name = name; } /** * Creates a new collection with the given server * * @param server

The server used for as part of the collection

* @throws ConfigurationException

If unable to configure the collection

*/ Collection(Server server) throws ConfigurationException { String serverName = server.getName(); this.serverTab = new ServerTab(serverName); this.server = server; this.serverConsole = ServerConsoles.addConsoleTab(serverName); this.name = serverName; } /** * Creates a new collection with the given parameters * * @param name

The name identifying the server, server tab, collection and server console

* @param serverPath

The path of the server folder

* @param enabled

Whether the server should be run when starting servers

* @param typeName

The name of the server type the server uses

* @param serverVersion

The version of the running server type.

* @param maxRam

The maximum amount of RAM the server is allowed to use.

*/ Collection(String name, String serverPath, boolean enabled, String typeName, String serverVersion, String maxRam) throws ConfigurationException { this.serverTab = new ServerTab(name); this.server = new Server(name, serverPath, enabled, typeName, serverVersion, maxRam); this.serverConsole = ServerConsoles.addConsoleTab(name); this.name = name; this.serverTab.setData(serverPath, enabled, typeName, serverVersion, maxRam); } /** * Gets the name of the collection * * @return

Collection name

*/ public String getName() { return this.name; } /** * Gets the server of the collection * * @return

Collection server

*/ public Server getServer() { return this.server; } /** * Gets the server tab of the collection * * @return

Collection server tab

*/ public ServerTab getServerTab() { return this.serverTab; } /** * Gets the server console of the collection * * @return

Collection server console

*/ public Console getServerConsole() { return this.serverConsole; } }