2016-12-24 05:55:17 +01:00
|
|
|
package net.ME1312.SubServers.Bungee.Host;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2019-04-18 16:02:09 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
|
|
|
import net.ME1312.Galaxi.Library.Util;
|
|
|
|
import net.ME1312.Galaxi.Library.Version.Version;
|
2020-11-16 21:34:59 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidTemplateException;
|
2017-07-23 06:32:57 +02:00
|
|
|
import net.ME1312.SubServers.Bungee.SubAPI;
|
2018-04-15 03:53:51 +02:00
|
|
|
|
2020-11-16 21:34:59 +01:00
|
|
|
import com.google.common.collect.Range;
|
|
|
|
|
2017-05-29 07:00:02 +02:00
|
|
|
import java.io.File;
|
2018-10-08 23:07:44 +02:00
|
|
|
import java.net.InetSocketAddress;
|
2017-11-22 22:58:33 +01:00
|
|
|
import java.util.*;
|
2021-10-24 06:14:07 +02:00
|
|
|
import java.util.function.Consumer;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SubCreator Layout Class
|
|
|
|
*/
|
|
|
|
public abstract class SubCreator {
|
2017-05-29 07:00:02 +02:00
|
|
|
public static class ServerTemplate {
|
2021-06-06 04:44:33 +02:00
|
|
|
private final boolean dynamic;
|
2017-05-29 07:00:02 +02:00
|
|
|
private String name;
|
|
|
|
private String nick = null;
|
|
|
|
private boolean enabled;
|
2021-06-25 05:06:53 +02:00
|
|
|
private boolean internal;
|
2017-05-29 07:00:02 +02:00
|
|
|
private String icon;
|
|
|
|
private File directory;
|
|
|
|
private ServerType type;
|
2019-04-18 16:02:09 +02:00
|
|
|
private ObjectMap<String> build;
|
|
|
|
private ObjectMap<String> options;
|
2017-05-29 07:00:02 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a SubCreator Template
|
|
|
|
*
|
|
|
|
* @param name Template Name
|
2021-06-06 04:44:33 +02:00
|
|
|
* @param enabled Template Enabled Status
|
|
|
|
* @param icon Template Item Icon Name
|
2017-05-29 07:00:02 +02:00
|
|
|
* @param directory Template Directory
|
|
|
|
* @param build Build Options
|
|
|
|
* @param options Configuration Options
|
|
|
|
*/
|
2019-04-18 16:02:09 +02:00
|
|
|
public ServerTemplate(String name, boolean enabled, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options) {
|
2021-06-25 05:06:53 +02:00
|
|
|
this(name, enabled, false, icon, directory, build, options, true);
|
2021-06-06 04:44:33 +02:00
|
|
|
}
|
|
|
|
|
2021-06-25 05:06:53 +02:00
|
|
|
private ServerTemplate(String name, boolean enabled, boolean internal, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options, boolean dynamic) {
|
2021-10-24 06:14:07 +02:00
|
|
|
Util.nullpo(name, enabled, directory, build, options);
|
2017-05-30 21:38:51 +02:00
|
|
|
if (name.contains(" ")) throw new InvalidTemplateException("Template names cannot have spaces: " + name);
|
2017-05-29 07:00:02 +02:00
|
|
|
this.name = name;
|
|
|
|
this.enabled = enabled;
|
2021-06-25 05:06:53 +02:00
|
|
|
this.internal = internal;
|
2017-05-29 07:00:02 +02:00
|
|
|
this.icon = icon;
|
|
|
|
this.directory = directory;
|
2021-10-24 20:53:15 +02:00
|
|
|
this.type = (build.contains("Server-Type"))?ServerType.valueOf(build.getString("Server-Type").toUpperCase()):ServerType.CUSTOM;
|
2017-05-29 07:00:02 +02:00
|
|
|
this.build = build;
|
|
|
|
this.options = options;
|
2021-06-06 04:44:33 +02:00
|
|
|
this.dynamic = dynamic;
|
2017-05-29 07:00:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Name of this Template
|
|
|
|
*
|
|
|
|
* @return Template Name
|
|
|
|
*/
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Display Name of this Template
|
|
|
|
*
|
|
|
|
* @return Display Name
|
|
|
|
*/
|
|
|
|
public String getDisplayName() {
|
|
|
|
return (nick == null)?getName():nick;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the Display Name for this Template
|
|
|
|
*
|
|
|
|
* @param value Value (or null to reset)
|
|
|
|
*/
|
|
|
|
public void setDisplayName(String value) {
|
|
|
|
if (value == null || value.length() == 0 || getName().equals(value)) {
|
|
|
|
this.nick = null;
|
|
|
|
} else {
|
|
|
|
this.nick = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Enabled Status of this Template
|
|
|
|
*
|
|
|
|
* @return Enabled Status
|
|
|
|
*/
|
|
|
|
public boolean isEnabled() {
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Enabled Status of this Template
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
public void setEnabled(boolean value) {
|
|
|
|
enabled = value;
|
|
|
|
}
|
|
|
|
|
2021-06-25 05:06:53 +02:00
|
|
|
/**
|
|
|
|
* Get if this Template is for Internal use only
|
|
|
|
*
|
|
|
|
* @return Internal Status
|
|
|
|
*/
|
|
|
|
public boolean isInternal() {
|
|
|
|
return internal;
|
|
|
|
}
|
|
|
|
|
2017-05-29 07:00:02 +02:00
|
|
|
/**
|
|
|
|
* Get the Item Icon for this Template
|
|
|
|
*
|
|
|
|
* @return Item Icon Name/ID
|
|
|
|
*/
|
|
|
|
public String getIcon() {
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the Item Icon for this Template
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
public void setIcon(String value) {
|
|
|
|
icon = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Directory for this Template
|
|
|
|
*
|
|
|
|
* @return Directory
|
|
|
|
*/
|
|
|
|
public File getDirectory() {
|
|
|
|
return directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Type of this Template
|
|
|
|
*
|
|
|
|
* @return Template Type
|
|
|
|
*/
|
|
|
|
public ServerType getType() {
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
2019-05-09 22:17:15 +02:00
|
|
|
/**
|
|
|
|
* Get whether this Template requires the Version argument
|
|
|
|
*
|
|
|
|
* @return Version Requirement
|
|
|
|
*/
|
|
|
|
public boolean requiresVersion() {
|
|
|
|
return getBuildOptions().getBoolean("Require-Version", false);
|
|
|
|
}
|
|
|
|
|
2019-06-17 05:13:48 +02:00
|
|
|
/**
|
|
|
|
* Get whether this Template can be used to update it's servers
|
|
|
|
*
|
|
|
|
* @return Updatable Status
|
|
|
|
*/
|
|
|
|
public boolean canUpdate() {
|
|
|
|
return getBuildOptions().getBoolean("Can-Update", false);
|
|
|
|
}
|
|
|
|
|
2021-06-06 04:44:33 +02:00
|
|
|
/**
|
|
|
|
* Get whether this Template was generated by a SubCreator instance
|
|
|
|
*
|
2021-06-25 05:06:53 +02:00
|
|
|
* @return Dynamic Status
|
2021-06-06 04:44:33 +02:00
|
|
|
*/
|
|
|
|
public boolean isDynamic() {
|
|
|
|
return dynamic;
|
|
|
|
}
|
|
|
|
|
2017-05-29 07:00:02 +02:00
|
|
|
/**
|
|
|
|
* Get the Build Options for this Template
|
|
|
|
*
|
|
|
|
* @return Build Options
|
|
|
|
*/
|
2019-04-18 16:02:09 +02:00
|
|
|
public ObjectMap<String> getBuildOptions() {
|
2017-05-29 07:00:02 +02:00
|
|
|
return build;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Configuration Options for this Template
|
|
|
|
*
|
|
|
|
* @return Configuration Options
|
|
|
|
*/
|
2019-04-18 16:02:09 +02:00
|
|
|
public ObjectMap<String> getConfigOptions() {
|
2017-05-29 07:00:02 +02:00
|
|
|
return options;
|
|
|
|
}
|
2018-01-21 21:45:27 +01:00
|
|
|
|
2019-04-18 16:02:09 +02:00
|
|
|
|
|
|
|
public ObjectMap<String> forSubData() {
|
|
|
|
ObjectMap<String> tinfo = new ObjectMap<String>();
|
2018-04-15 03:53:51 +02:00
|
|
|
tinfo.set("enabled", isEnabled());
|
2018-07-29 04:09:47 +02:00
|
|
|
tinfo.set("name", getName());
|
2018-04-15 03:53:51 +02:00
|
|
|
tinfo.set("display", getDisplayName());
|
|
|
|
tinfo.set("icon", getIcon());
|
|
|
|
tinfo.set("type", getType().toString());
|
2019-05-09 22:17:15 +02:00
|
|
|
tinfo.set("version-req", requiresVersion());
|
2019-06-17 05:13:48 +02:00
|
|
|
tinfo.set("can-update", canUpdate());
|
2019-04-18 16:02:09 +02:00
|
|
|
return tinfo;
|
2018-01-21 21:45:27 +01:00
|
|
|
}
|
2017-05-29 07:00:02 +02:00
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
public enum ServerType {
|
|
|
|
SPIGOT,
|
|
|
|
VANILLA,
|
2018-07-26 19:34:31 +02:00
|
|
|
FORGE,
|
2017-05-29 07:00:02 +02:00
|
|
|
SPONGE,
|
|
|
|
CUSTOM;
|
2017-01-01 20:34:46 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase();
|
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
}
|
|
|
|
|
2018-08-30 03:55:59 +02:00
|
|
|
/**
|
|
|
|
* Create a SubServer
|
|
|
|
*
|
|
|
|
* @param player Player Creating
|
|
|
|
* @param name Server Name
|
|
|
|
* @param template Server Template
|
2019-04-18 16:02:09 +02:00
|
|
|
* @param version Server Version (may be null)
|
2018-10-08 23:07:44 +02:00
|
|
|
* @param port Server Port Number (null to auto-select)
|
2019-06-17 05:13:48 +02:00
|
|
|
* @param callback Callback
|
2018-08-30 03:55:59 +02:00
|
|
|
* @return Success Status
|
|
|
|
*/
|
2021-10-24 06:14:07 +02:00
|
|
|
public abstract boolean create(UUID player, String name, ServerTemplate template, Version version, Integer port, Consumer<SubServer> callback);
|
2017-11-22 22:58:33 +01:00
|
|
|
|
2018-08-30 03:55:59 +02:00
|
|
|
/**
|
|
|
|
* Create a SubServer
|
|
|
|
*
|
|
|
|
* @param player Player Creating
|
|
|
|
* @param name Server Name
|
|
|
|
* @param template Server Template
|
2019-04-18 16:02:09 +02:00
|
|
|
* @param version Server Version (may be null)
|
2018-10-08 23:07:44 +02:00
|
|
|
* @param port Server Port Number (null to auto-select)
|
2018-08-30 03:55:59 +02:00
|
|
|
* @return Success Status
|
|
|
|
*/
|
2018-10-08 23:07:44 +02:00
|
|
|
public boolean create(UUID player, String name, ServerTemplate template, Version version, Integer port) {
|
2018-08-30 03:55:59 +02:00
|
|
|
return create(player, name, template, version, port, null);
|
2017-11-22 22:58:33 +01:00
|
|
|
}
|
|
|
|
|
2016-12-28 01:15:36 +01:00
|
|
|
/**
|
|
|
|
* Create a SubServer
|
|
|
|
*
|
|
|
|
* @param name Server Name
|
2017-05-29 07:00:02 +02:00
|
|
|
* @param template Server Template
|
2019-04-18 16:02:09 +02:00
|
|
|
* @param version Server Version (may be null)
|
2018-10-08 23:07:44 +02:00
|
|
|
* @param port Server Port Number (null to auto-select)
|
2019-06-17 05:13:48 +02:00
|
|
|
* @param callback Callback
|
2016-12-28 01:15:36 +01:00
|
|
|
* @return Success Status
|
|
|
|
*/
|
2021-10-24 06:14:07 +02:00
|
|
|
public boolean create(String name, ServerTemplate template, Version version, Integer port, Consumer<SubServer> callback) {
|
2018-08-30 03:55:59 +02:00
|
|
|
return create(null, name, template, version, port, callback);
|
|
|
|
}
|
2016-12-28 01:15:36 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a SubServer
|
|
|
|
*
|
|
|
|
* @param name Server Name
|
2017-05-29 07:00:02 +02:00
|
|
|
* @param template Server Template
|
2019-04-18 16:02:09 +02:00
|
|
|
* @param version Server Version (may be null)
|
2018-10-08 23:07:44 +02:00
|
|
|
* @param port Server Port Number (null to auto-select)
|
2016-12-28 01:15:36 +01:00
|
|
|
* @return Success Status
|
|
|
|
*/
|
2018-10-08 23:07:44 +02:00
|
|
|
public boolean create(String name, ServerTemplate template, Version version, Integer port) {
|
2017-05-29 07:00:02 +02:00
|
|
|
return create(null, name, template, version, port);
|
2016-12-05 04:21:04 +01:00
|
|
|
}
|
|
|
|
|
2019-06-17 05:13:48 +02:00
|
|
|
/**
|
|
|
|
* Update a SubServer
|
|
|
|
*
|
|
|
|
* @param player Player Updating
|
|
|
|
* @param server Server to Update
|
2020-08-20 03:15:55 +02:00
|
|
|
* @param template Server Template
|
2019-06-17 05:13:48 +02:00
|
|
|
* @param version Server Version (may be null)
|
|
|
|
* @param callback Callback
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
2021-10-24 06:14:07 +02:00
|
|
|
public abstract boolean update(UUID player, SubServer server, ServerTemplate template, Version version, Consumer<Boolean> callback);
|
2019-06-17 05:13:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a SubServer
|
|
|
|
*
|
|
|
|
* @param player Player Updating
|
|
|
|
* @param server Server to Update
|
2020-08-20 03:15:55 +02:00
|
|
|
* @param template Server Template
|
2019-06-17 05:13:48 +02:00
|
|
|
* @param version Server Version (may be null)
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
2020-08-20 03:15:55 +02:00
|
|
|
public boolean update(UUID player, SubServer server, ServerTemplate template, Version version) {
|
|
|
|
return update(player, server, template, version, null);
|
2019-06-17 05:13:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a SubServer
|
|
|
|
*
|
|
|
|
* @param server Server to Update
|
2020-08-20 03:15:55 +02:00
|
|
|
* @param template Server Template
|
2019-06-17 05:13:48 +02:00
|
|
|
* @param version Server Version (may be null)
|
|
|
|
* @param callback Callback
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
2021-10-24 06:14:07 +02:00
|
|
|
public boolean update(SubServer server, ServerTemplate template, Version version, Consumer<Boolean> callback) {
|
2020-08-20 03:15:55 +02:00
|
|
|
return update(null, server, template, version, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a SubServer
|
|
|
|
*
|
|
|
|
* @param server Server to Update
|
|
|
|
* @param template Server Template
|
|
|
|
* @param version Server Version (may be null)
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
public boolean update(SubServer server, ServerTemplate template, Version version) {
|
|
|
|
return update(null, server, template, version);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a SubServer
|
|
|
|
*
|
|
|
|
* @param player Player Updating
|
|
|
|
* @param server Server to Update
|
|
|
|
* @param version Server Version (may be null)
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
public boolean update(UUID player, SubServer server, Version version) {
|
|
|
|
return update(player, server, null, version);
|
2019-06-17 05:13:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update a SubServer
|
|
|
|
*
|
|
|
|
* @param server Server to Update
|
|
|
|
* @param version Server Version (may be null)
|
|
|
|
* @return Success Status
|
|
|
|
*/
|
|
|
|
public boolean update(SubServer server, Version version) {
|
|
|
|
return update(null, server, version);
|
|
|
|
}
|
|
|
|
|
2016-12-28 01:15:36 +01:00
|
|
|
/**
|
2017-07-23 06:32:57 +02:00
|
|
|
* Terminate All SubCreator Instances on this host
|
2016-12-28 01:15:36 +01:00
|
|
|
*/
|
|
|
|
public abstract void terminate();
|
|
|
|
|
|
|
|
/**
|
2017-07-23 06:32:57 +02:00
|
|
|
* Terminate a SubCreator Instance
|
|
|
|
*
|
|
|
|
* @param name Name of current creating server
|
|
|
|
*/
|
|
|
|
public abstract void terminate(String name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wait for All SubCreator Instances to Finish
|
2016-12-28 01:15:36 +01:00
|
|
|
*
|
|
|
|
* @throws InterruptedException
|
|
|
|
*/
|
2016-12-05 04:21:04 +01:00
|
|
|
public abstract void waitFor() throws InterruptedException;
|
|
|
|
|
2017-07-23 06:32:57 +02:00
|
|
|
/**
|
|
|
|
* Wait for SubCreator to Finish
|
|
|
|
*
|
|
|
|
* @param name Name of current creating server
|
|
|
|
* @throws InterruptedException
|
|
|
|
*/
|
|
|
|
public abstract void waitFor(String name) throws InterruptedException;
|
|
|
|
|
2016-12-28 01:15:36 +01:00
|
|
|
/**
|
|
|
|
* Gets the host this creator belongs to
|
|
|
|
*
|
|
|
|
* @return Host
|
|
|
|
*/
|
2016-12-05 04:21:04 +01:00
|
|
|
public abstract Host getHost();
|
|
|
|
|
2019-01-05 22:04:45 +01:00
|
|
|
/**
|
|
|
|
* Get the range of available port numbers
|
|
|
|
*
|
|
|
|
* @return Port Range
|
|
|
|
*/
|
|
|
|
public abstract Range getPortRange();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the range of available port numbers
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
public abstract void setPortRange(Range<Integer> value);
|
|
|
|
|
2016-12-28 01:15:36 +01:00
|
|
|
/**
|
|
|
|
* Gets the Git Bash install directory
|
|
|
|
*
|
|
|
|
* @return Git Bash Directory
|
|
|
|
*/
|
2017-01-21 17:49:37 +01:00
|
|
|
public abstract String getBashDirectory();
|
2016-12-15 22:04:39 +01:00
|
|
|
|
2017-01-11 04:23:29 +01:00
|
|
|
/**
|
2017-07-23 06:32:57 +02:00
|
|
|
* Gets all loggers for All SubCreator Instances
|
|
|
|
*
|
|
|
|
* @return SubCreator Loggers
|
|
|
|
*/
|
2018-10-08 23:07:44 +02:00
|
|
|
public abstract List<SubLogger> getLoggers();
|
2017-07-23 06:32:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the Logger for a SubCreator Instance
|
2017-01-11 04:23:29 +01:00
|
|
|
*
|
2017-07-23 06:32:57 +02:00
|
|
|
* @param thread Thread ID
|
|
|
|
* @return SubCreator Logger
|
2017-01-11 04:23:29 +01:00
|
|
|
*/
|
2017-07-23 06:32:57 +02:00
|
|
|
public abstract SubLogger getLogger(String thread);
|
2017-01-11 04:23:29 +01:00
|
|
|
|
2019-01-05 22:04:45 +01:00
|
|
|
/**
|
|
|
|
* If the Creator is Logging to console
|
|
|
|
*
|
|
|
|
* @return Logging Status
|
|
|
|
*/
|
|
|
|
public abstract boolean isLogging();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set if the Creator is Logging
|
|
|
|
*
|
|
|
|
* @param value Value
|
|
|
|
*/
|
|
|
|
public abstract void setLogging(boolean value);
|
|
|
|
|
2017-11-22 22:58:33 +01:00
|
|
|
|
2016-12-28 01:15:36 +01:00
|
|
|
/**
|
2017-07-23 06:32:57 +02:00
|
|
|
* Get a list of currently reserved Server names
|
2016-12-28 01:15:36 +01:00
|
|
|
*
|
2017-07-23 06:32:57 +02:00
|
|
|
* @return Reserved Names
|
2016-12-28 01:15:36 +01:00
|
|
|
*/
|
2017-07-23 06:32:57 +02:00
|
|
|
public abstract List<String> getReservedNames();
|
|
|
|
|
2018-10-08 23:07:44 +02:00
|
|
|
/**
|
|
|
|
* Get a list of currently reserved Server ports
|
|
|
|
*
|
|
|
|
* @return Reserved Ports
|
|
|
|
*/
|
|
|
|
public abstract List<Integer> getReservedPorts();
|
|
|
|
|
2017-07-23 06:32:57 +02:00
|
|
|
/**
|
|
|
|
* Check if a name has been reserved
|
|
|
|
*
|
|
|
|
* @param name Name to check
|
|
|
|
* @return Reserved Status
|
|
|
|
*/
|
|
|
|
public static boolean isReserved(String name) {
|
|
|
|
boolean reserved = false;
|
|
|
|
for (List<String> list : getAllReservedNames().values()) for (String reserve : list) {
|
|
|
|
if (reserve.equalsIgnoreCase(name)) reserved = true;
|
|
|
|
}
|
|
|
|
return reserved;
|
|
|
|
}
|
|
|
|
|
2018-10-08 23:07:44 +02:00
|
|
|
/**
|
|
|
|
* Check if an address has been reserved
|
|
|
|
*
|
|
|
|
* @param address Address to check
|
|
|
|
* @return Reserved Status
|
|
|
|
*/
|
|
|
|
public static boolean isReserved(InetSocketAddress address) {
|
|
|
|
boolean reserved = false;
|
|
|
|
for (InetSocketAddress list : getAllReservedAddresses()) {
|
|
|
|
if (list.equals(address)) reserved = true;
|
|
|
|
}
|
|
|
|
return reserved;
|
|
|
|
}
|
|
|
|
|
2017-07-23 06:32:57 +02:00
|
|
|
/**
|
|
|
|
* Get a list of all currently reserved Server names across all hosts
|
|
|
|
*
|
|
|
|
* @return All Reserved Names
|
|
|
|
*/
|
|
|
|
public static Map<Host, List<String>> getAllReservedNames() {
|
|
|
|
HashMap<Host, List<String>> names = new HashMap<Host, List<String>>();
|
|
|
|
for (Host host : SubAPI.getInstance().getHosts().values()) names.put(host, host.getCreator().getReservedNames());
|
|
|
|
return names;
|
|
|
|
}
|
2017-05-29 07:00:02 +02:00
|
|
|
|
2018-10-08 23:07:44 +02:00
|
|
|
/**
|
|
|
|
* Get a list of all currently reserved Server names across all hosts
|
|
|
|
*
|
|
|
|
* @return All Reserved Names
|
|
|
|
*/
|
|
|
|
public static List<InetSocketAddress> getAllReservedAddresses() {
|
|
|
|
List<InetSocketAddress> addresses = new ArrayList<InetSocketAddress>();
|
|
|
|
for (Server server : SubAPI.getInstance().getSubServers().values()) {
|
|
|
|
addresses.add(server.getAddress());
|
|
|
|
}
|
|
|
|
for (Host host : SubAPI.getInstance().getHosts().values())
|
|
|
|
for (int port : host.getCreator().getReservedPorts())
|
|
|
|
addresses.add(new InetSocketAddress(host.getAddress(), port));
|
|
|
|
return addresses;
|
|
|
|
}
|
|
|
|
|
2017-05-29 07:00:02 +02:00
|
|
|
/**
|
|
|
|
* Gets the Templates that can be used in this SubCreator instance
|
|
|
|
*
|
|
|
|
* @return Template Map
|
|
|
|
*/
|
|
|
|
public abstract Map<String, ServerTemplate> getTemplates();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a SubCreator Template by name
|
|
|
|
*
|
|
|
|
* @param name Template Name
|
|
|
|
* @return Template
|
|
|
|
*/
|
|
|
|
public abstract ServerTemplate getTemplate(String name);
|
2017-08-17 01:29:02 +02:00
|
|
|
|
2021-06-06 04:44:33 +02:00
|
|
|
/**
|
|
|
|
* Create a SubCreator Template
|
|
|
|
*
|
|
|
|
* @param name Template Name
|
|
|
|
* @param enabled Template Enabled Status
|
2021-06-25 05:06:53 +02:00
|
|
|
* @param internal Template Internal Status
|
2021-06-06 04:44:33 +02:00
|
|
|
* @param icon Template Item Icon Name
|
|
|
|
* @param directory Template Directory
|
|
|
|
* @param build Build Options
|
|
|
|
* @param options Configuration Options
|
|
|
|
*/
|
2021-06-25 05:06:53 +02:00
|
|
|
protected ServerTemplate loadTemplate(String name, boolean enabled, boolean internal, String icon, File directory, ObjectMap<String> build, ObjectMap<String> options) {
|
|
|
|
return new ServerTemplate(name, enabled, internal, icon, directory, build, options, false);
|
2021-06-06 04:44:33 +02:00
|
|
|
}
|
|
|
|
|
2017-08-17 01:29:02 +02:00
|
|
|
/**
|
|
|
|
* Reload SubCreator
|
|
|
|
*/
|
|
|
|
public abstract void reload();
|
2016-12-05 04:21:04 +01:00
|
|
|
}
|