87 lines
2.5 KiB
Java
Raw Normal View History

package net.knarcraft.minecraftserverlauncher.profile;
2018-01-31 17:40:28 +01:00
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;
2018-01-31 17:40:28 +01:00
2018-01-31 23:20:33 +01:00
/**
* Acts as a wrapper for objects necessary for each server.
2018-02-22 14:12:42 +01:00
*
* @author Kristian Knarvik <kristian.knarvik@knett.no>
* @version 1.0.0
* @since 1.0.0
2018-01-31 23:20:33 +01:00
*/
public class Collection {
private final Server server;
private final ServerTab serverTab;
private final Console serverConsole;
2018-01-31 23:20:33 +01:00
private final String name;
2018-01-31 17:40:28 +01:00
/**
* Creates a new collection with the given name
*
* @param name <p>The name identifying the server, server tab, collection and server console</p>
*/
Collection(String name) throws ConfigurationException {
2018-01-31 17:40:28 +01:00
this.serverTab = new ServerTab(name);
this.server = new Server(name);
this.serverConsole = ServerConsoles.addConsoleTab(name);
this.name = name;
2018-01-31 17:40:28 +01:00
}
/**
* Creates a new collection with the given server
*
* @param server <p>The server used for as part of the collection</p>
* @throws ConfigurationException <p>If unable to configure the collection</p>
*/
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;
this.serverTab.setData(server.getPath(), server.isEnabled(), server.getTypeName(), server.getServerVersion(),
server.getMaxRam());
}
/**
* Gets the name of the collection
*
* @return <p>Collection name</p>
*/
2018-01-31 17:40:28 +01:00
public String getName() {
return this.name;
}
/**
* Gets the server of the collection
*
* @return <p>Collection server</p>
*/
2018-01-31 17:40:28 +01:00
public Server getServer() {
return this.server;
}
/**
* Gets the server tab of the collection
*
* @return <p>Collection server tab</p>
*/
2018-01-31 17:40:28 +01:00
public ServerTab getServerTab() {
return this.serverTab;
2018-01-31 17:40:28 +01:00
}
/**
* Gets the server console of the collection
*
* @return <p>Collection server console</p>
*/
2018-01-31 17:40:28 +01:00
public Console getServerConsole() {
return this.serverConsole;
}
}