mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-25 11:46:50 +01:00
Replace Auto-Restart and Temporary Flags with Stop Actions
Stop Actions will is the replacement for both the Auto Restart and Temporary flags. To define that the server should restart on stop, use the RESTART keyword. To get the same result that you would get using the temporary flag, use the REMOVE_SERVER keyword. Additionally, there is now a DELETE_SERVER keyword. This keyword does the same thing as the REMOVE_SERVER keyword, except it deletes the directory on the server ran from. If you would like nothing special to happen when the server stops, use the NONE keyword.
This commit is contained in:
parent
a781370fbb
commit
bc5acab41d
@ -95,9 +95,14 @@ public class ExternalHost extends Host implements ClientHandler {
|
||||
client.rename(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return this.client.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled && this.client.name();
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,17 +142,13 @@ public class ExternalHost extends Host implements ClientHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException {
|
||||
public SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
|
||||
if (plugin.api.getServers().keySet().contains(name.toLowerCase())) throw new InvalidServerException("A Server already exists with this name!");
|
||||
SubServer server = new ExternalSubServer(this, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
|
||||
SubAddServerEvent event = new SubAddServerEvent(player, this, server);
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
queue(new PacketExAddServer(name, enabled, log, directory, executable, stopcmd, (server.isRunning())?((ExternalSubLogger) server.getLogger()).getExternalAddress():null, data -> {
|
||||
if (data.getInt("r") == 0) {
|
||||
if (temporary && server.start()) server.setTemporary(true);
|
||||
}
|
||||
}));
|
||||
queue(new PacketExAddServer(name, enabled, log, directory, executable, stopcmd, (server.isRunning())?((ExternalSubLogger) server.getLogger()).getExternalAddress():null));
|
||||
servers.put(name.toLowerCase(), server);
|
||||
return server;
|
||||
} else {
|
||||
@ -158,19 +159,18 @@ public class ExternalHost extends Host implements ClientHandler {
|
||||
@Override
|
||||
public boolean removeSubServer(UUID player, String name) throws InterruptedException {
|
||||
if (Util.isNull(name)) throw new NullPointerException();
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(name));
|
||||
String server = servers.get(name.toLowerCase()).getName();
|
||||
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
if (getSubServer(name).isRunning()) {
|
||||
getSubServer(name).stop();
|
||||
getSubServer(name).waitFor();
|
||||
if (getSubServer(server).isRunning()) {
|
||||
getSubServer(server).stop();
|
||||
getSubServer(server).waitFor();
|
||||
}
|
||||
queue(new PacketExRemoveServer(name, data -> {
|
||||
queue(new PacketExRemoveServer(server, data -> {
|
||||
if (data.getInt("r") == 0) {
|
||||
List<String> groups = new ArrayList<String>();
|
||||
groups.addAll(getSubServer(name).getGroups());
|
||||
for (String group : groups) getSubServer(name).removeGroup(group);
|
||||
servers.remove(name.toLowerCase());
|
||||
servers.remove(server.toLowerCase());
|
||||
}
|
||||
}));
|
||||
return true;
|
||||
@ -180,15 +180,16 @@ public class ExternalHost extends Host implements ClientHandler {
|
||||
@Override
|
||||
public boolean forceRemoveSubServer(UUID player, String name) {
|
||||
if (Util.isNull(name)) throw new NullPointerException();
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(name));
|
||||
String server = servers.get(name.toLowerCase()).getName();
|
||||
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
if (getSubServer(name).isRunning()) {
|
||||
getSubServer(name).terminate();
|
||||
if (getSubServer(server).isRunning()) {
|
||||
getSubServer(server).terminate();
|
||||
}
|
||||
queue(new PacketExRemoveServer(name, data -> {
|
||||
queue(new PacketExRemoveServer(server, data -> {
|
||||
if (data.getInt("r") == 0) {
|
||||
for (String group : getSubServer(name).getGroups()) getSubServer(name).removeGroup(group);
|
||||
servers.remove(name.toLowerCase());
|
||||
servers.remove(server.toLowerCase());
|
||||
}
|
||||
}));
|
||||
return true;
|
||||
@ -223,11 +224,10 @@ public class ExternalHost extends Host implements ClientHandler {
|
||||
System.out.println("SubServers > Removing Files...");
|
||||
queue(new PacketExDeleteServer(server, info, data -> {
|
||||
if (data.getInt("r") == 0) {
|
||||
for (String group : getSubServer(name).getGroups()) getSubServer(name).removeGroup(group);
|
||||
servers.remove(server.toLowerCase());
|
||||
System.out.println("SubServers > Done!");
|
||||
System.out.println("SubServers > Deleted SubServer: " + server);
|
||||
} else {
|
||||
System.out.println("SubServers > Couldn't remove server from memory. See " + getName() + " console for more details");
|
||||
System.out.println("SubServers > Couldn't remove " + server + " from memory. See " + getName() + " console for more details");
|
||||
}
|
||||
}));
|
||||
return true;
|
||||
@ -261,11 +261,11 @@ public class ExternalHost extends Host implements ClientHandler {
|
||||
System.out.println("SubServers > Removing Files...");
|
||||
queue(new PacketExDeleteServer(server, info, data -> {
|
||||
if (data.getInt("r") == 0) {
|
||||
for (String group : getSubServer(name).getGroups()) getSubServer(name).removeGroup(group);
|
||||
for (String group : getSubServer(server).getGroups()) getSubServer(server).removeGroup(group);
|
||||
servers.remove(server.toLowerCase());
|
||||
System.out.println("SubServers > Done!");
|
||||
System.out.println("SubServers > Deleted SubServer: " + server);
|
||||
} else {
|
||||
System.out.println("SubServers > Couldn't remove server from memory. See " + getName() + " console for more details");
|
||||
System.out.println("SubServers > Couldn't remove " + server + " from memory. See " + getName() + " console for more details");
|
||||
}
|
||||
}));
|
||||
return true;
|
||||
|
@ -11,6 +11,7 @@ import net.ME1312.SubServers.Bungee.Network.Packet.PacketExCreateServer;
|
||||
import net.ME1312.SubServers.Bungee.SubAPI;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@ -57,9 +58,10 @@ public class ExternalSubCreator extends SubCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(UUID player, String name, ServerTemplate template, Version version, int port) {
|
||||
public boolean create(UUID player, String name, ServerTemplate template, Version version, int port, Callback<SubServer> callback) {
|
||||
if (Util.isNull(name, template, version, port)) throw new NullPointerException();
|
||||
if (template.isEnabled() && !SubAPI.getInstance().getSubServers().keySet().contains(name.toLowerCase()) && !SubCreator.isReserved(name)) {
|
||||
if (host.isAvailable() && host.isEnabled() && template.isEnabled() && !SubAPI.getInstance().getSubServers().keySet().contains(name.toLowerCase()) && !SubCreator.isReserved(name)) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
ExternalSubLogger logger = new ExternalSubLogger(this, name + File.separator + "Creator", new Container<Boolean>(host.plugin.config.get().getSection("Settings").getBoolean("Log-Creator")), null);
|
||||
thread.put(name.toLowerCase(), logger);
|
||||
final SubCreateEvent event = new SubCreateEvent(player, host, name, template, version, port);
|
||||
@ -78,7 +80,6 @@ public class ExternalSubCreator extends SubCreator {
|
||||
new NamedContainer<>("$template$", template.getName()), new NamedContainer<>("$type$", template.getType().toString()), new NamedContainer<>("$version$", version.toString().replace(" ", "@")), new NamedContainer<>("$port$", Integer.toString(port))));
|
||||
|
||||
server.set("Enabled", true);
|
||||
//server.set("Editable", true);
|
||||
server.set("Display", "");
|
||||
server.set("Host", host.getName());
|
||||
server.set("Group", new ArrayList<String>());
|
||||
@ -88,25 +89,33 @@ public class ExternalSubCreator extends SubCreator {
|
||||
server.set("Directory", "." + File.separatorChar + name);
|
||||
server.set("Executable", "java -Xmx1024M -jar " + template.getType().toString() + ".jar");
|
||||
server.set("Stop-Command", "stop");
|
||||
server.set("Stop-Action", "NONE");
|
||||
server.set("Run-On-Launch", false);
|
||||
server.set("Auto-Restart", false);
|
||||
server.set("Restricted", false);
|
||||
server.set("Incompatible", new ArrayList<String>());
|
||||
server.set("Hidden", false);
|
||||
server.setAll(config);
|
||||
|
||||
SubServer subserver = host.addSubServer(player, name, server.getBoolean("Enabled"), port, server.getColoredString("Motd", '&'), server.getBoolean("Log"), server.getRawString("Directory"),
|
||||
new Executable(server.getRawString("Executable")), server.getRawString("Stop-Command"), server.getBoolean("Hidden"), server.getBoolean("Restricted"), false);
|
||||
if (server.getBoolean("Editable", true)) subserver.setEditable(true);
|
||||
if (server.getBoolean("Auto-Restart")) subserver.setAutoRestart(true);
|
||||
new Executable(server.getRawString("Executable")), server.getRawString("Stop-Command"), server.getBoolean("Hidden"), server.getBoolean("Restricted"));
|
||||
if (server.getString("Display").length() > 0) subserver.setDisplayName(server.getString("Display"));
|
||||
for (String group : server.getStringList("Group")) subserver.addGroup(group);
|
||||
SubServer.StopAction action = Util.getDespiteException(() -> SubServer.StopAction.valueOf(server.getRawString("Stop-Action").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
if (action != null) subserver.setStopAction(action);
|
||||
if (server.contains("Extra")) for (String extra : server.getSection("Extra").getKeys())
|
||||
subserver.addExtra(extra, server.getSection("Extra").getObject(extra));
|
||||
host.plugin.config.get().getSection("Servers").set(name, server);
|
||||
host.plugin.config.save();
|
||||
if (template.getBuildOptions().getBoolean("Run-On-Finish", true))
|
||||
subserver.start();
|
||||
|
||||
if (callback != null) try {
|
||||
callback.run(subserver);
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
System.out.println(name + "/Creator > " + data.getString("m"));
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import net.ME1312.SubServers.Bungee.SubAPI;
|
||||
import net.md_5.bungee.BungeeServerInfo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
@ -25,15 +26,13 @@ import java.util.UUID;
|
||||
public class ExternalSubServer extends SubServerContainer {
|
||||
private ExternalHost host;
|
||||
private boolean enabled;
|
||||
private boolean editable;
|
||||
private Container<Boolean> log;
|
||||
private String dir;
|
||||
protected Executable exec;
|
||||
private String stopcmd;
|
||||
private StopAction stopaction;
|
||||
private LinkedList<LoggedCommand> history;
|
||||
private ExternalSubLogger logger;
|
||||
private boolean restart;
|
||||
private boolean temporary;
|
||||
private boolean running;
|
||||
private boolean lock;
|
||||
|
||||
@ -55,20 +54,18 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
*/
|
||||
public ExternalSubServer(ExternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
|
||||
super(host, name, port, motd, hidden, restricted);
|
||||
if (Util.isNull(host, name, enabled, port, motd, log, stopcmd, restart, hidden, restricted)) throw new NullPointerException();
|
||||
if (Util.isNull(host, name, enabled, port, motd, log, stopcmd, hidden, restricted)) throw new NullPointerException();
|
||||
this.host = host;
|
||||
this.enabled = enabled;
|
||||
this.editable = false;
|
||||
this.log = new Container<Boolean>(log);
|
||||
this.dir = directory;
|
||||
this.exec = executable;
|
||||
this.stopcmd = stopcmd;
|
||||
this.stopaction = StopAction.NONE;
|
||||
this.history = new LinkedList<LoggedCommand>();
|
||||
this.logger = new ExternalSubLogger(this, getName(), this.log, null);
|
||||
this.restart = false;
|
||||
|
||||
this.running = false;
|
||||
this.temporary = false;
|
||||
this.lock = false;
|
||||
}
|
||||
|
||||
@ -89,7 +86,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
} else return false;
|
||||
}
|
||||
private void falsestart() {
|
||||
System.out.println("SubServers > Couldn't start " + getName() + " \u2014 See the " + host.getName() + " console for more details");
|
||||
System.out.println("SubServers > Couldn't start " + getName() + " - See the " + host.getName() + " console for more details");
|
||||
running = false;
|
||||
logger.stop();
|
||||
}
|
||||
@ -114,16 +111,26 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
history.clear();
|
||||
running = false;
|
||||
|
||||
if (isTemporary()) {
|
||||
if (stopaction == StopAction.REMOVE_SERVER || stopaction == StopAction.DELETE_SERVER) {
|
||||
try {
|
||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName()))
|
||||
host.plugin.config.get().getSection("Servers").remove(getName());
|
||||
host.removeSubServer(getName());
|
||||
if (stopaction == StopAction.DELETE_SERVER) {
|
||||
host.deleteSubServer(getName());
|
||||
} else {
|
||||
try {
|
||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
host.plugin.config.get().getSection("Servers").remove(getName());
|
||||
host.plugin.config.save();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
host.removeSubServer(getName());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (willAutoRestart() && allowrestart) {
|
||||
} else if (stopaction == StopAction.RESTART) {
|
||||
if (allowrestart) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(250);
|
||||
@ -174,7 +181,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
boolean state = isRunning();
|
||||
SubServer forward = null;
|
||||
YAMLSection pending = edit.clone();
|
||||
if (editable) for (String key : edit.getKeys()) {
|
||||
for (String key : edit.getKeys()) {
|
||||
pending.remove(key);
|
||||
YAMLValue value = edit.get(key);
|
||||
SubEditServerEvent event = new SubEditServerEvent(player, this, new NamedContainer<String, YAMLValue>(key, value), true);
|
||||
@ -184,7 +191,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
switch (key) {
|
||||
case "name":
|
||||
if (value.isString() && host.removeSubServer(player, getName())) {
|
||||
SubServer server = host.addSubServer(player, value.asRawString(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = host.addSubServer(player, value.asRawString(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
YAMLSection config = this.host.plugin.config.get().getSection("Servers").getSection(getName());
|
||||
@ -246,7 +253,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
case "host":
|
||||
if (value.isString() && host.removeSubServer(player, getName())) {
|
||||
waitFor(() -> host.getSubServer(getName()), null);
|
||||
SubServer server = this.host.plugin.api.getHost(value.asRawString()).addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = this.host.plugin.api.getHost(value.asRawString()).addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Host", server.getHost().getName());
|
||||
@ -260,7 +267,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
case "port":
|
||||
if (value.isNumber() && host.removeSubServer(player, getName())) {
|
||||
waitFor(() -> host.getSubServer(getName()), null);
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), value.asInt(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), value.asInt(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Port", server.getAddress().getPort());
|
||||
@ -298,7 +305,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
case "dir":
|
||||
if (value.isString() && host.removeSubServer(player, getName())) {
|
||||
waitFor(() -> host.getSubServer(getName()), null);
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), value.asRawString(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), value.asRawString(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Directory", server.getPath());
|
||||
@ -312,7 +319,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
case "exec":
|
||||
if (value.isString() && host.removeSubServer(player, getName())) {
|
||||
waitFor(() -> host.getSubServer(getName()), null);
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), new Executable(value.asRawString()), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), new Executable(value.asRawString()), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Executable", value.asRawString());
|
||||
@ -339,6 +346,19 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
c++;
|
||||
}
|
||||
break;
|
||||
case "stop-action":
|
||||
if (value.isString()) {
|
||||
StopAction action = Util.getDespiteException(() -> StopAction.valueOf(value.asRawString().toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
if (action != null) {
|
||||
stopaction = action;
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Stop-Action", getStopAction().toString());
|
||||
this.host.plugin.config.save();
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "auto-run":
|
||||
if (value.isBoolean()) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
@ -348,16 +368,6 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
c++;
|
||||
}
|
||||
break;
|
||||
case "auto-restart":
|
||||
if (value.isBoolean()) {
|
||||
restart = value.asBoolean();
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Auto-Restart", willAutoRestart());
|
||||
this.host.plugin.config.save();
|
||||
}
|
||||
c++;
|
||||
}
|
||||
break;
|
||||
case "incompatible":
|
||||
if (value.isList()) {
|
||||
for (String oname : value.asStringList()) {
|
||||
@ -399,7 +409,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
break;
|
||||
}
|
||||
if (forward != null) {
|
||||
if (willAutoRestart()) forward.setAutoRestart(true);
|
||||
forward.setStopAction(getStopAction());
|
||||
if (!getName().equals(getDisplayName())) forward.setDisplayName(getDisplayName());
|
||||
List<String> groups = new ArrayList<String>();
|
||||
groups.addAll(getGroups());
|
||||
@ -413,7 +423,6 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
}
|
||||
for (String extra : getExtra().getKeys()) forward.addExtra(extra, getExtra(extra));
|
||||
|
||||
forward.setEditable(true);
|
||||
if (state) pending.set("state", true);
|
||||
c += forward.edit(player, pending);
|
||||
break;
|
||||
@ -447,7 +456,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
public void setDisplayName(String value) {
|
||||
super.setDisplayName(value);
|
||||
logger.name = getDisplayName();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("display", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("display", value), false));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -463,21 +472,11 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
@Override
|
||||
public void setEnabled(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("enabled", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("enabled", value), false));
|
||||
if (enabled != value) host.queue(new PacketExUpdateServer(this, PacketExUpdateServer.UpdateType.SET_ENABLED, (Boolean) value));
|
||||
enabled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean value) {
|
||||
editable = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogging() {
|
||||
return log.get();
|
||||
@ -486,7 +485,7 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
@Override
|
||||
public void setLogging(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("log", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("log", value), false));
|
||||
if (log.get() != value) host.queue(new PacketExUpdateServer(this, PacketExUpdateServer.UpdateType.SET_LOGGING, (Boolean) value));
|
||||
log.set(value);
|
||||
}
|
||||
@ -519,32 +518,20 @@ public class ExternalSubServer extends SubServerContainer {
|
||||
@Override
|
||||
public void setStopCommand(String value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("stop-cmd", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("stop-cmd", value), false));
|
||||
if (!stopcmd.equals(value)) host.queue(new PacketExUpdateServer(this, PacketExUpdateServer.UpdateType.SET_STOP_COMMAND, value));
|
||||
stopcmd = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean willAutoRestart() {
|
||||
return restart;
|
||||
public StopAction getStopAction() {
|
||||
return stopaction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoRestart(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("auto-restart", value), false);
|
||||
restart = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return temporary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTemporary(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("temp", value), false);
|
||||
this.temporary = !(value && !isRunning() && !start()) && value;
|
||||
public void setStopAction(StopAction action) {
|
||||
if (Util.isNull(action)) throw new NullPointerException();
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("stop-action", action), false));
|
||||
stopaction = action;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,15 @@ public abstract class Host implements ExtraDataHandler {
|
||||
SubDataServer.allowConnection(address.getHostAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Available?
|
||||
*
|
||||
* @return Availability Status
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Enabled?
|
||||
*
|
||||
@ -234,11 +243,10 @@ public abstract class Host implements ExtraDataHandler {
|
||||
* @param stopcmd Command to Stop the Server
|
||||
* @param hidden if the server should be hidden from players
|
||||
* @param restricted Players will need a permission to join if true
|
||||
* @param temporary Temporary Status
|
||||
* @return The SubServer
|
||||
* @throws InvalidServerException
|
||||
*/
|
||||
public abstract SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException;
|
||||
public abstract SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException;
|
||||
|
||||
/**
|
||||
* Adds a SubServer
|
||||
@ -253,12 +261,11 @@ public abstract class Host implements ExtraDataHandler {
|
||||
* @param stopcmd Command to Stop the Server
|
||||
* @param hidden if the server should be hidden from players
|
||||
* @param restricted Players will need a permission to join if true
|
||||
* @param temporary Temporary Status
|
||||
* @return The SubServer
|
||||
* @throws InvalidServerException
|
||||
*/
|
||||
public SubServer addSubServer(String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException {
|
||||
return addSubServer(null, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted, temporary);
|
||||
public SubServer addSubServer(String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
|
||||
return addSubServer(null, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -382,6 +389,7 @@ public abstract class Host implements ExtraDataHandler {
|
||||
hinfo.set("type", "Host");
|
||||
hinfo.set("name", getName());
|
||||
hinfo.set("display", getDisplayName());
|
||||
hinfo.set("available", isAvailable());
|
||||
hinfo.set("enabled", isEnabled());
|
||||
hinfo.set("address", getAddress().getHostAddress());
|
||||
hinfo.set("dir", getPath());
|
||||
|
@ -92,9 +92,9 @@ public class InternalHost extends Host {
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException {
|
||||
public SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
|
||||
if (plugin.api.getServers().keySet().contains(name.toLowerCase())) throw new InvalidServerException("A Server already exists with this name!");
|
||||
SubServer server = new InternalSubServer(this, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted, temporary);
|
||||
SubServer server = new InternalSubServer(this, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
|
||||
SubAddServerEvent event = new SubAddServerEvent(player, this, server);
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
@ -108,15 +108,15 @@ public class InternalHost extends Host {
|
||||
@Override
|
||||
public boolean removeSubServer(UUID player, String name) throws InterruptedException {
|
||||
if (Util.isNull(name)) throw new NullPointerException();
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(name));
|
||||
String server = servers.get(name.toLowerCase()).getName();
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
if (getSubServer(name).isRunning()) {
|
||||
getSubServer(name).stop();
|
||||
getSubServer(name).waitFor();
|
||||
if (getSubServer(server).isRunning()) {
|
||||
getSubServer(server).stop();
|
||||
getSubServer(server).waitFor();
|
||||
}
|
||||
|
||||
servers.remove(name.toLowerCase());
|
||||
servers.remove(server.toLowerCase());
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
@ -124,12 +124,13 @@ public class InternalHost extends Host {
|
||||
@Override
|
||||
public boolean forceRemoveSubServer(UUID player, String name) {
|
||||
if (Util.isNull(name)) throw new NullPointerException();
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(name));
|
||||
String server = servers.get(name.toLowerCase()).getName();
|
||||
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
|
||||
plugin.getPluginManager().callEvent(event);
|
||||
if (getSubServer(name).isRunning()) {
|
||||
getSubServer(name).terminate();
|
||||
if (getSubServer(server).isRunning()) {
|
||||
getSubServer(server).terminate();
|
||||
}
|
||||
servers.remove(name.toLowerCase());
|
||||
servers.remove(server.toLowerCase());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -172,7 +173,7 @@ public class InternalHost extends Host {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("SubServers > Done!");
|
||||
System.out.println("SubServers > Deleted SubServer: " + server);
|
||||
}).start();
|
||||
return true;
|
||||
} else return false;
|
||||
@ -217,7 +218,7 @@ public class InternalHost extends Host {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("SubServers > Done!");
|
||||
System.out.println("SubServers > Deleted SubServer: " + server);
|
||||
}).start();
|
||||
return true;
|
||||
} else return false;
|
||||
|
@ -2,14 +2,11 @@ package net.ME1312.SubServers.Bungee.Host.Internal;
|
||||
|
||||
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
|
||||
import net.ME1312.SubServers.Bungee.Host.*;
|
||||
import net.ME1312.SubServers.Bungee.Library.*;
|
||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLConfig;
|
||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||
import net.ME1312.SubServers.Bungee.Library.Container;
|
||||
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
|
||||
import net.ME1312.SubServers.Bungee.Library.Exception.SubCreatorException;
|
||||
import net.ME1312.SubServers.Bungee.Library.NamedContainer;
|
||||
import net.ME1312.SubServers.Bungee.Library.UniversalFile;
|
||||
import net.ME1312.SubServers.Bungee.Library.Util;
|
||||
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Bungee.SubAPI;
|
||||
import net.ME1312.SubServers.Bungee.SubPlugin;
|
||||
@ -20,6 +17,7 @@ import org.xml.sax.InputSource;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
@ -190,7 +188,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
return server;
|
||||
}
|
||||
|
||||
private void run(UUID player, String name, ServerTemplate template, Version version, int port) {
|
||||
private SubServer run(UUID player, String name, ServerTemplate template, Version version, int port) {
|
||||
NamedContainer<InternalSubLogger, Process> thread = this.thread.get(name.toLowerCase()).get();
|
||||
UniversalFile dir = new UniversalFile(new File(host.getPath()), name);
|
||||
dir.mkdirs();
|
||||
@ -217,7 +215,6 @@ public class InternalSubCreator extends SubCreator {
|
||||
new NamedContainer<>("$type$", template.getType().toString()), new NamedContainer<>("$version$", version.toString().replace(" ", "@")), new NamedContainer<>("$port$", Integer.toString(port))));
|
||||
|
||||
server.set("Enabled", true);
|
||||
//server.set("Editable", true);
|
||||
server.set("Display", "");
|
||||
server.set("Host", host.getName());
|
||||
server.set("Group", new ArrayList<String>());
|
||||
@ -227,25 +224,28 @@ public class InternalSubCreator extends SubCreator {
|
||||
server.set("Directory", "." + File.separatorChar + name);
|
||||
server.set("Executable", "java -Xmx1024M -jar " + template.getType().toString() + ".jar");
|
||||
server.set("Stop-Command", "stop");
|
||||
server.set("Stop-Action", "NONE");
|
||||
server.set("Run-On-Launch", false);
|
||||
server.set("Auto-Restart", false);
|
||||
server.set("Restricted", false);
|
||||
server.set("Incompatible", new ArrayList<String>());
|
||||
server.set("Hidden", false);
|
||||
server.setAll(config);
|
||||
|
||||
SubServer subserver = host.addSubServer(player, name, server.getBoolean("Enabled"), port, server.getColoredString("Motd", '&'), server.getBoolean("Log"), server.getRawString("Directory"),
|
||||
new Executable(server.getRawString("Executable")), server.getRawString("Stop-Command"), server.getBoolean("Hidden"), server.getBoolean("Restricted"), false);
|
||||
if (server.getBoolean("Editable", true)) subserver.setEditable(true);
|
||||
if (server.getBoolean("Auto-Restart")) subserver.setAutoRestart(true);
|
||||
new Executable(server.getRawString("Executable")), server.getRawString("Stop-Command"), server.getBoolean("Hidden"), server.getBoolean("Restricted"));
|
||||
if (server.getString("Display").length() > 0) subserver.setDisplayName(server.getString("Display"));
|
||||
for (String group : server.getStringList("Group")) subserver.addGroup(group);
|
||||
SubServer.StopAction action = Util.getDespiteException(() -> SubServer.StopAction.valueOf(server.getRawString("Stop-Action").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
if (action != null) subserver.setStopAction(action);
|
||||
if (server.contains("Extra")) for (String extra : server.getSection("Extra").getKeys())
|
||||
subserver.addExtra(extra, server.getSection("Extra").getObject(extra));
|
||||
host.plugin.config.get().getSection("Servers").set(name, server);
|
||||
host.plugin.config.save();
|
||||
if (template.getBuildOptions().getBoolean("Run-On-Finish", true))
|
||||
subserver.start();
|
||||
|
||||
this.thread.remove(name.toLowerCase());
|
||||
return subserver;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -253,6 +253,7 @@ public class InternalSubCreator extends SubCreator {
|
||||
System.out.println(name + File.separator + "Creator > Couldn't build the server jar. Check the SubCreator logs for more detail.");
|
||||
}
|
||||
this.thread.remove(name.toLowerCase());
|
||||
return null;
|
||||
} private Object convert(Object value, NamedContainer<String, String>... replacements) {
|
||||
if (value instanceof Map) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
@ -278,16 +279,27 @@ public class InternalSubCreator extends SubCreator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean create(UUID player, String name, ServerTemplate template, Version version, int port) {
|
||||
public boolean create(UUID player, String name, ServerTemplate template, Version version, int port, Callback<SubServer> callback) {
|
||||
if (Util.isNull(name, template, version, port)) throw new NullPointerException();
|
||||
if (host.isEnabled() && template.isEnabled() && !SubAPI.getInstance().getSubServers().keySet().contains(name.toLowerCase()) && !SubCreator.isReserved(name)) {
|
||||
if (host.isAvailable() && host.isEnabled() && template.isEnabled() && !SubAPI.getInstance().getSubServers().keySet().contains(name.toLowerCase()) && !SubCreator.isReserved(name)) {
|
||||
StackTraceElement[] origin = new Exception().getStackTrace();
|
||||
NamedContainer<Thread, NamedContainer<InternalSubLogger, Process>> thread = new NamedContainer<Thread, NamedContainer<InternalSubLogger, Process>>(null, new NamedContainer<InternalSubLogger, Process>(new InternalSubLogger(null, this, name + File.separator + "Creator", new Container<Boolean>(false), null), null));
|
||||
this.thread.put(name.toLowerCase(), thread);
|
||||
|
||||
final SubCreateEvent event = new SubCreateEvent(player, host, name, template, version, port);
|
||||
host.plugin.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
thread.rename(new Thread(() -> InternalSubCreator.this.run(player, name, event.getTemplate(), event.getVersion(), port)));
|
||||
thread.rename(new Thread(() -> {
|
||||
SubServer server = InternalSubCreator.this.run(player, name, event.getTemplate(), event.getVersion(), port);
|
||||
|
||||
if (callback != null && server != null) try {
|
||||
callback.run(server);
|
||||
} catch (Throwable e) {
|
||||
Throwable ew = new InvocationTargetException(e);
|
||||
ew.setStackTrace(origin);
|
||||
ew.printStackTrace();
|
||||
}
|
||||
}));
|
||||
thread.name().start();
|
||||
return true;
|
||||
} else {
|
||||
|
@ -28,20 +28,18 @@ import java.util.jar.JarInputStream;
|
||||
public class InternalSubServer extends SubServerContainer {
|
||||
private InternalHost host;
|
||||
private boolean enabled;
|
||||
private boolean editable;
|
||||
private Container<Boolean> log;
|
||||
private String dir;
|
||||
private File directory;
|
||||
private Executable executable;
|
||||
private String stopcmd;
|
||||
private StopAction stopaction;
|
||||
private LinkedList<LoggedCommand> history;
|
||||
private Process process;
|
||||
private InternalSubLogger logger;
|
||||
private Thread thread;
|
||||
private BufferedWriter command;
|
||||
private boolean restart;
|
||||
private boolean allowrestart;
|
||||
private boolean temporary;
|
||||
private boolean lock;
|
||||
|
||||
/**
|
||||
@ -58,26 +56,24 @@ public class InternalSubServer extends SubServerContainer {
|
||||
* @param stopcmd Stop Command
|
||||
* @param hidden Hidden Status
|
||||
* @param restricted Restricted Status
|
||||
* @param temporary Temporary Status
|
||||
* @throws InvalidServerException
|
||||
*/
|
||||
public InternalSubServer(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException {
|
||||
public InternalSubServer(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
|
||||
super(host, name, port, motd, hidden, restricted);
|
||||
if (Util.isNull(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted, temporary)) throw new NullPointerException();
|
||||
if (Util.isNull(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted)) throw new NullPointerException();
|
||||
this.host = host;
|
||||
this.enabled = enabled;
|
||||
this.editable = false;
|
||||
this.log = new Container<Boolean>(log);
|
||||
this.dir = directory;
|
||||
this.directory = new File(host.getPath(), directory);
|
||||
this.executable = executable;
|
||||
this.stopcmd = stopcmd;
|
||||
this.stopaction = StopAction.NONE;
|
||||
this.history = new LinkedList<LoggedCommand>();
|
||||
this.process = null;
|
||||
this.logger = new InternalSubLogger(null, this, getName(), this.log, null);
|
||||
this.thread = null;
|
||||
this.command = null;
|
||||
this.restart = false;
|
||||
|
||||
if (new UniversalFile(this.directory, "plugins:SubServers.Client.jar").exists()) {
|
||||
try {
|
||||
@ -116,7 +112,6 @@ public class InternalSubServer extends SubServerContainer {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.temporary = temporary && start();
|
||||
this.lock = false;
|
||||
}
|
||||
|
||||
@ -147,16 +142,26 @@ public class InternalSubServer extends SubServerContainer {
|
||||
command = null;
|
||||
history.clear();
|
||||
|
||||
if (isTemporary()) {
|
||||
if (stopaction == StopAction.REMOVE_SERVER || stopaction == StopAction.DELETE_SERVER) {
|
||||
try {
|
||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName()))
|
||||
host.plugin.config.get().getSection("Servers").remove(getName());
|
||||
host.removeSubServer(getName());
|
||||
if (stopaction == StopAction.DELETE_SERVER) {
|
||||
host.deleteSubServer(getName());
|
||||
} else {
|
||||
try {
|
||||
if (host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
host.plugin.config.get().getSection("Servers").remove(getName());
|
||||
host.plugin.config.save();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
host.removeSubServer(getName());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
if (willAutoRestart() && allowrestart) {
|
||||
} else if (stopaction == StopAction.RESTART) {
|
||||
if (allowrestart) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
while (thread != null && thread.isAlive()) {
|
||||
@ -251,7 +256,7 @@ public class InternalSubServer extends SubServerContainer {
|
||||
boolean state = isRunning();
|
||||
SubServer forward = null;
|
||||
YAMLSection pending = edit.clone();
|
||||
if (editable) for (String key : edit.getKeys()) {
|
||||
for (String key : edit.getKeys()) {
|
||||
pending.remove(key);
|
||||
YAMLValue value = edit.get(key);
|
||||
SubEditServerEvent event = new SubEditServerEvent(player, this, new NamedContainer<String, YAMLValue>(key, value), true);
|
||||
@ -261,7 +266,7 @@ public class InternalSubServer extends SubServerContainer {
|
||||
switch (key) {
|
||||
case "name":
|
||||
if (value.isString() && host.removeSubServer(player, getName())) {
|
||||
SubServer server = host.addSubServer(player, value.asRawString(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = host.addSubServer(player, value.asRawString(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
YAMLSection config = this.host.plugin.config.get().getSection("Servers").getSection(getName());
|
||||
@ -321,7 +326,7 @@ public class InternalSubServer extends SubServerContainer {
|
||||
break;
|
||||
case "host":
|
||||
if (value.isString() && host.removeSubServer(player, getName())) {
|
||||
SubServer server = this.host.plugin.api.getHost(value.asRawString()).addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = this.host.plugin.api.getHost(value.asRawString()).addSubServer(player, getName(), isEnabled(), getAddress().getPort(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Host", server.getHost().getName());
|
||||
@ -334,7 +339,7 @@ public class InternalSubServer extends SubServerContainer {
|
||||
break;
|
||||
case "port":
|
||||
if (value.isNumber() && host.removeSubServer(player, getName())) {
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), value.asInt(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted(), isTemporary());
|
||||
SubServer server = host.addSubServer(player, getName(), isEnabled(), value.asInt(), getMotd(), isLogging(), getPath(), getExecutable(), getStopCommand(), isHidden(), isRestricted());
|
||||
if (server != null) {
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Port", server.getAddress().getPort());
|
||||
@ -407,6 +412,19 @@ public class InternalSubServer extends SubServerContainer {
|
||||
c++;
|
||||
}
|
||||
break;
|
||||
case "stop-action":
|
||||
if (value.isString()) {
|
||||
StopAction action = Util.getDespiteException(() -> StopAction.valueOf(value.asRawString().toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
if (action != null) {
|
||||
stopaction = action;
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Stop-Action", getStopAction().toString());
|
||||
this.host.plugin.config.save();
|
||||
}
|
||||
c++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "state":
|
||||
if (value.isBoolean()) {
|
||||
state = value.asBoolean();
|
||||
@ -421,16 +439,6 @@ public class InternalSubServer extends SubServerContainer {
|
||||
c++;
|
||||
}
|
||||
break;
|
||||
case "auto-restart":
|
||||
if (value.isBoolean()) {
|
||||
restart = value.asBoolean();
|
||||
if (this.host.plugin.config.get().getSection("Servers").getKeys().contains(getName())) {
|
||||
this.host.plugin.config.get().getSection("Servers").getSection(getName()).set("Auto-Restart", willAutoRestart());
|
||||
this.host.plugin.config.save();
|
||||
}
|
||||
c++;
|
||||
}
|
||||
break;
|
||||
case "incompatible":
|
||||
if (value.isList()) {
|
||||
for (String oname : value.asStringList()) {
|
||||
@ -472,7 +480,7 @@ public class InternalSubServer extends SubServerContainer {
|
||||
break;
|
||||
}
|
||||
if (forward != null) {
|
||||
if (willAutoRestart()) forward.setAutoRestart(true);
|
||||
forward.setStopAction(getStopAction());
|
||||
if (!getName().equals(getDisplayName())) forward.setDisplayName(getDisplayName());
|
||||
List<String> groups = new ArrayList<String>();
|
||||
groups.addAll(getGroups());
|
||||
@ -486,7 +494,6 @@ public class InternalSubServer extends SubServerContainer {
|
||||
}
|
||||
for (String extra : getExtra().getKeys()) forward.addExtra(extra, getExtra(extra));
|
||||
|
||||
forward.setEditable(true);
|
||||
if (state) pending.set("state", true);
|
||||
c += forward.edit(player, pending);
|
||||
break;
|
||||
@ -531,20 +538,10 @@ public class InternalSubServer extends SubServerContainer {
|
||||
@Override
|
||||
public void setEnabled(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("enabled", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("enabled", value), false));
|
||||
enabled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return editable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean value) {
|
||||
editable = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogging() {
|
||||
return log.get();
|
||||
@ -553,7 +550,7 @@ public class InternalSubServer extends SubServerContainer {
|
||||
@Override
|
||||
public void setLogging(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("log", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("log", value), false));
|
||||
log.set(value);
|
||||
}
|
||||
|
||||
@ -585,31 +582,19 @@ public class InternalSubServer extends SubServerContainer {
|
||||
@Override
|
||||
public void setStopCommand(String value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("stop-cmd", value), false);
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("stop-cmd", value), false));
|
||||
stopcmd = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean willAutoRestart() {
|
||||
return restart;
|
||||
public StopAction getStopAction() {
|
||||
return stopaction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoRestart(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("auto-restart", value), false);
|
||||
restart = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return temporary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTemporary(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("temp", value), false);
|
||||
temporary = !(value && !isRunning() && !start()) && value;
|
||||
public void setStopAction(StopAction action) {
|
||||
if (Util.isNull(action)) throw new NullPointerException();
|
||||
host.plugin.getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("stop-action", action), false));
|
||||
stopaction = action;
|
||||
}
|
||||
}
|
||||
|
@ -54,12 +54,13 @@ public class ServerContainer extends BungeeServerInfo implements Server {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setDisplayName(String value) {
|
||||
if (value == null || value.length() == 0 || getName().equals(value)) {
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("display", getName()), false);
|
||||
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("display", getName()), false));
|
||||
this.nick = null;
|
||||
} else {
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("display", value), false);
|
||||
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("display", value), false));
|
||||
this.nick = value;
|
||||
}
|
||||
}
|
||||
@ -108,15 +109,17 @@ public class ServerContainer extends BungeeServerInfo implements Server {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setHidden(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("hidden", value), false);
|
||||
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("hidden", value), false));
|
||||
this.hidden = value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setMotd(String value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("motd", value), false);
|
||||
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("motd", value), false));
|
||||
try {
|
||||
Field f = BungeeServerInfo.class.getDeclaredField("motd");
|
||||
f.setAccessible(true);
|
||||
@ -127,9 +130,10 @@ public class ServerContainer extends BungeeServerInfo implements Server {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setRestricted(boolean value) {
|
||||
if (Util.isNull(value)) throw new NullPointerException();
|
||||
new SubEditServerEvent(null, this, new NamedContainer<String, Object>("restricted", value), false);
|
||||
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("restricted", value), false));
|
||||
try {
|
||||
Field f = BungeeServerInfo.class.getDeclaredField("restricted");
|
||||
f.setAccessible(true);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.ME1312.SubServers.Bungee.Host;
|
||||
|
||||
import net.ME1312.SubServers.Bungee.Library.Callback;
|
||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidTemplateException;
|
||||
import net.ME1312.SubServers.Bungee.Library.Util;
|
||||
@ -170,148 +171,17 @@ public abstract class SubCreator {
|
||||
}
|
||||
}
|
||||
|
||||
public SubCreator() {
|
||||
/*
|
||||
if (!defaults) {
|
||||
defaults = true;
|
||||
addValidator("System", (template, match, string) -> {
|
||||
boolean validated;
|
||||
switch (match.toLowerCase()) {
|
||||
case "touppercase":
|
||||
string.set(string.get().toUpperCase());
|
||||
validated = true;
|
||||
break;
|
||||
case "tolowercase":
|
||||
string.set(string.get().toLowerCase());
|
||||
validated = true;
|
||||
break;
|
||||
case "toserverversion":
|
||||
try {
|
||||
Version version = new Version(string.get());
|
||||
if (template.getType() == ServerType.VANILLA) {
|
||||
String patch = "Patch";
|
||||
if (version.compareTo(new Version("1.12")) >= 0) patch += "-v2";
|
||||
version = new Version(version.toString() + " " + patch);
|
||||
} else if (template.getType() == ServerType.SPONGE) {
|
||||
Document spongexml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://files.minecraftforge.net/maven/org/spongepowered/spongeforge/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
Document forgexml = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(Util.readAll(new BufferedReader(new InputStreamReader(new URL("http://files.minecraftforge.net/maven/net/minecraftforge/forge/maven-metadata.xml").openStream(), Charset.forName("UTF-8")))))));
|
||||
|
||||
NodeList spnodeList = spongexml.getElementsByTagName("version");
|
||||
Version spversion = null;
|
||||
for (int i = 0; i < spnodeList.getLength(); i++) {
|
||||
Node node = spnodeList.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (node.getTextContent().startsWith(version.toString() + '-') && (spversion == null || new Version(node.getTextContent()).compareTo(spversion) >= 0)) {
|
||||
spversion = new Version(node.getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (spversion == null)
|
||||
throw new InvalidServerException("Cannot find sponge version for Minecraft " + version.toString());
|
||||
|
||||
NodeList mcfnodeList = forgexml.getElementsByTagName("version");
|
||||
Version mcfversion = null;
|
||||
for (int i = 0; i < mcfnodeList.getLength(); i++) {
|
||||
Node node = mcfnodeList.item(i);
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (node.getTextContent().contains(spversion.toString().split("\\-")[1]) && (mcfversion == null || new Version(node.getTextContent()).compareTo(mcfversion) >= 0)) {
|
||||
mcfversion = new Version(node.getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mcfversion == null)
|
||||
throw new InvalidServerException("Cannot find forge version for Sponge " + spversion.toString());
|
||||
|
||||
version = new Version(mcfversion.toString() + " " + spversion.toString());
|
||||
}
|
||||
string.set(version.toString());
|
||||
validated = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
validated = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
validated = false;
|
||||
}
|
||||
return validated;
|
||||
});
|
||||
addValidator("Integer", (template, match, string) -> {
|
||||
Matcher matcher = Pattern.compile("^([!<>=][=]?)(.*)$").matcher(match);
|
||||
String comparator = "";
|
||||
String other = "";
|
||||
while (matcher.find()) {
|
||||
comparator = matcher.group(1).toUpperCase();
|
||||
other = matcher.group(2);
|
||||
}
|
||||
|
||||
boolean validated;
|
||||
switch (comparator) {
|
||||
case "=":
|
||||
case "==":
|
||||
validated = string.get().equals(other);
|
||||
break;
|
||||
case "!":
|
||||
case "!=":
|
||||
validated = !string.get().equals(other);
|
||||
break;
|
||||
case "<":
|
||||
validated = new Version(string.get()).compareTo(new Version(other)) < 0;
|
||||
break;
|
||||
case "<=":
|
||||
validated = new Version(string.get()).compareTo(new Version(other)) <= 0;
|
||||
break;
|
||||
case ">":
|
||||
validated = new Version(string.get()).compareTo(new Version(other)) > 0;
|
||||
break;
|
||||
case ">=":
|
||||
validated = new Version(string.get()).compareTo(new Version(other)) >= 0;
|
||||
break;
|
||||
default:
|
||||
validated = false;
|
||||
}
|
||||
return validated;
|
||||
});
|
||||
addValidator("RegEx", (template, match, string) -> {
|
||||
Matcher matcher = Pattern.compile("^/(.*)/([iux]*)$").matcher(match);
|
||||
String pattern = "";
|
||||
char[] flags = new char[0];
|
||||
while (matcher.find()) {
|
||||
pattern = matcher.group(1);
|
||||
if (matcher.groupCount() >= 2)
|
||||
flags = matcher.group(2).toCharArray();
|
||||
}
|
||||
|
||||
int byteflags = 0x00;
|
||||
for (char flag : flags) {
|
||||
switch (flag) {
|
||||
case 'i':
|
||||
byteflags |= Pattern.CASE_INSENSITIVE;
|
||||
break;
|
||||
case 'u':
|
||||
byteflags |= Pattern.UNICODE_CASE;
|
||||
break;
|
||||
case 'x':
|
||||
byteflags |= Pattern.COMMENTS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (byteflags == 0x00) {
|
||||
matcher = Pattern.compile(pattern).matcher(match);
|
||||
} else {
|
||||
matcher = Pattern.compile(pattern, byteflags).matcher(match);
|
||||
}
|
||||
boolean validated = false;
|
||||
while (matcher.find()) {
|
||||
string.set(matcher.group());
|
||||
validated = true;
|
||||
}
|
||||
return validated;
|
||||
});
|
||||
}
|
||||
*/
|
||||
}
|
||||
/**
|
||||
* Create a SubServer
|
||||
*
|
||||
* @param player Player Creating
|
||||
* @param name Server Name
|
||||
* @param template Server Template
|
||||
* @param version Server Version
|
||||
* @param port Server Port Number
|
||||
* @return Success Status
|
||||
*/
|
||||
public abstract boolean create(UUID player, String name, ServerTemplate template, Version version, int port, Callback<SubServer> callback);
|
||||
|
||||
/**
|
||||
* Create a SubServer
|
||||
@ -323,7 +193,22 @@ public abstract class SubCreator {
|
||||
* @param port Server Port Number
|
||||
* @return Success Status
|
||||
*/
|
||||
public abstract boolean create(UUID player, String name, ServerTemplate template, Version version, int port);
|
||||
public boolean create(UUID player, String name, ServerTemplate template, Version version, int port) {
|
||||
return create(player, name, template, version, port, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SubServer
|
||||
*
|
||||
* @param name Server Name
|
||||
* @param template Server Template
|
||||
* @param version Server Version
|
||||
* @param port Server Port Number
|
||||
* @return Success Status
|
||||
*/
|
||||
public boolean create(String name, ServerTemplate template, Version version, int port, Callback<SubServer> callback) {
|
||||
return create(null, name, template, version, port, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SubServer
|
||||
|
@ -9,6 +9,22 @@ import java.util.*;
|
||||
* SubServer Interface
|
||||
*/
|
||||
public interface SubServer extends Server {
|
||||
|
||||
/**
|
||||
* SubServer Stop Action Class
|
||||
*/
|
||||
enum StopAction {
|
||||
NONE,
|
||||
RESTART,
|
||||
REMOVE_SERVER,
|
||||
DELETE_SERVER;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Command Storage Class
|
||||
*/
|
||||
@ -153,7 +169,9 @@ public interface SubServer extends Server {
|
||||
* @param edit Edits
|
||||
* @return Success Status
|
||||
*/
|
||||
int edit(UUID player, YAMLSection edit);
|
||||
default int edit(UUID player, YAMLSection edit) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the Server
|
||||
@ -161,7 +179,9 @@ public interface SubServer extends Server {
|
||||
* @param edit Edits
|
||||
* @return Success Status
|
||||
*/
|
||||
int edit(YAMLSection edit);
|
||||
default int edit(YAMLSection edit) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for the Server to Stop
|
||||
@ -205,16 +225,9 @@ public interface SubServer extends Server {
|
||||
* @see #edit(UUID, YAMLSection)
|
||||
* @return Edit Status
|
||||
*/
|
||||
boolean isEditable();
|
||||
|
||||
/**
|
||||
* Set if the Server should accept requests to edit()
|
||||
*
|
||||
* @param value Edit Status
|
||||
* @see #edit(YAMLSection)
|
||||
* @see #edit(UUID, YAMLSection)
|
||||
*/
|
||||
void setEditable(boolean value);
|
||||
default boolean isEditable() {
|
||||
return edit(new YAMLSection()) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server is Logging
|
||||
@ -278,18 +291,18 @@ public interface SubServer extends Server {
|
||||
void setStopCommand(String value);
|
||||
|
||||
/**
|
||||
* If the Server will Auto Restart on unexpected shutdowns
|
||||
* Get the action the Server will take when it stops
|
||||
*
|
||||
* @return Auto Restart Status
|
||||
* @return Stop Action
|
||||
*/
|
||||
boolean willAutoRestart();
|
||||
StopAction getStopAction();
|
||||
|
||||
/**
|
||||
* Set if the Server will Auto Restart on unexpected shutdowns
|
||||
* Set the action the Server will take when it stops
|
||||
*
|
||||
* @param value Value
|
||||
* @param action Stop Action
|
||||
*/
|
||||
void setAutoRestart(boolean value);
|
||||
void setStopAction(StopAction action);
|
||||
|
||||
/**
|
||||
* Toggles compatibility with other Servers
|
||||
@ -311,7 +324,7 @@ public interface SubServer extends Server {
|
||||
*
|
||||
* @return Incompatibility List
|
||||
*/
|
||||
List<SubServer> getIncompatibilities() ;
|
||||
List<SubServer> getIncompatibilities();
|
||||
|
||||
/**
|
||||
* Get incompatibility issues this server currently has
|
||||
@ -319,18 +332,4 @@ public interface SubServer extends Server {
|
||||
* @return Current Incompatibility List
|
||||
*/
|
||||
List<SubServer> getCurrentIncompatibilities();
|
||||
|
||||
/**
|
||||
* If the Server is Temporary
|
||||
*
|
||||
* @return Temporary Status
|
||||
*/
|
||||
boolean isTemporary();
|
||||
|
||||
/**
|
||||
* Set If the Server is Temporary (will start server if not running)
|
||||
*
|
||||
* @param value Value
|
||||
*/
|
||||
void setTemporary(boolean value);
|
||||
}
|
||||
|
@ -113,22 +113,21 @@ public abstract class SubServerContainer extends ServerContainer implements SubS
|
||||
YAMLSection sinfo = new YAMLSection(new Gson().fromJson(super.toString(), Map.class));
|
||||
sinfo.set("type", "SubServer");
|
||||
sinfo.set("host", getHost().getName());
|
||||
sinfo.set("enabled", isEnabled() && getHost().isEnabled());
|
||||
sinfo.set("enabled", isEnabled());
|
||||
sinfo.set("editable", isEditable());
|
||||
sinfo.set("log", isLogging());
|
||||
sinfo.set("dir", getPath());
|
||||
sinfo.set("exec", getExecutable());
|
||||
sinfo.set("running", isRunning());
|
||||
sinfo.set("stop-cmd", getStopCommand());
|
||||
sinfo.set("stop-action", getStopAction().toString());
|
||||
sinfo.set("auto-run", SubAPI.getInstance().getInternals().config.get().getSection("Servers").getSection(getName()).getKeys().contains("Run-On-Launch") && SubAPI.getInstance().getInternals().config.get().getSection("Servers").getSection(getName()).getBoolean("Run-On-Launch"));
|
||||
sinfo.set("auto-restart", willAutoRestart());
|
||||
List<String> incompatibleCurrent = new ArrayList<String>();
|
||||
List<String> incompatible = new ArrayList<String>();
|
||||
for (SubServer server : getCurrentIncompatibilities()) incompatibleCurrent.add(server.getName());
|
||||
for (SubServer server : getIncompatibilities()) incompatible.add(server.getName());
|
||||
sinfo.set("incompatible", incompatibleCurrent);
|
||||
sinfo.set("incompatible-list", incompatible);
|
||||
sinfo.set("temp", isTemporary());
|
||||
return sinfo.toJSON();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import java.util.*;
|
||||
* API-Safe SubServer Layout Class
|
||||
*/
|
||||
public abstract class SubServerController {
|
||||
private final net.ME1312.SubServers.Bungee.Host.SubServerContainer control;
|
||||
private final SubServerContainer control;
|
||||
|
||||
/**
|
||||
* Creates a SubServer
|
||||
@ -98,16 +98,6 @@ public abstract class SubServerController {
|
||||
SubServerController.this.setEnabled(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEditable() {
|
||||
return SubServerController.this.isEditable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEditable(boolean value) {
|
||||
SubServerController.this.setEditable(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLogging() {
|
||||
return SubServerController.this.isLogging();
|
||||
@ -149,23 +139,13 @@ public abstract class SubServerController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean willAutoRestart() {
|
||||
return SubServerController.this.willAutoRestart();
|
||||
public StopAction getStopAction() {
|
||||
return SubServerController.this.getStopAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoRestart(boolean value) {
|
||||
SubServerController.this.setAutoRestart(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTemporary() {
|
||||
return SubServerController.this.isTemporary();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTemporary(boolean value) {
|
||||
SubServerController.this.setTemporary(value);
|
||||
public void setStopAction(StopAction action) {
|
||||
SubServerController.this.setStopAction(action);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -256,7 +236,9 @@ public abstract class SubServerController {
|
||||
* @param edit Edits
|
||||
* @return Success Status
|
||||
*/
|
||||
public abstract int edit(UUID player, YAMLSection edit);
|
||||
public int edit(UUID player, YAMLSection edit) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the Server
|
||||
@ -265,7 +247,7 @@ public abstract class SubServerController {
|
||||
* @return Success Status
|
||||
*/
|
||||
public int edit(YAMLSection edit) {
|
||||
return edit(null, edit);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,24 +285,6 @@ public abstract class SubServerController {
|
||||
*/
|
||||
public abstract void setEnabled(boolean value);
|
||||
|
||||
/**
|
||||
* If the Server is accepting requests to edit()
|
||||
*
|
||||
* @see #edit(YAMLSection)
|
||||
* @see #edit(UUID, YAMLSection)
|
||||
* @return Edit Status
|
||||
*/
|
||||
public abstract boolean isEditable();
|
||||
|
||||
/**
|
||||
* Set if the Server should accept requests to edit()
|
||||
*
|
||||
* @param value Edit Status
|
||||
* @see #edit(YAMLSection)
|
||||
* @see #edit(UUID, YAMLSection)
|
||||
*/
|
||||
public abstract void setEditable(boolean value);
|
||||
|
||||
/**
|
||||
* If the Server is Logging
|
||||
*
|
||||
@ -376,32 +340,18 @@ public abstract class SubServerController {
|
||||
public abstract void setStopCommand(String value);
|
||||
|
||||
/**
|
||||
* If the Server will Auto Restart on unexpected shutdowns
|
||||
* Get the action the Server will take when it stops
|
||||
*
|
||||
* @return Auto Restart Status
|
||||
* @return Stop Action
|
||||
*/
|
||||
public abstract boolean willAutoRestart();
|
||||
public abstract SubServer.StopAction getStopAction();
|
||||
|
||||
/**
|
||||
* Set if the Server will Auto Restart on unexpected shutdowns
|
||||
* Set the action the Server will take when it stops
|
||||
*
|
||||
* @param value Value
|
||||
* @param action Stop Action
|
||||
*/
|
||||
public abstract void setAutoRestart(boolean value);
|
||||
|
||||
/**
|
||||
* If the Server is Temporary
|
||||
*
|
||||
* @return Temporary Status
|
||||
*/
|
||||
public abstract boolean isTemporary();
|
||||
|
||||
/**
|
||||
* Set If the Server is Temporary (will start server if not running)
|
||||
*
|
||||
* @param value Value
|
||||
*/
|
||||
public abstract void setTemporary(boolean value);
|
||||
public abstract void setStopAction(SubServer.StopAction action);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -29,8 +29,8 @@ Servers:
|
||||
Directory: './Example'
|
||||
Executable: 'java -Djline.terminal=jline.UnsupportedTerminal -jar Spigot.jar'
|
||||
Stop-Command: 'stop'
|
||||
Stop-Action: 'NONE'
|
||||
Run-On-Launch: false
|
||||
Auto-Restart: false
|
||||
Restricted: false
|
||||
Incompatible: []
|
||||
Hidden: false
|
@ -54,6 +54,7 @@ Lang:
|
||||
'Command.Start': '&aSubServers &2&l\u00BB&a Starting SubServer'
|
||||
'Command.Start.Unknown': '&cSubServers &4&l\u00BB&c There is no Server with that name'
|
||||
'Command.Start.Invalid': '&cSubServers &4&l\u00BB&c That Server is not a SubServer'
|
||||
'Command.Start.Host-Unavailable': '&cSubServers &4&l\u00BB&c That SubServer\u0027s Host is not available'
|
||||
'Command.Start.Host-Disabled': '&cSubServers &4&l\u00BB&c That SubServer\u0027s Host is not enabled'
|
||||
'Command.Start.Server-Disabled': '&cSubServers &4&l\u00BB&c That SubServer is not enabled'
|
||||
'Command.Start.Server-Incompatible': '&cSubServers &4&l\u00BB&c That SubServer cannot start while these server(s) are running: &4$str$'
|
||||
@ -73,7 +74,10 @@ Lang:
|
||||
'Command.Creator': '&aSubServers &2&l\u00BB&a Creating SubServer'
|
||||
'Command.Creator.Exists': '&cSubServers &4&l\u00BB&c There is already a SubServer with that name'
|
||||
'Command.Creator.Unknown-Host': '&cSubServers &4&l\u00BB&c There is no Host with that name'
|
||||
'Command.Creator.Invalid-Template': '&cSubServers &4&l\u00BB&c There is no Template with that name'
|
||||
'Command.Creator.Host-Unavailable': '&cSubServers &4&l\u00BB&c That Host is not available'
|
||||
'Command.Creator.Host-Disabled': '&cSubServers &4&l\u00BB&c That Host is not enabled'
|
||||
'Command.Creator.Unknown-Template': '&cSubServers &4&l\u00BB&c There is no Template with that name'
|
||||
'Command.Creator.Template-Disabled': '&cSubServers &4&l\u00BB&c That Template is not enabled'
|
||||
'Command.Creator.Invalid-Version': '&cSubServers &4&l\u00BB&c SubCreator cannot create servers before Minecraft 1.8'
|
||||
'Command.Creator.Invalid-Port': '&cSubServers &4&l\u00BB&c Invalid Port Number'
|
||||
'Interface.Generic.Back': '&cBack'
|
||||
@ -92,6 +96,7 @@ Lang:
|
||||
'Interface.Proxy-Menu.Proxy-Redis': '&7Redis Only'
|
||||
'Interface.Proxy-Menu.Proxy-Disconnected': '&4Disconnected'
|
||||
'Interface.Host-Menu.Title': 'Host Menu'
|
||||
'Interface.Host-Menu.Host-Unavailable': '&4Unavailable'
|
||||
'Interface.Host-Menu.Host-Disabled': '&4Disabled'
|
||||
'Interface.Host-Menu.Host-Server-Count': '&9$int$ Server(s)'
|
||||
'Interface.Host-Menu.No-Hosts': '&c&oThere are No Hosts'
|
||||
|
@ -173,7 +173,7 @@ public class Metrics {
|
||||
int playerAmount = plugin.getOnlineCount();
|
||||
playerAmount = playerAmount > 500 ? 500 : playerAmount;
|
||||
int onlineMode = plugin.getConfig().isOnlineMode() ? 1 : 0;
|
||||
String bungeecordVersion = (plugin.getName().equals("SubServers.Bungee"))?"SubServers-Bungee-Patched":plugin.getVersion();
|
||||
String bungeecordVersion = (plugin.getName().equals("SubServers Platform"))?"SubServers-Bungee-Patched":plugin.getVersion();
|
||||
int managedServers = plugin.getServers().size();
|
||||
|
||||
// OS/Java specific data
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.SubServers.Bungee.Host.SubCreator;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Bungee.Network.Client;
|
||||
@ -59,13 +60,18 @@ public class PacketCreateServer implements PacketIn, PacketOut {
|
||||
client.sendPacket(new PacketCreateServer(4, "There is already a subserver with that name", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (!plugin.hosts.keySet().contains(data.getSection("creator").getString("host").toLowerCase())) {
|
||||
client.sendPacket(new PacketCreateServer(5, "There is no Host with that name", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (!plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).getCreator().getTemplates().keySet().contains(data.getSection("creator").getString("template").toLowerCase()) ||
|
||||
!plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).getCreator().getTemplate(data.getSection("creator").getString("template")).isEnabled()) {
|
||||
client.sendPacket(new PacketCreateServer(6, "There is no template with that name", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (!plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).isAvailable()) {
|
||||
client.sendPacket(new PacketStartServer(6, "That SubServer's Host is not available", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (!plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).isEnabled()) {
|
||||
client.sendPacket(new PacketStartServer(7, "That SubServer's Host is not enabled", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (!plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).getCreator().getTemplates().keySet().contains(data.getSection("creator").getString("template").toLowerCase())) {
|
||||
client.sendPacket(new PacketCreateServer(8, "There is no template with that name", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (!plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).getCreator().getTemplate(data.getSection("creator").getString("template")).isEnabled()) {
|
||||
client.sendPacket(new PacketCreateServer(8, "That Template is not enabled", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (new Version("1.8").compareTo(new Version(data.getSection("creator").getString("version"))) > 0) {
|
||||
client.sendPacket(new PacketCreateServer(7, "SubCreator cannot create servers before Minecraft 1.8", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
client.sendPacket(new PacketCreateServer(10, "SubCreator cannot create servers before Minecraft 1.8", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (data.getSection("creator").getInt("port") <= 0 || data.getSection("creator").getInt("port") > 65535) {
|
||||
client.sendPacket(new PacketCreateServer(8, "Invalid Port Number", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
client.sendPacket(new PacketCreateServer(11, "Invalid Port Number", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else {
|
||||
if (plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).getCreator().create((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, data.getSection("creator").getString("name"), plugin.hosts.get(data.getSection("creator").getString("host").toLowerCase()).getCreator().getTemplate(data.getSection("creator").getString("template")), new Version(data.getSection("creator").getString("version")), data.getSection("creator").getInt("port"))) {
|
||||
if (data.contains("wait") && data.getBoolean("wait")) {
|
||||
|
@ -1,73 +0,0 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.SubServers.Bungee.Host.Server;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||
import net.ME1312.SubServers.Bungee.Library.Util;
|
||||
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Bungee.Network.Client;
|
||||
import net.ME1312.SubServers.Bungee.Network.PacketIn;
|
||||
import net.ME1312.SubServers.Bungee.Network.PacketOut;
|
||||
import net.ME1312.SubServers.Bungee.SubPlugin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Edit Server Packet
|
||||
*/
|
||||
public class PacketEditServer implements PacketIn, PacketOut {
|
||||
private SubPlugin plugin;
|
||||
private int response;
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* New PacketEditServer (In)
|
||||
*
|
||||
* @param plugin SubPlugin
|
||||
*/
|
||||
public PacketEditServer(SubPlugin plugin) {
|
||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketEditServer (Out)
|
||||
*
|
||||
* @param response Response ID
|
||||
* @param id Receiver ID
|
||||
*/
|
||||
public PacketEditServer(int response, String id) {
|
||||
if (Util.isNull(response)) throw new NullPointerException();
|
||||
this.response = response;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YAMLSection generate() {
|
||||
YAMLSection json = new YAMLSection();
|
||||
if (id != null) json.set("id", id);
|
||||
json.set("r", response);
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, YAMLSection data) {
|
||||
try {
|
||||
Map<String, Server> servers = plugin.api.getServers();
|
||||
if (!servers.keySet().contains(data.getRawString("server").toLowerCase()) || !(servers.get(data.getRawString("server").toLowerCase()) instanceof SubServer)) {
|
||||
client.sendPacket(new PacketEditServer(0, (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else {
|
||||
new Thread(() -> client.sendPacket(new PacketEditServer(((SubServer) servers.get(data.getRawString("server").toLowerCase())).edit((data.contains("player"))?UUID.fromString(data.getRawString("player")):null, data.getSection("edit").clone()) * -1, (data.contains("id"))?data.getRawString("id"):null))).start();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
client.sendPacket(new PacketEditServer(0, (data.contains("id"))?data.getRawString("id"):null));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return new Version("2.11.0a");
|
||||
}
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
package net.ME1312.SubServers.Bungee.Network.Packet;
|
||||
|
||||
import net.ME1312.SubServers.Bungee.Host.Host;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubLogFilter;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubLogger;
|
||||
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
||||
import net.ME1312.SubServers.Bungee.Library.Config.YAMLSection;
|
||||
import net.ME1312.SubServers.Bungee.Library.NamedContainer;
|
||||
import net.ME1312.SubServers.Bungee.Library.Util;
|
||||
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Bungee.Network.Client;
|
||||
import net.ME1312.SubServers.Bungee.Network.PacketIn;
|
||||
import net.ME1312.SubServers.Bungee.Network.PacketOut;
|
||||
import net.ME1312.SubServers.Bungee.SubPlugin;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Server Log Listener Packet
|
||||
*/
|
||||
public class PacketListenLog implements PacketIn, PacketOut {
|
||||
private static HashMap<String, NamedContainer<SubLogger, SubLogFilter>> filters = new HashMap<String, NamedContainer<SubLogger, SubLogFilter>>();
|
||||
private SubPlugin plugin;
|
||||
private SubLogger.LogMessage[] lines;
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* New PacketListenServerLog (In)
|
||||
*
|
||||
* @param plugin SubPlugin
|
||||
*/
|
||||
public PacketListenLog(SubPlugin plugin) {
|
||||
if (Util.isNull(plugin)) throw new NullPointerException();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New PacketListenServerLog (Out)
|
||||
*
|
||||
* @param line Message
|
||||
* @param id Receiver ID
|
||||
*/
|
||||
public PacketListenLog(String id, SubLogger.LogMessage... line) {
|
||||
if (Util.isNull(id, line)) throw new NullPointerException();
|
||||
this.lines = line;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YAMLSection generate() {
|
||||
YAMLSection add = new YAMLSection();
|
||||
if (id != null) add.set("id", id);
|
||||
LinkedList<String> lines = new LinkedList<String>();
|
||||
for (SubLogger.LogMessage line : this.lines) lines.add(new SimpleDateFormat("hh:mm:ss").format(line.getDate()) + " [" + line.getLevel().getLocalizedName() + "] " + line.getMessage());
|
||||
add.set("lines", lines);
|
||||
return add;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Client client, YAMLSection data) {
|
||||
if (data != null && data.contains("id")) {
|
||||
if (data.contains("server")) {
|
||||
if (data.getRawString("server").length() == 0) {
|
||||
unregister(data.getRawString("id"));
|
||||
} else {
|
||||
Map<String, SubServer> servers = plugin.api.getSubServers();
|
||||
if (servers.keySet().contains(data.getRawString("server").toLowerCase())) {
|
||||
register(client, data.getRawString("id"), servers.get(data.getRawString("server").toLowerCase()).getLogger());
|
||||
}
|
||||
}
|
||||
} else if (data.contains("creator")) {
|
||||
if (data.getRawString("creator").length() == 0) {
|
||||
unregister(data.getRawString("id"));
|
||||
} else {
|
||||
Map<String, Host> hosts = plugin.api.getHosts();
|
||||
if (hosts.keySet().contains(data.getRawString("creator").toLowerCase())) {
|
||||
register(client, data.getRawString("id"), hosts.get(data.getRawString("creator").toLowerCase()).getCreator().getLogger(data.getRawString("name")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void register(Client client, String id, SubLogger logger) {
|
||||
client.sendPacket(new PacketListenLog(id, logger.getMessageHistory().toArray(new SubLogger.LogMessage[logger.getMessageHistory().size()])));
|
||||
SubLogFilter filter = new SubLogFilter() {
|
||||
@Override
|
||||
public void start() {
|
||||
if (client.getConnection().isClosed()) {
|
||||
unregister(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean log(Level level, String message) {
|
||||
if (client.getConnection().isClosed()) {
|
||||
unregister(id);
|
||||
} else {
|
||||
client.sendPacket(new PacketListenLog(id, new SubLogger.LogMessage(level, message)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (client.getConnection().isClosed()) {
|
||||
unregister(id);
|
||||
}
|
||||
}
|
||||
};
|
||||
filters.put(id, new NamedContainer<SubLogger, SubLogFilter>(logger, filter));
|
||||
logger.registerFilter(filter);
|
||||
}
|
||||
|
||||
private void unregister(String id) {
|
||||
if (filters.keySet().contains(id)) {
|
||||
filters.get(id).name().unregisterFilter(filters.get(id).get());
|
||||
filters.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return new Version("2.11.0a");
|
||||
}
|
||||
}
|
@ -63,19 +63,21 @@ public class PacketStartServer implements PacketIn, PacketOut {
|
||||
client.sendPacket(new PacketStartServer(3, "There is no server with that name", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (!(servers.get(data.getRawString("server").toLowerCase()) instanceof SubServer)) {
|
||||
client.sendPacket(new PacketStartServer(4, "That Server is not a SubServer", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (!((SubServer) servers.get(data.getRawString("server").toLowerCase())).getHost().isAvailable()) {
|
||||
client.sendPacket(new PacketStartServer(5, "That SubServer's Host is not available", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (!((SubServer) servers.get(data.getRawString("server").toLowerCase())).getHost().isEnabled()) {
|
||||
client.sendPacket(new PacketStartServer(5, "That SubServer's Host is not enabled", (data.contains("id"))?data.getRawString("id"):null));
|
||||
client.sendPacket(new PacketStartServer(6, "That SubServer's Host is not enabled", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (!((SubServer) servers.get(data.getRawString("server").toLowerCase())).isEnabled()) {
|
||||
client.sendPacket(new PacketStartServer(6, "That SubServer is not enabled", (data.contains("id"))?data.getRawString("id"):null));
|
||||
client.sendPacket(new PacketStartServer(7, "That SubServer is not enabled", (data.contains("id"))?data.getRawString("id"):null));
|
||||
} else if (((SubServer) servers.get(data.getRawString("server").toLowerCase())).isRunning()) {
|
||||
client.sendPacket(new PacketStartServer(7, "That SubServer is already running", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
client.sendPacket(new PacketStartServer(8, "That SubServer is already running", (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else if (((SubServer) servers.get(data.getRawString("server").toLowerCase())).getCurrentIncompatibilities().size() != 0) {
|
||||
String list = "";
|
||||
for (SubServer server : ((SubServer) servers.get(data.getRawString("server").toLowerCase())).getCurrentIncompatibilities()) {
|
||||
if (list.length() != 0) list += ", ";
|
||||
list += server.getName();
|
||||
}
|
||||
client.sendPacket(new PacketStartServer(8, "Cannot start SubServer while these servers are running: " + list, (data.contains("id")) ? data.getRawString("id") : null));
|
||||
client.sendPacket(new PacketStartServer(9, "Cannot start SubServer while these servers are running: " + list, (data.contains("id")) ? data.getRawString("id") : null));
|
||||
} else {
|
||||
if (((SubServer) servers.get(data.getRawString("server").toLowerCase())).start((data.contains("player"))?UUID.fromString(data.getRawString("player")):null)) {
|
||||
client.sendPacket(new PacketStartServer(0, "Starting SubServer", (data.contains("id"))?data.getRawString("id"):null));
|
||||
|
@ -97,7 +97,6 @@ public final class SubDataServer {
|
||||
registerPacket(new PacketDownloadPlayerList(plugin), "SubServers", "DownloadPlayerList");
|
||||
registerPacket(new PacketDownloadProxyInfo(plugin), "SubServers", "DownloadProxyInfo");
|
||||
registerPacket(new PacketDownloadServerInfo(plugin), "SubServers", "DownloadServerInfo");
|
||||
registerPacket(new PacketEditServer(plugin), "SubServers", "EditServer");
|
||||
registerPacket(new PacketExAddServer(), "SubServers", "ExAddServer");
|
||||
registerPacket(new PacketExConfigureHost(plugin), "SubServers", "ExConfigureHost");
|
||||
registerPacket(new PacketExCreateServer(null), "SubServers", "ExCreateServer");
|
||||
@ -109,7 +108,6 @@ public final class SubDataServer {
|
||||
registerPacket(new PacketLinkExHost(plugin), "SubServers", "LinkExHost");
|
||||
registerPacket(new PacketLinkProxy(plugin), "SubServers", "LinkProxy");
|
||||
registerPacket(new PacketLinkServer(plugin), "SubServers", "LinkServer");
|
||||
registerPacket(new PacketListenLog(plugin), "SubServers", "ListenLog");
|
||||
registerPacket(new PacketStartServer(plugin), "SubServers", "StartServer");
|
||||
registerPacket(new PacketStopServer(plugin), "SubServers", "StopServer");
|
||||
|
||||
@ -124,7 +122,6 @@ public final class SubDataServer {
|
||||
registerPacket(PacketDownloadPlayerList.class, "SubServers", "DownloadPlayerList");
|
||||
registerPacket(PacketDownloadProxyInfo.class, "SubServers", "DownloadProxyInfo");
|
||||
registerPacket(PacketDownloadServerInfo.class, "SubServers", "DownloadServerInfo");
|
||||
registerPacket(PacketEditServer.class, "SubServers", "EditServer");
|
||||
registerPacket(PacketExAddServer.class, "SubServers", "ExAddServer");
|
||||
registerPacket(PacketExConfigureHost.class, "SubServers", "ExConfigureHost");
|
||||
registerPacket(PacketExCreateServer.class, "SubServers", "ExCreateServer");
|
||||
@ -134,7 +131,6 @@ public final class SubDataServer {
|
||||
registerPacket(PacketLinkExHost.class, "SubServers", "LinkExHost");
|
||||
registerPacket(PacketLinkProxy.class, "SubServers", "LinkProxy");
|
||||
registerPacket(PacketLinkServer.class, "SubServers", "LinkServer");
|
||||
registerPacket(PacketListenLog.class, "SubServers", "ListenLog");
|
||||
registerPacket(PacketOutRunEvent.class, "SubServers", "RunEvent");
|
||||
registerPacket(PacketOutReload.class, "SubServers", "Reload");
|
||||
registerPacket(PacketOutReset.class, "SubServers", "Reset");
|
||||
|
@ -92,6 +92,7 @@ public final class SubCommand extends CommandX {
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (args.length > 1) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "*":
|
||||
case "all":
|
||||
case "system":
|
||||
case "bungee":
|
||||
@ -150,11 +151,13 @@ public final class SubCommand extends CommandX {
|
||||
Server server = servers.get(name.toLowerCase());
|
||||
if (!(servers.get(name.toLowerCase()) instanceof SubServer)) {
|
||||
message += ChatColor.WHITE;
|
||||
} else if (((SubServer) server).isTemporary()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
message += ChatColor.GREEN;
|
||||
} else if (((SubServer) server).getHost().isEnabled() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.GREEN;
|
||||
}
|
||||
} else if (((SubServer) server).getHost().isAvailable() && ((SubServer) server).getHost().isEnabled() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
@ -173,7 +176,7 @@ public final class SubCommand extends CommandX {
|
||||
sender.sendMessage("SubServers > Host/SubServer List:");
|
||||
for (Host host : plugin.api.getHosts().values()) {
|
||||
String message = " ";
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
@ -181,10 +184,12 @@ public final class SubCommand extends CommandX {
|
||||
message += host.getDisplayName() + " (" + host.getAddress().getHostAddress() + ((host.getName().equals(host.getDisplayName()))?"":ChatColor.stripColor(div)+host.getName()) + ")" + ChatColor.RESET + ": ";
|
||||
for (SubServer subserver : host.getSubServers().values()) {
|
||||
if (i != 0) message += div;
|
||||
if (subserver.isTemporary()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (subserver.isRunning()) {
|
||||
message += ChatColor.GREEN;
|
||||
if (subserver.isRunning()) {
|
||||
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.GREEN;
|
||||
}
|
||||
} else if (subserver.getHost().isEnabled() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
@ -252,12 +257,9 @@ public final class SubCommand extends CommandX {
|
||||
sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getPlayers().size() + " online");
|
||||
}
|
||||
sender.sendMessage(" -> MOTD: " + ChatColor.WHITE + ChatColor.stripColor(server.getMotd()));
|
||||
if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(" -> Stop Action: " + ChatColor.WHITE + ((SubServer) server).getStopAction().toString());
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + server.getSignature());
|
||||
if (server instanceof SubServer) {
|
||||
sender.sendMessage(" -> Logging: " + ((((SubServer) server).isLogging())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (((SubServer) server).isTemporary()) sender.sendMessage(" -> Temporary: " + ChatColor.GREEN + "yes");
|
||||
else sender.sendMessage(" -> Auto Restart: " + ((((SubServer) server).willAutoRestart())?ChatColor.GREEN+"enabled":ChatColor.RED+"disabled"));
|
||||
}
|
||||
if (server instanceof SubServer) sender.sendMessage(" -> Logging: " + ((((SubServer) server).isLogging())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Restricted: " + ((server.isRestricted())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (server instanceof SubServer && ((SubServer) server).getIncompatibilities().size() > 0) {
|
||||
List<String> current = new ArrayList<String>();
|
||||
@ -293,6 +295,7 @@ public final class SubCommand extends CommandX {
|
||||
if (host != null) {
|
||||
sender.sendMessage("SubServers > Info on Host: " + ChatColor.WHITE + host.getDisplayName());
|
||||
if (!host.getName().equals(host.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + host.getName());
|
||||
sender.sendMessage(" -> Available: " + ((host.isAvailable())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Enabled: " + ((host.isEnabled())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Address: " + ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
if (host instanceof ClientHandler && ((ClientHandler) host).getSubData() != null) sender.sendMessage(" -> Connected: " + ChatColor.GREEN + "yes");
|
||||
@ -362,6 +365,8 @@ public final class SubCommand extends CommandX {
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
} else if (!(servers.get(args[1].toLowerCase()) instanceof SubServer)) {
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
} else if (!((SubServer) servers.get(args[1].toLowerCase())).getHost().isAvailable()) {
|
||||
sender.sendMessage("SubServers > That SubServer's Host is not available");
|
||||
} else if (!((SubServer) servers.get(args[1].toLowerCase())).getHost().isEnabled()) {
|
||||
sender.sendMessage("SubServers > That SubServer's Host is not enabled");
|
||||
} else if (!((SubServer) servers.get(args[1].toLowerCase())).isEnabled()) {
|
||||
@ -464,8 +469,14 @@ public final class SubCommand extends CommandX {
|
||||
sender.sendMessage("SubServers > There is already a SubServer with that name");
|
||||
} else if (!plugin.hosts.keySet().contains(args[2].toLowerCase())) {
|
||||
sender.sendMessage("SubServers > There is no host with that name");
|
||||
} else if (!plugin.hosts.get(args[2].toLowerCase()).getCreator().getTemplates().keySet().contains(args[3].toLowerCase()) || !plugin.hosts.get(args[2].toLowerCase()).getCreator().getTemplate(args[3]).isEnabled()) {
|
||||
} else if (!plugin.hosts.get(args[2].toLowerCase()).isAvailable()) {
|
||||
sender.sendMessage("SubServers > That Host is not available");
|
||||
} else if (!plugin.hosts.get(args[2].toLowerCase()).isEnabled()) {
|
||||
sender.sendMessage("SubServers > That Host is not enabled");
|
||||
} else if (!plugin.hosts.get(args[2].toLowerCase()).getCreator().getTemplates().keySet().contains(args[3].toLowerCase())) {
|
||||
sender.sendMessage("SubServers > There is no template with that name");
|
||||
} else if (!plugin.hosts.get(args[2].toLowerCase()).getCreator().getTemplate(args[3]).isEnabled()) {
|
||||
sender.sendMessage("SubServers > That Template is not enabled");
|
||||
} else if (new Version("1.8").compareTo(new Version(args[4])) > 0) {
|
||||
sender.sendMessage("SubServers > SubCreator cannot create servers before Minecraft 1.8");
|
||||
} else if (Util.isException(() -> Integer.parseInt(args[5])) || Integer.parseInt(args[5]) <= 0 || Integer.parseInt(args[5]) > 65535) {
|
||||
|
@ -416,8 +416,9 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
edits.set("exec", config.get().getSection("Servers").getSection(name).getRawString("Executable"));
|
||||
if (!config.get().getSection("Servers").getSection(name).getRawString("Stop-Command").equals(server.getStopCommand()))
|
||||
edits.set("stop-cmd", config.get().getSection("Servers").getSection(name).getRawString("Stop-Command"));
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Auto-Restart") != server.willAutoRestart())
|
||||
edits.set("auto-restart", config.get().getSection("Servers").getSection(name).getBoolean("Auto-Restart"));
|
||||
SubServer.StopAction action = Util.getDespiteException(() -> SubServer.StopAction.valueOf(config.get().getSection("Servers").getSection(name).getRawString("Stop-Action", "NONE").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
if (action != null && action != server.getStopAction())
|
||||
edits.set("stop-action", action.toString());
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Restricted") != server.isRestricted())
|
||||
edits.set("restricted", config.get().getSection("Servers").getSection(name).getBoolean("Restricted"));
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Hidden") != server.isHidden())
|
||||
@ -439,7 +440,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
server = this.hosts.get(config.get().getSection("Servers").getSection(name).getString("Host").toLowerCase()).addSubServer(name, config.get().getSection("Servers").getSection(name).getBoolean("Enabled"),
|
||||
config.get().getSection("Servers").getSection(name).getInt("Port"), config.get().getSection("Servers").getSection(name).getColoredString("Motd", '&'), config.get().getSection("Servers").getSection(name).getBoolean("Log"),
|
||||
config.get().getSection("Servers").getSection(name).getRawString("Directory"), new Executable(config.get().getSection("Servers").getSection(name).getRawString("Executable")), config.get().getSection("Servers").getSection(name).getRawString("Stop-Command"),
|
||||
config.get().getSection("Servers").getSection(name).getBoolean("Hidden"), config.get().getSection("Servers").getSection(name).getBoolean("Restricted"), false);
|
||||
config.get().getSection("Servers").getSection(name).getBoolean("Hidden"), config.get().getSection("Servers").getSection(name).getBoolean("Restricted"));
|
||||
} else { // Server doesn't need to reset
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Enabled") != server.isEnabled())
|
||||
server.setEnabled(config.get().getSection("Servers").getSection(name).getBoolean("Enabled"));
|
||||
@ -454,8 +455,9 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Hidden") != server.isHidden())
|
||||
server.setHidden(config.get().getSection("Servers").getSection(name).getBoolean("Hidden"));
|
||||
} // Apply these changes regardless of reset
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Auto-Restart") != server.willAutoRestart())
|
||||
server.setAutoRestart(config.get().getSection("Servers").getSection(name).getBoolean("Auto-Restart"));
|
||||
SubServer.StopAction action = Util.getDespiteException(() -> SubServer.StopAction.valueOf(config.get().getSection("Servers").getSection(name).getRawString("Stop-Action", "NONE").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
if (action != null && action != server.getStopAction())
|
||||
server.setStopAction(action);
|
||||
if (!status && config.get().getSection("Servers").getSection(name).getBoolean("Run-On-Launch"))
|
||||
autorun.add(name.toLowerCase());
|
||||
if (config.get().getSection("Servers").getSection(name).getKeys().contains("Display") && ((config.get().getSection("Servers").getSection(name).getRawString("Display").length() == 0 && !server.getDisplayName().equals(server.getName())) || !config.get().getSection("Servers").getSection(name).getRawString("Display").equals(server.getDisplayName())))
|
||||
@ -465,7 +467,6 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
for (String group : config.get().getSection("Servers").getSection(name).getStringList("Group")) server.addGroup(group);
|
||||
}
|
||||
} // Apply these changes regardless of edit/reset
|
||||
if (config.get().getSection("Servers").getSection(name).getBoolean("Editable", true) != server.isEditable()) server.setEditable(config.get().getSection("Servers").getSection(name).getBoolean("Editable", true));
|
||||
if (config.get().getSection("Servers").getSection(name).getKeys().contains("Extra")) for (String extra : config.get().getSection("Servers").getSection(name).getSection("Extra").getKeys()) server.addExtra(extra, config.get().getSection("Servers").getSection(name).getSection("Extra").getObject(extra));
|
||||
ukeys.add(name.toLowerCase());
|
||||
subservers++;
|
||||
@ -660,7 +661,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return (isPatched)?"SubServers.Bungee":super.getName();
|
||||
return (isPatched)?"SubServers Platform":super.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,7 +334,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
if (listening.get()) if (!json.getString("server").equalsIgnoreCase((String) gui.lastVisitedObjects[0])) {
|
||||
PacketInRunEvent.callback("SubStoppedEvent", this);
|
||||
} else {
|
||||
gui.reopen();
|
||||
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 5);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
enabled = (((i & 1) == 0) ? new NamedContainer<>("BLUE_STAINED_GLASS_PANE", (short) 3) : new NamedContainer<>("LIGHT_BLUE_STAINED_GLASS_PANE", (short) 11));
|
||||
disabled = (((i & 1) == 0) ? new NamedContainer<>("MAGENTA_STAINED_GLASS_PANE", (short) 2) : new NamedContainer<>("RED_STAINED_GLASS_PANE", (short) 14));
|
||||
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
block = createItem("STAINED_GLASS_PANE", enabled.name(), enabled.get());
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + host.getDisplayName());
|
||||
@ -138,7 +138,8 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!host.getName().equals(host.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + host.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
|
||||
if (!host.isAvailable()) lore.add(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Unavailable"));
|
||||
else lore.add(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
|
||||
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) lore.add(ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
blockMeta.setLore(lore);
|
||||
}
|
||||
@ -278,7 +279,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(27, block);
|
||||
inv.setItem(28, block);
|
||||
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + host.getDisplayName());
|
||||
@ -295,7 +296,8 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!host.getName().equals(host.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + host.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
|
||||
if (!host.isAvailable()) lore.add(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Unavailable"));
|
||||
else lore.add(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
|
||||
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) lore.add(ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
blockMeta.setLore(lore);
|
||||
}
|
||||
@ -844,24 +846,17 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Invalid"));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else if (((SubServer) server).isTemporary()) {
|
||||
block = createItem("STAINED_GLASS_PANE", temp.name(), temp.get());
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + server.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!server.getName().equals(server.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + server.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
block = createItem("STAINED_GLASS_PANE", online.name(), online.get());
|
||||
NamedContainer<String, Short> blockinfo = (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER)?temp:online;
|
||||
block = createItem("STAINED_GLASS_PANE", blockinfo.name(), blockinfo.get());
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GREEN + server.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!server.getName().equals(server.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + server.getName());
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + server.getDisplayName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
|
||||
} else blockMeta.setDisplayName(ChatColor.GREEN + server.getDisplayName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
@ -989,176 +984,172 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
windowHistory.add(() -> subserverAdmin(name));
|
||||
if (subserver == null) {
|
||||
if (hasHistory()) back();
|
||||
} else {
|
||||
setDownloading(null);
|
||||
lastVisitedObjects[0] = name;
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
} else subserver.getHost(host -> {
|
||||
if (host == null) {
|
||||
if (hasHistory()) back();
|
||||
} else {
|
||||
setDownloading(null);
|
||||
lastVisitedObjects[0] = name;
|
||||
ItemStack block;
|
||||
ItemMeta blockMeta;
|
||||
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
|
||||
ItemMeta divMeta = div.getItemMeta();
|
||||
divMeta.setDisplayName(ChatColor.RESET.toString());
|
||||
div.setItemMeta(divMeta);
|
||||
|
||||
Inventory inv = Bukkit.createInventory(null, 36, plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").replace("$str$", subserver.getDisplayName()));
|
||||
Inventory inv = Bukkit.createInventory(null, 36, plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").replace("$str$", subserver.getDisplayName()));
|
||||
|
||||
int i = 0;
|
||||
while (i < inv.getSize()) {
|
||||
inv.setItem(i, div);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
int i = 0;
|
||||
while (i < inv.getSize()) {
|
||||
inv.setItem(i, div);
|
||||
i++;
|
||||
}
|
||||
i = 0;
|
||||
|
||||
if (subserver.isRunning()) {
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
if (subserver.isRunning()) {
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.terminate." + name.toLowerCase())));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate"));
|
||||
}
|
||||
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(1, block);
|
||||
inv.setItem(10, block);
|
||||
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.stop.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.stop." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.stop." + name.toLowerCase())));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "MAGENTA_STAINED_GLASS_PANE", (short) 2);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop"));
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(2, block);
|
||||
inv.setItem(3, block);
|
||||
inv.setItem(11, block);
|
||||
inv.setItem(12, block);
|
||||
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.command.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.command." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.command." + name.toLowerCase())));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command"));
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(5, block);
|
||||
inv.setItem(6, block);
|
||||
inv.setItem(7, block);
|
||||
inv.setItem(14, block);
|
||||
inv.setItem(15, block);
|
||||
inv.setItem(16, block);
|
||||
} else {
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.start.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.start." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.start." + name.toLowerCase())));
|
||||
} else if (!host.isAvailable() || !host.isEnabled() || !subserver.isEnabled() || subserver.getCurrentIncompatibilities().size() != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start"));
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(3, block);
|
||||
inv.setItem(4, block);
|
||||
inv.setItem(5, block);
|
||||
inv.setItem(12, block);
|
||||
inv.setItem(13, block);
|
||||
inv.setItem(14, block);
|
||||
}
|
||||
|
||||
if (!host.isAvailable() || !host.isEnabled() || !subserver.isEnabled() || subserverPlugins.size() <= 0) {
|
||||
block = div;
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.terminate." + name.toLowerCase())));
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Plugins"));
|
||||
block.setItemMeta(blockMeta);
|
||||
}
|
||||
inv.setItem(27, block);
|
||||
inv.setItem(28, block);
|
||||
|
||||
if (subserver.isRunning()) {
|
||||
block = (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER)?createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11):createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
blockMeta = block.getItemMeta();
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
if (subserver.getStopAction() != SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() != SubServer.StopAction.DELETE_SERVER) {
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + subserver.getDisplayName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
|
||||
} else blockMeta.setDisplayName(ChatColor.GREEN + subserver.getDisplayName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size())));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.YELLOW + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate"));
|
||||
}
|
||||
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(1, block);
|
||||
inv.setItem(10, block);
|
||||
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.stop.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.stop." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.stop." + name.toLowerCase())));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "MAGENTA_STAINED_GLASS_PANE", (short) 2);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop"));
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(2, block);
|
||||
inv.setItem(3, block);
|
||||
inv.setItem(11, block);
|
||||
inv.setItem(12, block);
|
||||
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.command.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.command." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.command." + name.toLowerCase())));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command"));
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(5, block);
|
||||
inv.setItem(6, block);
|
||||
inv.setItem(7, block);
|
||||
inv.setItem(14, block);
|
||||
inv.setItem(15, block);
|
||||
inv.setItem(16, block);
|
||||
} else {
|
||||
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.start.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.start." + name.toLowerCase()))) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
|
||||
blockMeta.setLore(Arrays.asList(plugin.api.getLang("SubServers", "Interface.Generic.Invalid-Permission").replace("$str$", "subservers.subserver.start." + name.toLowerCase())));
|
||||
} else if (!subserver.isEnabled() || subserver.getCurrentIncompatibilities().size() != 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "GRAY_STAINED_GLASS_PANE", (short) 7);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GRAY+ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start")));
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start"));
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(3, block);
|
||||
inv.setItem(4, block);
|
||||
inv.setItem(5, block);
|
||||
inv.setItem(12, block);
|
||||
inv.setItem(13, block);
|
||||
inv.setItem(14, block);
|
||||
}
|
||||
|
||||
if (!subserver.isEnabled() || subserverPlugins.size() <= 0) {
|
||||
block = div;
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Plugins"));
|
||||
block.setItemMeta(blockMeta);
|
||||
}
|
||||
inv.setItem(27, block);
|
||||
inv.setItem(28, block);
|
||||
|
||||
if (subserver.isTemporary()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "BLUE_STAINED_GLASS_PANE", (short) 11);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.AQUA + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary"));
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size())));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else if (subserver.isRunning()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "LIME_STAINED_GLASS_PANE", (short) 5);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.GREEN + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size())));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
block = createItem("STAINED_GLASS_PANE", "YELLOW_STAINED_GLASS_PANE", (short) 4);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.YELLOW + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Offline"));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
} else {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(ChatColor.RED + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
if (subserver.getCurrentIncompatibilities().size() != 0) {
|
||||
String list = "";
|
||||
for (String other : subserver.getCurrentIncompatibilities()) {
|
||||
if (list.length() != 0) list += ", ";
|
||||
list += other;
|
||||
blockMeta.setDisplayName(ChatColor.RED + subserver.getDisplayName());
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
if (!subserver.getName().equals(subserver.getDisplayName()))
|
||||
lore.add(ChatColor.GRAY + subserver.getName());
|
||||
if (subserver.getCurrentIncompatibilities().size() != 0) {
|
||||
String list = "";
|
||||
for (String other : subserver.getCurrentIncompatibilities()) {
|
||||
if (list.length() != 0) list += ", ";
|
||||
list += other;
|
||||
}
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list));
|
||||
}
|
||||
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Incompatible").replace("$str$", list));
|
||||
if (!subserver.isEnabled()) lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Disabled"));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
}
|
||||
if (!subserver.isEnabled()) lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Disabled"));
|
||||
lore.add(ChatColor.WHITE + ((plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
|
||||
blockMeta.setLore(lore);
|
||||
}
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(30, block);
|
||||
inv.setItem(31, block);
|
||||
inv.setItem(32, block);
|
||||
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(34, block);
|
||||
inv.setItem(35, block);
|
||||
}
|
||||
inv.setItem(30, block);
|
||||
inv.setItem(31, block);
|
||||
inv.setItem(32, block);
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
if (hasHistory()) {
|
||||
block = createItem("STAINED_GLASS_PANE", "RED_STAINED_GLASS_PANE", (short) 14);
|
||||
blockMeta = block.getItemMeta();
|
||||
blockMeta.setDisplayName(plugin.api.getLang("SubServers", "Interface.Generic.Back"));
|
||||
block.setItemMeta(blockMeta);
|
||||
inv.setItem(34, block);
|
||||
inv.setItem(35, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -50,19 +50,7 @@ public class BungeeChat {
|
||||
message = new TextComponent(server.getDisplayName());
|
||||
hover = new TextComponent(server.getDisplayName() + '\n');
|
||||
if (server instanceof SubServer) {
|
||||
if (((SubServer) server).isTemporary()) {
|
||||
message.setColor(ChatColor.AQUA);
|
||||
hover.setColor(ChatColor.AQUA);
|
||||
hoverm.add(hover);
|
||||
if (!server.getName().equals(server.getDisplayName())) {
|
||||
hover = new TextComponent(server.getName() + '\n');
|
||||
hover.setColor(ChatColor.GRAY);
|
||||
hoverm.add(hover);
|
||||
}
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n');
|
||||
hoverm.add(hover);
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())));
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
if (((SubServer) server).isRunning()) {
|
||||
message.setColor(ChatColor.GREEN);
|
||||
hover.setColor(ChatColor.GREEN);
|
||||
hoverm.add(hover);
|
||||
@ -71,6 +59,12 @@ public class BungeeChat {
|
||||
hover.setColor(ChatColor.GRAY);
|
||||
hoverm.add(hover);
|
||||
}
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message.setColor(ChatColor.AQUA);
|
||||
hover.setColor(ChatColor.AQUA);
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n');
|
||||
hoverm.add(hover);
|
||||
}
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())));
|
||||
} else if (((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
message.setColor(ChatColor.YELLOW);
|
||||
@ -153,7 +147,7 @@ public class BungeeChat {
|
||||
TextComponent msg = new TextComponent(" ");
|
||||
TextComponent message = new TextComponent(host.getDisplayName());
|
||||
TextComponent hover = new TextComponent(host.getDisplayName() + '\n');
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
message.setColor(ChatColor.AQUA);
|
||||
hover.setColor(ChatColor.AQUA);
|
||||
hoverm.add(hover);
|
||||
@ -172,7 +166,7 @@ public class BungeeChat {
|
||||
hover.setColor(ChatColor.GRAY);
|
||||
hoverm.add(hover);
|
||||
}
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Host-Menu.Host-Disabled"));
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", (!host.isAvailable())?"Interface.Host-Menu.Host-Unavailable":"Interface.Host-Menu.Host-Disabled"));
|
||||
}
|
||||
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
|
||||
hoverm.add(hover);
|
||||
@ -190,19 +184,7 @@ public class BungeeChat {
|
||||
message = new TextComponent(subserver.getDisplayName());
|
||||
hover = new TextComponent(subserver.getDisplayName() + '\n');
|
||||
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, label + " open SubServer/ " + subserver));
|
||||
if (subserver.isTemporary()) {
|
||||
message.setColor(ChatColor.AQUA);
|
||||
hover.setColor(ChatColor.AQUA);
|
||||
hoverm.add(hover);
|
||||
if (!subserver.getName().equals(subserver.getDisplayName())) {
|
||||
hover = new TextComponent(subserver.getName() + '\n');
|
||||
hover.setColor(ChatColor.GRAY);
|
||||
hoverm.add(hover);
|
||||
}
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n');
|
||||
hoverm.add(hover);
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size())));
|
||||
} else if (subserver.isEnabled()) {
|
||||
if (subserver.isRunning()) {
|
||||
message.setColor(ChatColor.GREEN);
|
||||
hover.setColor(ChatColor.GREEN);
|
||||
hoverm.add(hover);
|
||||
@ -211,6 +193,12 @@ public class BungeeChat {
|
||||
hover.setColor(ChatColor.GRAY);
|
||||
hoverm.add(hover);
|
||||
}
|
||||
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message.setColor(ChatColor.AQUA);
|
||||
hover.setColor(ChatColor.AQUA);
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Temporary") + '\n');
|
||||
hoverm.add(hover);
|
||||
}
|
||||
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size())));
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
message.setColor(ChatColor.YELLOW);
|
||||
|
@ -58,6 +58,15 @@ public class Host {
|
||||
return raw.getRawString("subdata", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Available?
|
||||
*
|
||||
* @return Availability Status
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return raw.getBoolean("available");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Enabled?
|
||||
*
|
||||
|
@ -13,6 +13,21 @@ public class SubServer extends Server {
|
||||
private List<SubServer> incompatibilities = null;
|
||||
private Host host = null;
|
||||
|
||||
/**
|
||||
* SubServer Stop Action Class
|
||||
*/
|
||||
public enum StopAction {
|
||||
NONE,
|
||||
RESTART,
|
||||
REMOVE_SERVER,
|
||||
DELETE_SERVER;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an API representation of a Server
|
||||
*
|
||||
@ -331,12 +346,12 @@ public class SubServer extends Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server will Auto Restart on unexpected shutdowns
|
||||
* Get the action the Server will take when it stops
|
||||
*
|
||||
* @return Auto Restart Status
|
||||
* @return Stop Action
|
||||
*/
|
||||
public boolean willAutoRestart() {
|
||||
return raw.getBoolean("auto-restart");
|
||||
public StopAction getStopAction() {
|
||||
return Util.getDespiteException(() -> StopAction.valueOf(raw.getRawString("stop-action").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -422,13 +437,4 @@ public class SubServer extends Server {
|
||||
callback.run(current);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server is Temporary
|
||||
*
|
||||
* @return Temporary Status
|
||||
*/
|
||||
public boolean isTemporary() {
|
||||
return raw.getBoolean("temp");
|
||||
}
|
||||
}
|
||||
|
@ -91,10 +91,12 @@ public final class SubCommand implements CommandExecutor {
|
||||
if (i != 0) message += div;
|
||||
if (!(server instanceof SubServer)) {
|
||||
message += ChatColor.WHITE;
|
||||
} else if (((SubServer) server).isTemporary()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
message += ChatColor.GREEN;
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.GREEN;
|
||||
}
|
||||
} else if (((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
@ -114,7 +116,7 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.List.Host-Header"));
|
||||
for (Host host : hosts.values()) {
|
||||
String message = " ";
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
@ -128,10 +130,12 @@ public final class SubCommand implements CommandExecutor {
|
||||
message += plugin.api.getLang("SubServers", "Command.List.Header");
|
||||
for (SubServer subserver : host.getSubServers().values()) {
|
||||
if (i != 0) message += div;
|
||||
if (subserver.isTemporary()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (subserver.isRunning()) {
|
||||
message += ChatColor.GREEN;
|
||||
if (subserver.isRunning()) {
|
||||
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.GREEN;
|
||||
}
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
@ -199,12 +203,9 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Players") + ChatColor.AQUA + server.getPlayers().size() + " online");
|
||||
}
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "MOTD") + ChatColor.WHITE + ChatColor.stripColor(server.getMotd()));
|
||||
if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Stop Action") + ChatColor.WHITE + ((SubServer) server).getStopAction().toString());
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Signature") + ChatColor.AQUA + server.getSignature());
|
||||
if (server instanceof SubServer) {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Logging") + ((((SubServer) server).isLogging())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (((SubServer) server).isTemporary()) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Temporary") + ChatColor.GREEN + "yes");
|
||||
else sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Auto Restart") + ((((SubServer) server).willAutoRestart())?ChatColor.GREEN+"enabled":ChatColor.RED+"disabled"));
|
||||
}
|
||||
if (server instanceof SubServer) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Logging") + ((((SubServer) server).isLogging())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Restricted") + ((server.isRestricted())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (server instanceof SubServer && ((SubServer) server).getIncompatibilities().size() > 0) {
|
||||
List<String> current = new ArrayList<String>();
|
||||
@ -238,6 +239,7 @@ public final class SubCommand implements CommandExecutor {
|
||||
if (host != null) {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info").replace("$str$", "Host") + ChatColor.WHITE + host.getDisplayName());
|
||||
if (!host.getName().equals(host.getDisplayName())) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "System Name") + ChatColor.WHITE + host.getName());
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Available") + ((host.isAvailable())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Enabled") + ((host.isEnabled())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Address") + ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
if (host.getSubData() != null) sender.sendMessage(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Connected") + ChatColor.GREEN + "yes");
|
||||
@ -311,15 +313,18 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Invalid"));
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Host-Disabled"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Host-Unavailable"));
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Server-Disabled"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Host-Disabled"));
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Running"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Server-Disabled"));
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Running"));
|
||||
break;
|
||||
case 9:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Server-Incompatible").replace("$str$", data.getString("m").split(":\\s")[1]));
|
||||
break;
|
||||
case 0:
|
||||
@ -453,12 +458,21 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Unknown-Host"));
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Invalid-Template"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Host-Unavailable"));
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Invalid-Version"));
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Start.Host-Disabled"));
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Unknown-Template"));
|
||||
break;
|
||||
case 9:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Template-Disabled"));
|
||||
break;
|
||||
case 10:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Invalid-Version"));
|
||||
break;
|
||||
case 11:
|
||||
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Creator.Invalid-Port"));
|
||||
break;
|
||||
case 0:
|
||||
|
@ -20,7 +20,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>spongeapi</artifactId>
|
||||
<version>4.0.0</version>
|
||||
<version>7.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -44,11 +44,11 @@ public class SubAddHostEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ public class SubAddProxyEvent extends AbstractEvent implements SubEvent {
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().build();
|
||||
return Cause.builder().build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -55,11 +55,11 @@ public class SubAddServerEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +113,11 @@ public class SubCreateEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -73,11 +73,11 @@ public class SubEditServerEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ public class SubNetworkConnectEvent extends AbstractEvent implements SubEvent {
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().build();
|
||||
return Cause.builder().build(getContext());
|
||||
}
|
||||
}
|
@ -18,6 +18,6 @@ public class SubNetworkDisconnectEvent extends AbstractEvent implements SubEvent
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().build();
|
||||
return Cause.builder().build(getContext());
|
||||
}
|
||||
}
|
@ -44,11 +44,11 @@ public class SubRemoveHostEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,6 @@ public class SubRemoveProxyEvent extends AbstractEvent implements SubEvent {
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().build();
|
||||
return Cause.builder().build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -55,11 +55,11 @@ public class SubRemoveServerEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ public class SubSendCommandEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -45,11 +45,11 @@ public class SubStartEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -57,11 +57,11 @@ public class SubStopEvent extends AbstractEvent implements SubEvent {
|
||||
* Gets the cause of this Event
|
||||
*
|
||||
* @deprecated Use simplified methods where available
|
||||
* @return The player who triggered this event under the key: player
|
||||
* @return The player UUID who triggered this event
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().named("player", player).build();
|
||||
return Cause.builder().append(player).build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,6 @@ public class SubStoppedEvent extends AbstractEvent implements SubEvent {
|
||||
@Override
|
||||
@Deprecated
|
||||
public Cause getCause() {
|
||||
return Cause.builder().build();
|
||||
return Cause.builder().build(getContext());
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,15 @@ public class Host {
|
||||
return raw.getRawString("subdata", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Available?
|
||||
*
|
||||
* @return Availability Status
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return raw.getBoolean("available");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Enabled?
|
||||
*
|
||||
|
@ -16,6 +16,21 @@ public class SubServer extends Server {
|
||||
private List<SubServer> incompatibilities = null;
|
||||
private Host host = null;
|
||||
|
||||
/**
|
||||
* SubServer Stop Action Class
|
||||
*/
|
||||
public enum StopAction {
|
||||
NONE,
|
||||
RESTART,
|
||||
REMOVE_SERVER,
|
||||
DELETE_SERVER;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an API representation of a Server
|
||||
*
|
||||
@ -334,12 +349,12 @@ public class SubServer extends Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server will Auto Restart on unexpected shutdowns
|
||||
* Get the action the Server will take when it stops
|
||||
*
|
||||
* @return Auto Restart Status
|
||||
* @return Stop Action
|
||||
*/
|
||||
public boolean willAutoRestart() {
|
||||
return raw.getBoolean("auto-restart");
|
||||
public StopAction getStopAction() {
|
||||
return Util.getDespiteException(() -> StopAction.valueOf(raw.getRawString("stop-action").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -425,13 +440,4 @@ public class SubServer extends Server {
|
||||
callback.run(current);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server is Temporary
|
||||
*
|
||||
* @return Temporary Status
|
||||
*/
|
||||
public boolean isTemporary() {
|
||||
return raw.getBoolean("temp");
|
||||
}
|
||||
}
|
||||
|
@ -208,22 +208,17 @@ public final class SubCommand implements CommandExecutor {
|
||||
Text.Builder hover = Text.builder(server.getDisplayName() + '\n');
|
||||
if (server instanceof SubServer) {
|
||||
message.onClick(TextActions.runCommand("/subservers open SubServer/ " + server.getName()));
|
||||
if (((SubServer) server).isTemporary()) {
|
||||
message.color(TextColors.AQUA);
|
||||
hover.color(TextColors.AQUA);
|
||||
if (!server.getName().equals(server.getDisplayName())) {
|
||||
hover.append(Text.builder(server.getName() + '\n').color(TextColors.GRAY).build());
|
||||
}
|
||||
hover.append(
|
||||
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.SubServer-Temporary") + '\n'),
|
||||
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())))
|
||||
);
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
if (((SubServer) server).isRunning()) {
|
||||
message.color(TextColors.GREEN);
|
||||
hover.color(TextColors.GREEN);
|
||||
if (!server.getName().equals(server.getDisplayName())) {
|
||||
hover.append(Text.builder(server.getName() + '\n').color(TextColors.GRAY).build());
|
||||
}
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message.color(TextColors.AQUA);
|
||||
hover.color(TextColors.AQUA);
|
||||
hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.SubServer-Temporary") + '\n'));
|
||||
}
|
||||
hover.append(
|
||||
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())))
|
||||
);
|
||||
@ -293,7 +288,7 @@ public final class SubCommand implements CommandExecutor {
|
||||
for (Host host : hosts.values()) {
|
||||
Text.Builder msg = Text.builder(host.getDisplayName());
|
||||
Text.Builder hover = Text.builder(host.getDisplayName() + '\n');
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
msg.color(TextColors.AQUA);
|
||||
hover.color(TextColors.AQUA);
|
||||
if (!host.getName().equals(host.getDisplayName())) {
|
||||
@ -306,7 +301,8 @@ public final class SubCommand implements CommandExecutor {
|
||||
if (!host.getName().equals(host.getDisplayName())) {
|
||||
hover.append(Text.builder(host.getName() + '\n').color(TextColors.GRAY).build());
|
||||
}
|
||||
hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Host-Menu.Host-Disabled")));
|
||||
if (!host.isAvailable()) hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Host-Menu.Host-Unavailable")));
|
||||
else hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Host-Menu.Host-Disabled")));
|
||||
}
|
||||
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) {
|
||||
hover.append(Text.builder('\n' + host.getAddress().getHostAddress()).color(TextColors.WHITE).build());
|
||||
@ -318,22 +314,17 @@ public final class SubCommand implements CommandExecutor {
|
||||
for (SubServer subserver : host.getSubServers().values()) {
|
||||
Text.Builder message = Text.builder(subserver.getDisplayName());
|
||||
hover = Text.builder(subserver.getDisplayName() + '\n');
|
||||
if (subserver.isTemporary()) {
|
||||
message.color(TextColors.AQUA);
|
||||
hover.color(TextColors.AQUA);
|
||||
if (!subserver.getName().equals(subserver.getDisplayName())) {
|
||||
hover.append(Text.builder(subserver.getName() + '\n').color(TextColors.GRAY).build());
|
||||
}
|
||||
hover.append(
|
||||
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.SubServer-Temporary") + '\n'),
|
||||
ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size())))
|
||||
);
|
||||
} else if (subserver.isRunning()) {
|
||||
if (subserver.isRunning()) {
|
||||
message.color(TextColors.GREEN);
|
||||
hover.color(TextColors.GREEN);
|
||||
if (!subserver.getName().equals(subserver.getDisplayName())) {
|
||||
hover.append(Text.builder(subserver.getName() + '\n').color(TextColors.GRAY).build());
|
||||
}
|
||||
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message.color(TextColors.AQUA);
|
||||
hover.color(TextColors.AQUA);
|
||||
hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.SubServer-Temporary") + '\n'));
|
||||
}
|
||||
hover.append(ChatColor.convertColor(plugin.api.getLang("SubServers","Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getPlayers().size()))));
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
message.color(TextColors.YELLOW);
|
||||
@ -503,12 +494,9 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Players")).toBuilder().append(Text.builder(server.getPlayers().size() + " online").color(TextColors.AQUA).build()).build());
|
||||
}
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "MOTD")).toBuilder().append(Text.builder(server.getMotd().replaceAll("\\u00A7[0-9a-fA-Fk-oK-ORr]", "")).color(TextColors.WHITE).build()).build());
|
||||
if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Stop Action")).toBuilder().append(Text.builder(((SubServer) server).getStopAction().toString()).color(TextColors.WHITE).build()).build());
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Signature")).toBuilder().append(Text.builder(server.getSignature()).color(TextColors.AQUA).build()).build());
|
||||
if (server instanceof SubServer) {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Logging")).toBuilder().append(Text.builder((((SubServer) server).isLogging())?"yes":"no").color((((SubServer) server).isLogging())?TextColors.GREEN:TextColors.RED).build()).build());
|
||||
if (((SubServer) server).isTemporary()) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Temporary")).toBuilder().append(Text.builder("yes").color(TextColors.GREEN).build()).build());
|
||||
else sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Auto Restart")).toBuilder().append(Text.builder((((SubServer) server).willAutoRestart())?"enabled":"disabled").color((((SubServer) server).willAutoRestart())?TextColors.GREEN:TextColors.RED).build()).build());
|
||||
}
|
||||
if (server instanceof SubServer) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Logging")).toBuilder().append(Text.builder((((SubServer) server).isLogging())?"yes":"no").color((((SubServer) server).isLogging())?TextColors.GREEN:TextColors.RED).build()).build());
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Restricted")).toBuilder().append(Text.builder((server.isRestricted())?"yes":"no").color((server.isRestricted())?TextColors.GREEN:TextColors.RED).build()).build());
|
||||
if (server instanceof SubServer && ((SubServer) server).getIncompatibilities().size() > 0) {
|
||||
List<String> current = new ArrayList<String>();
|
||||
@ -542,6 +530,7 @@ public final class SubCommand implements CommandExecutor {
|
||||
if (host != null) {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info").replace("$str$", "Host")).toBuilder().append(Text.builder(host.getDisplayName()).color(TextColors.WHITE).build()).build());
|
||||
if (!host.getName().equals(host.getDisplayName())) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "System Name")).toBuilder().append(Text.builder(host.getName()).color(TextColors.WHITE).build()).build());
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Available")).toBuilder().append(Text.builder((host.isAvailable())?"yes":"no").color((host.isAvailable())?TextColors.GREEN:TextColors.RED).build()).build());
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Enabled")).toBuilder().append(Text.builder((host.isEnabled())?"yes":"no").color((host.isEnabled())?TextColors.GREEN:TextColors.RED).build()).build());
|
||||
if (plugin.config.get().getSection("Settings").getBoolean("Show-Addresses", false)) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Address")).toBuilder().append(Text.builder(host.getAddress().getHostAddress()).color(TextColors.WHITE).build()).build());
|
||||
if (host.getSubData() != null) sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers", "Command.Info.Format").replace("$str$", "Connected")).toBuilder().append(Text.builder("yes").color(TextColors.GREEN).build()).build());
|
||||
@ -627,15 +616,18 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Invalid")));
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Host-Disabled")));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Host-Unavailable")));
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Server-Disabled")));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Host-Disabled")));
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Running")));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Server-Disabled")));
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Running")));
|
||||
break;
|
||||
case 9:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Server-Incompatible").replace("$str$", data.getString("m").split(":\\s")[1])));
|
||||
break;
|
||||
case 0:
|
||||
@ -818,12 +810,21 @@ public final class SubCommand implements CommandExecutor {
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Unknown-Host")));
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Invalid-Template")));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Host-Unavailable")));
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Invalid-Version")));
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Start.Host-Disabled")));
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Unknown-Template")));
|
||||
break;
|
||||
case 9:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Template-Disabled")));
|
||||
break;
|
||||
case 10:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Invalid-Version")));
|
||||
break;
|
||||
case 11:
|
||||
sender.sendMessage(ChatColor.convertColor(plugin.api.getLang("SubServers","Command.Creator.Invalid-Port")));
|
||||
break;
|
||||
case 0:
|
||||
|
@ -58,6 +58,15 @@ public class Host {
|
||||
return raw.getRawString("subdata", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Available?
|
||||
*
|
||||
* @return Availability Status
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return raw.getBoolean("available");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Enabled?
|
||||
*
|
||||
|
@ -18,6 +18,21 @@ public class SubServer extends Server {
|
||||
private List<SubServer> incompatibilities = null;
|
||||
private Host host = null;
|
||||
|
||||
/**
|
||||
* SubServer Stop Action Class
|
||||
*/
|
||||
public enum StopAction {
|
||||
NONE,
|
||||
RESTART,
|
||||
REMOVE_SERVER,
|
||||
DELETE_SERVER;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an API representation of a Server
|
||||
*
|
||||
@ -336,12 +351,12 @@ public class SubServer extends Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server will Auto Restart on unexpected shutdowns
|
||||
* Get the action the Server will take when it stops
|
||||
*
|
||||
* @return Auto Restart Status
|
||||
* @return Stop Action
|
||||
*/
|
||||
public boolean willAutoRestart() {
|
||||
return raw.getBoolean("auto-restart");
|
||||
public StopAction getStopAction() {
|
||||
return Util.getDespiteException(() -> StopAction.valueOf(raw.getRawString("stop-action").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -427,13 +442,4 @@ public class SubServer extends Server {
|
||||
callback.run(current);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server is Temporary
|
||||
*
|
||||
* @return Temporary Status
|
||||
*/
|
||||
public boolean isTemporary() {
|
||||
return raw.getBoolean("temp");
|
||||
}
|
||||
}
|
||||
|
@ -114,10 +114,12 @@ public class SubCommand {
|
||||
if (i != 0) message += div;
|
||||
if (!(server instanceof SubServer)) {
|
||||
message += TextColor.WHITE;
|
||||
} else if (((SubServer) server).isTemporary()) {
|
||||
message += TextColor.AQUA;
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
message += TextColor.GREEN;
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += TextColor.AQUA;
|
||||
} else {
|
||||
message += TextColor.GREEN;
|
||||
}
|
||||
} else if (((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
message += TextColor.YELLOW;
|
||||
} else {
|
||||
@ -138,7 +140,7 @@ public class SubCommand {
|
||||
host.log.message.println("Host/SubServer List:");
|
||||
for (Host host : hosts.values()) {
|
||||
String message = " ";
|
||||
if (host.isEnabled()) {
|
||||
if (host.isAvailable() && host.isEnabled()) {
|
||||
message += TextColor.AQUA;
|
||||
} else {
|
||||
message += TextColor.RED;
|
||||
@ -146,10 +148,12 @@ public class SubCommand {
|
||||
message += host.getDisplayName() + " (" + host.getAddress().getHostAddress() + ((host.getName().equals(host.getDisplayName()))?"":TextColor.stripColor(div)+host.getName()) + ")" + TextColor.RESET + ": ";
|
||||
for (SubServer subserver : host.getSubServers().values()) {
|
||||
if (i != 0) message += div;
|
||||
if (subserver.isTemporary()) {
|
||||
message += TextColor.AQUA;
|
||||
} else if (subserver.isRunning()) {
|
||||
message += TextColor.GREEN;
|
||||
if (subserver.isRunning()) {
|
||||
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += TextColor.AQUA;
|
||||
} else {
|
||||
message += TextColor.GREEN;
|
||||
}
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
message += TextColor.YELLOW;
|
||||
} else {
|
||||
@ -225,12 +229,9 @@ public class SubCommand {
|
||||
host.log.message.println(" -> Players: " + TextColor.AQUA + server.getPlayers().size() + " online");
|
||||
}
|
||||
host.log.message.println(" -> MOTD: " + TextColor.WHITE + TextColor.stripColor(server.getMotd()));
|
||||
if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) host.log.message.println(" -> Stop Action: " + TextColor.WHITE + ((SubServer) server).getStopAction().toString());
|
||||
host.log.message.println(" -> Signature: " + TextColor.AQUA + server.getSignature());
|
||||
if (server instanceof SubServer) {
|
||||
host.log.message.println(" -> Logging: " + ((((SubServer) server).isLogging())?TextColor.GREEN+"yes":TextColor.RED+"no"));
|
||||
if (((SubServer) server).isTemporary()) host.log.message.println(" -> Temporary: " + TextColor.GREEN + "yes");
|
||||
else host.log.message.println(" -> Auto Restart: " + ((((SubServer) server).willAutoRestart())?TextColor.GREEN+"enabled":TextColor.RED+"disabled"));
|
||||
}
|
||||
if (server instanceof SubServer) host.log.message.println(" -> Logging: " + ((((SubServer) server).isLogging())?TextColor.GREEN+"yes":TextColor.RED+"no"));
|
||||
host.log.message.println(" -> Restricted: " + ((server.isRestricted())?TextColor.GREEN+"yes":TextColor.RED+"no"));
|
||||
if (server instanceof SubServer && ((SubServer) server).getIncompatibilities().size() > 0) {
|
||||
List<String> current = new ArrayList<String>();
|
||||
@ -265,6 +266,7 @@ public class SubCommand {
|
||||
if (host != null) {
|
||||
h.log.message.println("SubServers > Info on Host: " + TextColor.WHITE + host.getDisplayName());
|
||||
if (!host.getName().equals(host.getDisplayName())) h.log.message.println(" -> System Name: " + TextColor.WHITE + host.getName());
|
||||
h.log.message.println(" -> Available: " + ((host.isAvailable())?TextColor.GREEN+"yes":TextColor.RED+"no"));
|
||||
h.log.message.println(" -> Enabled: " + ((host.isEnabled())?TextColor.GREEN+"yes":TextColor.RED+"no"));
|
||||
h.log.message.println(" -> Address: " + TextColor.WHITE + host.getAddress().getHostAddress());
|
||||
if (host.getSubData() != null) h.log.message.println(" -> Connected: " + TextColor.GREEN + "yes");
|
||||
@ -354,15 +356,18 @@ public class SubCommand {
|
||||
host.log.message.println("That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
host.log.message.println("That SubServer's Host is not enabled");
|
||||
host.log.message.println("That SubServer's Host is not available");
|
||||
break;
|
||||
case 6:
|
||||
host.log.message.println("That SubServer is not enabled");
|
||||
host.log.message.println("That SubServer's Host is not enabled");
|
||||
break;
|
||||
case 7:
|
||||
host.log.message.println("That SubServer is already running");
|
||||
host.log.message.println("That SubServer is not enabled");
|
||||
break;
|
||||
case 8:
|
||||
host.log.message.println("That SubServer is already running");
|
||||
break;
|
||||
case 9:
|
||||
host.log.message.println("That SubServer cannot start while these server(s) are running:", data.getRawString("m").split(":\\s")[1]);
|
||||
break;
|
||||
case 0:
|
||||
@ -538,12 +543,21 @@ public class SubCommand {
|
||||
host.log.message.println("There is no host with that name");
|
||||
break;
|
||||
case 6:
|
||||
host.log.message.println("There is no template with that name");
|
||||
host.log.message.println("That Host is not available");
|
||||
break;
|
||||
case 7:
|
||||
host.log.message.println("SubCreator cannot create servers before Minecraft 1.8");
|
||||
host.log.message.println("That Host is not enabled");
|
||||
break;
|
||||
case 8:
|
||||
host.log.message.println("There is no template with that name");
|
||||
break;
|
||||
case 9:
|
||||
host.log.message.println("That Template is not enabled");
|
||||
break;
|
||||
case 10:
|
||||
host.log.message.println("SubCreator cannot create servers before Minecraft 1.8");
|
||||
break;
|
||||
case 11:
|
||||
host.log.message.println("Invalid Port Number");
|
||||
break;
|
||||
case 0:
|
||||
|
@ -153,7 +153,7 @@ public class Metrics {
|
||||
int playerAmount = plugin.getOnlineCount();
|
||||
playerAmount = playerAmount > 500 ? 500 : playerAmount;
|
||||
int onlineMode = plugin.getConfig().isOnlineMode() ? 1 : 0;
|
||||
String bungeecordVersion = (plugin.getName().equals("SubServers.Sync"))?"SubServers-Sync-Patched":plugin.getVersion();
|
||||
String bungeecordVersion = (plugin.getName().equals("SubServers Platform"))?"SubServers-Sync-Patched":plugin.getVersion();
|
||||
int managedServers = plugin.getServers().size();
|
||||
|
||||
// OS/Java specific data
|
||||
|
@ -58,6 +58,15 @@ public class Host {
|
||||
return raw.getRawString("subdata", null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Available?
|
||||
*
|
||||
* @return Availability Status
|
||||
*/
|
||||
public boolean isAvailable() {
|
||||
return raw.getBoolean("available");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this Host Enabled?
|
||||
*
|
||||
|
@ -17,6 +17,21 @@ public class SubServer extends Server {
|
||||
private List<SubServer> incompatibilities = null;
|
||||
private Host host = null;
|
||||
|
||||
/**
|
||||
* SubServer Stop Action Class
|
||||
*/
|
||||
public enum StopAction {
|
||||
NONE,
|
||||
RESTART,
|
||||
REMOVE_SERVER,
|
||||
DELETE_SERVER;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().substring(0, 1).toUpperCase()+super.toString().substring(1).toLowerCase().replace('_', ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an API representation of a Server
|
||||
*
|
||||
@ -335,12 +350,12 @@ public class SubServer extends Server {
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server will Auto Restart on unexpected shutdowns
|
||||
* Get the action the Server will take when it stops
|
||||
*
|
||||
* @return Auto Restart Status
|
||||
* @return Stop Action
|
||||
*/
|
||||
public boolean willAutoRestart() {
|
||||
return raw.getBoolean("auto-restart");
|
||||
public StopAction getStopAction() {
|
||||
return Util.getDespiteException(() -> StopAction.valueOf(raw.getRawString("stop-action").toUpperCase().replace('-', '_').replace(' ', '_')), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -426,13 +441,4 @@ public class SubServer extends Server {
|
||||
callback.run(current);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Server is Temporary
|
||||
*
|
||||
* @return Temporary Status
|
||||
*/
|
||||
public boolean isTemporary() {
|
||||
return raw.getBoolean("temp");
|
||||
}
|
||||
}
|
||||
|
@ -53,99 +53,65 @@ public final class SubCommand extends CommandX {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
if (plugin.subdata == null) {
|
||||
throw new IllegalStateException("SubData is not connected");
|
||||
} else if (plugin.lang == null) {
|
||||
throw new IllegalStateException("There are no lang options available at this time");
|
||||
} else {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||
sender.sendMessages(printHelp());
|
||||
} else if (args[0].equalsIgnoreCase("version") || args[0].equalsIgnoreCase("ver")) {
|
||||
sender.sendMessage("SubServers > These are the platforms and versions that are running SubServers.Sync:");
|
||||
sender.sendMessage(" " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + ',');
|
||||
sender.sendMessage(" Java " + System.getProperty("java.version") + ',');
|
||||
sender.sendMessage(" " + plugin.getBungeeName() + ((plugin.isPatched)?" [Patched] ":" ") + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ',');
|
||||
sender.sendMessage(" SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
|
||||
sender.sendMessage("");
|
||||
new Thread(() -> {
|
||||
try {
|
||||
YAMLSection tags = new YAMLSection(new Gson().fromJson("{\"tags\":" + Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://api.github.com/repos/ME1312/SubServers-2/git/refs/tags").openStream(), Charset.forName("UTF-8")))) + '}', Map.class));
|
||||
List<Version> versions = new LinkedList<Version>();
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||
sender.sendMessages(printHelp());
|
||||
} else if (args[0].equalsIgnoreCase("version") || args[0].equalsIgnoreCase("ver")) {
|
||||
sender.sendMessage("SubServers > These are the platforms and versions that are running SubServers.Sync:");
|
||||
sender.sendMessage(" " + System.getProperty("os.name") + ' ' + System.getProperty("os.version") + ',');
|
||||
sender.sendMessage(" Java " + System.getProperty("java.version") + ',');
|
||||
sender.sendMessage(" " + plugin.getBungeeName() + ((plugin.isPatched)?" [Patched] ":" ") + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ',');
|
||||
sender.sendMessage(" SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
|
||||
sender.sendMessage("");
|
||||
new Thread(() -> {
|
||||
try {
|
||||
YAMLSection tags = new YAMLSection(new Gson().fromJson("{\"tags\":" + Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://api.github.com/repos/ME1312/SubServers-2/git/refs/tags").openStream(), Charset.forName("UTF-8")))) + '}', Map.class));
|
||||
List<Version> versions = new LinkedList<Version>();
|
||||
|
||||
Version updversion = plugin.version;
|
||||
int updcount = 0;
|
||||
for (YAMLSection tag : tags.getSectionList("tags")) versions.add(Version.fromString(tag.getString("ref").substring(10)));
|
||||
Collections.sort(versions);
|
||||
for (Version version : versions) {
|
||||
if (version.compareTo(updversion) > 0) {
|
||||
updversion = version;
|
||||
updcount++;
|
||||
}
|
||||
Version updversion = plugin.version;
|
||||
int updcount = 0;
|
||||
for (YAMLSection tag : tags.getSectionList("tags")) versions.add(Version.fromString(tag.getString("ref").substring(10)));
|
||||
Collections.sort(versions);
|
||||
for (Version version : versions) {
|
||||
if (version.compareTo(updversion) > 0) {
|
||||
updversion = version;
|
||||
updcount++;
|
||||
}
|
||||
if (updcount == 0) {
|
||||
sender.sendMessage("You are on the latest version.");
|
||||
} else {
|
||||
sender.sendMessage("SubServers.Sync v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}).start();
|
||||
} else if (args[0].equalsIgnoreCase("list")) {
|
||||
plugin.api.getGroups(groups -> plugin.api.getHosts(hosts -> plugin.api.getServers(servers -> plugin.api.getMasterProxy(proxymaster -> plugin.api.getProxies(proxies -> {
|
||||
int i = 0;
|
||||
boolean sent = false;
|
||||
String div = ChatColor.RESET + ", ";
|
||||
if (groups.keySet().size() > 0) {
|
||||
sender.sendMessage("Group/Server List:");
|
||||
for (String group : groups.keySet()) {
|
||||
String message = " ";
|
||||
message += ChatColor.GOLD + group + ChatColor.RESET + ": ";
|
||||
for (Server server : groups.get(group)) {
|
||||
if (i != 0) message += div;
|
||||
if (!(server instanceof SubServer)) {
|
||||
message += ChatColor.WHITE;
|
||||
} else if (((SubServer) server).isTemporary()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
message += ChatColor.GREEN;
|
||||
} else if (((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
message += server.getDisplayName() + " (" + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort() + ((server.getName().equals(server.getDisplayName())) ? "" : ChatColor.stripColor(div) + server.getName()) + ")";
|
||||
i++;
|
||||
}
|
||||
if (i == 0) message += ChatColor.RESET + "(none)";
|
||||
sender.sendMessage(message);
|
||||
i = 0;
|
||||
sent = true;
|
||||
}
|
||||
if (!sent) sender.sendMessage(ChatColor.RESET + "(none)");
|
||||
sent = false;
|
||||
if (updcount == 0) {
|
||||
sender.sendMessage("You are on the latest version.");
|
||||
} else {
|
||||
sender.sendMessage("SubServers.Sync v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
|
||||
}
|
||||
sender.sendMessage("Host/SubServer List:");
|
||||
for (Host host : hosts.values()) {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}).start();
|
||||
} else if (args[0].equalsIgnoreCase("list")) {
|
||||
plugin.api.getGroups(groups -> plugin.api.getHosts(hosts -> plugin.api.getServers(servers -> plugin.api.getMasterProxy(proxymaster -> plugin.api.getProxies(proxies -> {
|
||||
int i = 0;
|
||||
boolean sent = false;
|
||||
String div = ChatColor.RESET + ", ";
|
||||
if (groups.keySet().size() > 0) {
|
||||
sender.sendMessage("Group/Server List:");
|
||||
for (String group : groups.keySet()) {
|
||||
String message = " ";
|
||||
if (host.isEnabled()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
message += host.getDisplayName() + " (" + host.getAddress().getHostAddress() + ((host.getName().equals(host.getDisplayName()))?"":ChatColor.stripColor(div)+host.getName()) + ")" + ChatColor.RESET + ": ";
|
||||
for (SubServer subserver : host.getSubServers().values()) {
|
||||
message += ChatColor.GOLD + group + ChatColor.RESET + ": ";
|
||||
for (Server server : groups.get(group)) {
|
||||
if (i != 0) message += div;
|
||||
if (subserver.isTemporary()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (subserver.isRunning()) {
|
||||
message += ChatColor.GREEN;
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
if (!(server instanceof SubServer)) {
|
||||
message += ChatColor.WHITE;
|
||||
} else if (((SubServer) server).isRunning()) {
|
||||
if (((SubServer) server).getStopAction() == SubServer.StopAction.REMOVE_SERVER || ((SubServer) server).getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.GREEN;
|
||||
}
|
||||
} else if (((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
message += subserver.getDisplayName() + " (" + subserver.getAddress().getPort() + ((subserver.getName().equals(subserver.getDisplayName()))?"":ChatColor.stripColor(div)+subserver.getName()) + ")";
|
||||
message += server.getDisplayName() + " (" + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort() + ((server.getName().equals(server.getDisplayName())) ? "" : ChatColor.stripColor(div) + server.getName()) + ")";
|
||||
i++;
|
||||
}
|
||||
if (i == 0) message += ChatColor.RESET + "(none)";
|
||||
@ -154,322 +120,364 @@ public final class SubCommand extends CommandX {
|
||||
sent = true;
|
||||
}
|
||||
if (!sent) sender.sendMessage(ChatColor.RESET + "(none)");
|
||||
sender.sendMessage("Server List:");
|
||||
sent = false;
|
||||
}
|
||||
sender.sendMessage("Host/SubServer List:");
|
||||
for (Host host : hosts.values()) {
|
||||
String message = " ";
|
||||
for (Server server : servers.values()) if (!(server instanceof SubServer)) {
|
||||
if (host.isEnabled()) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
message += host.getDisplayName() + " (" + host.getAddress().getHostAddress() + ((host.getName().equals(host.getDisplayName()))?"":ChatColor.stripColor(div)+host.getName()) + ")" + ChatColor.RESET + ": ";
|
||||
for (SubServer subserver : host.getSubServers().values()) {
|
||||
if (i != 0) message += div;
|
||||
message += ChatColor.WHITE + server.getDisplayName() + " (" + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort() + ((server.getName().equals(server.getDisplayName()))?"":ChatColor.stripColor(div)+server.getName()) + ")";
|
||||
if (subserver.isRunning()) {
|
||||
if (subserver.getStopAction() == SubServer.StopAction.REMOVE_SERVER || subserver.getStopAction() == SubServer.StopAction.DELETE_SERVER) {
|
||||
message += ChatColor.AQUA;
|
||||
} else {
|
||||
message += ChatColor.GREEN;
|
||||
}
|
||||
} else if (subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
|
||||
message += ChatColor.YELLOW;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
message += subserver.getDisplayName() + " (" + subserver.getAddress().getPort() + ((subserver.getName().equals(subserver.getDisplayName()))?"":ChatColor.stripColor(div)+subserver.getName()) + ")";
|
||||
i++;
|
||||
}
|
||||
if (i == 0) message += ChatColor.RESET + "(none)";
|
||||
sender.sendMessage(message);
|
||||
if (proxies.keySet().size() > 0) {
|
||||
sender.sendMessage("Proxy List:");
|
||||
message = " (master)";
|
||||
for (Proxy proxy : proxies.values()) {
|
||||
message += div;
|
||||
if (proxy.getSubData() != null && proxy.isRedis()) {
|
||||
message += ChatColor.GREEN;
|
||||
} else if (proxy.getSubData() != null) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (proxy.isRedis()) {
|
||||
message += ChatColor.WHITE;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
message += proxy.getDisplayName() + ((proxy.getName().equals(proxy.getDisplayName()))?"":" ("+proxy.getName()+')');
|
||||
i = 0;
|
||||
sent = true;
|
||||
}
|
||||
if (!sent) sender.sendMessage(ChatColor.RESET + "(none)");
|
||||
sender.sendMessage("Server List:");
|
||||
String message = " ";
|
||||
for (Server server : servers.values()) if (!(server instanceof SubServer)) {
|
||||
if (i != 0) message += div;
|
||||
message += ChatColor.WHITE + server.getDisplayName() + " (" + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort() + ((server.getName().equals(server.getDisplayName()))?"":ChatColor.stripColor(div)+server.getName()) + ")";
|
||||
i++;
|
||||
}
|
||||
if (i == 0) message += ChatColor.RESET + "(none)";
|
||||
sender.sendMessage(message);
|
||||
if (proxies.keySet().size() > 0) {
|
||||
sender.sendMessage("Proxy List:");
|
||||
message = " (master)";
|
||||
for (Proxy proxy : proxies.values()) {
|
||||
message += div;
|
||||
if (proxy.getSubData() != null && proxy.isRedis()) {
|
||||
message += ChatColor.GREEN;
|
||||
} else if (proxy.getSubData() != null) {
|
||||
message += ChatColor.AQUA;
|
||||
} else if (proxy.isRedis()) {
|
||||
message += ChatColor.WHITE;
|
||||
} else {
|
||||
message += ChatColor.RED;
|
||||
}
|
||||
sender.sendMessage(message);
|
||||
message += proxy.getDisplayName() + ((proxy.getName().equals(proxy.getDisplayName()))?"":" ("+proxy.getName()+')');
|
||||
}
|
||||
})))));
|
||||
} else if (args[0].equalsIgnoreCase("info") || args[0].equalsIgnoreCase("status")) {
|
||||
if (args.length > 1) {
|
||||
String type = (args.length > 2)?args[1]:null;
|
||||
String name = args[(type != null)?2:1];
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
})))));
|
||||
} else if (args[0].equalsIgnoreCase("info") || args[0].equalsIgnoreCase("status")) {
|
||||
if (args.length > 1) {
|
||||
String type = (args.length > 2)?args[1]:null;
|
||||
String name = args[(type != null)?2:1];
|
||||
|
||||
Runnable getServer = () -> plugin.api.getServer(name, server -> {
|
||||
if (server != null) {
|
||||
sender.sendMessage("SubServers > Info on " + ((server instanceof SubServer)?"Sub":"") + "Server: " + ChatColor.WHITE + server.getDisplayName());
|
||||
if (!server.getName().equals(server.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + server.getName());
|
||||
if (server instanceof SubServer) {
|
||||
sender.sendMessage(" -> Enabled: " + ((((SubServer) server).isEnabled())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (!((SubServer) server).isEditable()) sender.sendMessage(" -> Editable: " + ChatColor.RED + "no");
|
||||
sender.sendMessage(" -> Host: " + ChatColor.WHITE + ((SubServer) server).getHost());
|
||||
}
|
||||
if (server.getGroups().size() > 0) sender.sendMessage(" -> Group" + ((server.getGroups().size() > 1)?"s:":": " + ChatColor.WHITE + server.getGroups().get(0)));
|
||||
if (server.getGroups().size() > 1) for (String group : server.getGroups()) sender.sendMessage(" - " + ChatColor.WHITE + group);
|
||||
sender.sendMessage(" -> Address: " + ChatColor.WHITE + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort());
|
||||
if (server instanceof SubServer) sender.sendMessage(" -> Running: " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) {
|
||||
sender.sendMessage(" -> Connected: " + ((server.getSubData() != null)?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getPlayers().size() + " online");
|
||||
}
|
||||
sender.sendMessage(" -> MOTD: " + ChatColor.WHITE + ChatColor.stripColor(server.getMotd()));
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + server.getSignature());
|
||||
if (server instanceof SubServer) {
|
||||
sender.sendMessage(" -> Logging: " + ((((SubServer) server).isLogging())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (((SubServer) server).isTemporary()) sender.sendMessage(" -> Temporary: " + ChatColor.GREEN + "yes");
|
||||
else sender.sendMessage(" -> Auto Restart: " + ((((SubServer) server).willAutoRestart())?ChatColor.GREEN+"enabled":ChatColor.RED+"disabled"));
|
||||
}
|
||||
sender.sendMessage(" -> Restricted: " + ((server.isRestricted())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (server instanceof SubServer && ((SubServer) server).getIncompatibilities().size() > 0) {
|
||||
List<String> current = new ArrayList<String>();
|
||||
for (String other : ((SubServer) server).getCurrentIncompatibilities()) current.add(other.toLowerCase());
|
||||
sender.sendMessage(" -> Incompatibilities:");
|
||||
for (String other : ((SubServer) server).getIncompatibilities()) sender.sendMessage(" - " + ((current.contains(other.toLowerCase()))?ChatColor.WHITE:ChatColor.GRAY) + other);
|
||||
}
|
||||
sender.sendMessage(" -> Hidden: " + ((server.isHidden())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
} else {
|
||||
if (type == null) {
|
||||
sender.sendMessage("SubServers > There is no object with that name");
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
}
|
||||
Runnable getServer = () -> plugin.api.getServer(name, server -> {
|
||||
if (server != null) {
|
||||
sender.sendMessage("SubServers > Info on " + ((server instanceof SubServer)?"Sub":"") + "Server: " + ChatColor.WHITE + server.getDisplayName());
|
||||
if (!server.getName().equals(server.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + server.getName());
|
||||
if (server instanceof SubServer) {
|
||||
sender.sendMessage(" -> Enabled: " + ((((SubServer) server).isEnabled())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (!((SubServer) server).isEditable()) sender.sendMessage(" -> Editable: " + ChatColor.RED + "no");
|
||||
sender.sendMessage(" -> Host: " + ChatColor.WHITE + ((SubServer) server).getHost());
|
||||
}
|
||||
});
|
||||
Runnable getGroup = () -> plugin.api.getGroup(name, group -> {
|
||||
if (group != null) {
|
||||
sender.sendMessage("SubServers > Info on Group: " + ChatColor.WHITE + name);
|
||||
sender.sendMessage(" -> Servers: " + ((group.size() <= 0)?ChatColor.GRAY + "(none)":ChatColor.AQUA.toString() + group.size()));
|
||||
for (Server server : group) sender.sendMessage(" - " + ChatColor.WHITE + server.getDisplayName() + ((server.getName().equals(server.getDisplayName()))?"":" ("+server.getName()+')'));
|
||||
} else {
|
||||
if (type == null) {
|
||||
getServer.run();
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no group with that name");
|
||||
}
|
||||
if (server.getGroups().size() > 0) sender.sendMessage(" -> Group" + ((server.getGroups().size() > 1)?"s:":": " + ChatColor.WHITE + server.getGroups().get(0)));
|
||||
if (server.getGroups().size() > 1) for (String group : server.getGroups()) sender.sendMessage(" - " + ChatColor.WHITE + group);
|
||||
sender.sendMessage(" -> Address: " + ChatColor.WHITE + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort());
|
||||
if (server instanceof SubServer) sender.sendMessage(" -> Running: " + ((((SubServer) server).isRunning())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (!(server instanceof SubServer) || ((SubServer) server).isRunning()) {
|
||||
sender.sendMessage(" -> Connected: " + ((server.getSubData() != null)?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Players: " + ChatColor.AQUA + server.getPlayers().size() + " online");
|
||||
}
|
||||
});
|
||||
Runnable getHost = () -> plugin.api.getHost(name, host -> {
|
||||
if (host != null) {
|
||||
sender.sendMessage("SubServers > Info on Host: " + ChatColor.WHITE + host.getDisplayName());
|
||||
if (!host.getName().equals(host.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + host.getName());
|
||||
sender.sendMessage(" -> Enabled: " + ((host.isEnabled())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Address: " + ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
if (host.getSubData() != null) sender.sendMessage(" -> Connected: " + ChatColor.GREEN + "yes");
|
||||
sender.sendMessage(" -> SubServers: " + ((host.getSubServers().keySet().size() <= 0)?ChatColor.GRAY + "(none)":ChatColor.AQUA.toString() + host.getSubServers().keySet().size()));
|
||||
for (SubServer subserver : host.getSubServers().values()) sender.sendMessage(" - " + ((subserver.isEnabled())?ChatColor.WHITE:ChatColor.GRAY) + subserver.getDisplayName() + ((subserver.getName().equals(subserver.getDisplayName()))?"":" ("+subserver.getName()+')'));
|
||||
sender.sendMessage(" -> Templates: " + ((host.getCreator().getTemplates().keySet().size() <= 0)?ChatColor.GRAY + "(none)":ChatColor.AQUA.toString() + host.getCreator().getTemplates().keySet().size()));
|
||||
for (SubCreator.ServerTemplate template : host.getCreator().getTemplates().values()) sender.sendMessage(" - " + ((template.isEnabled())?ChatColor.WHITE:ChatColor.GRAY) + template.getDisplayName() + ((template.getName().equals(template.getDisplayName()))?"":" ("+template.getName()+')'));
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + host.getSignature());
|
||||
} else {
|
||||
if (type == null) {
|
||||
getGroup.run();
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no host with that name");
|
||||
}
|
||||
sender.sendMessage(" -> MOTD: " + ChatColor.WHITE + ChatColor.stripColor(server.getMotd()));
|
||||
if (server instanceof SubServer && ((SubServer) server).getStopAction() != SubServer.StopAction.NONE) sender.sendMessage(" -> Stop Action: " + ChatColor.WHITE + ((SubServer) server).getStopAction().toString());
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + server.getSignature());
|
||||
if (server instanceof SubServer) sender.sendMessage(" -> Logging: " + ((((SubServer) server).isLogging())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Restricted: " + ((server.isRestricted())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
if (server instanceof SubServer && ((SubServer) server).getIncompatibilities().size() > 0) {
|
||||
List<String> current = new ArrayList<String>();
|
||||
for (String other : ((SubServer) server).getCurrentIncompatibilities()) current.add(other.toLowerCase());
|
||||
sender.sendMessage(" -> Incompatibilities:");
|
||||
for (String other : ((SubServer) server).getIncompatibilities()) sender.sendMessage(" - " + ((current.contains(other.toLowerCase()))?ChatColor.WHITE:ChatColor.GRAY) + other);
|
||||
}
|
||||
});
|
||||
Runnable getProxy = () -> plugin.api.getProxy(name, proxy -> {
|
||||
if (proxy != null) {
|
||||
sender.sendMessage("SubServers > Info on Proxy: " + ChatColor.WHITE + proxy.getDisplayName());
|
||||
if (!proxy.getName().equals(proxy.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + proxy.getName());
|
||||
sender.sendMessage(" -> Connected: " + ((proxy.getSubData() != null)?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Redis: " + ((proxy.isRedis())?ChatColor.GREEN:ChatColor.RED+"un") + "available");
|
||||
if (proxy.isRedis()) sender.sendMessage(" -> Players: " + ChatColor.AQUA + proxy.getPlayers().size() + " online");
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + proxy.getSignature());
|
||||
sender.sendMessage(" -> Hidden: " + ((server.isHidden())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
} else {
|
||||
if (type == null) {
|
||||
sender.sendMessage("SubServers > There is no object with that name");
|
||||
} else {
|
||||
if (type == null) {
|
||||
getHost.run();
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no proxy with that name");
|
||||
}
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Runnable getGroup = () -> plugin.api.getGroup(name, group -> {
|
||||
if (group != null) {
|
||||
sender.sendMessage("SubServers > Info on Group: " + ChatColor.WHITE + name);
|
||||
sender.sendMessage(" -> Servers: " + ((group.size() <= 0)?ChatColor.GRAY + "(none)":ChatColor.AQUA.toString() + group.size()));
|
||||
for (Server server : group) sender.sendMessage(" - " + ChatColor.WHITE + server.getDisplayName() + ((server.getName().equals(server.getDisplayName()))?"":" ("+server.getName()+')'));
|
||||
} else {
|
||||
if (type == null) {
|
||||
getServer.run();
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no group with that name");
|
||||
}
|
||||
}
|
||||
});
|
||||
Runnable getHost = () -> plugin.api.getHost(name, host -> {
|
||||
if (host != null) {
|
||||
sender.sendMessage("SubServers > Info on Host: " + ChatColor.WHITE + host.getDisplayName());
|
||||
if (!host.getName().equals(host.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + host.getName());
|
||||
sender.sendMessage(" -> Available: " + ((host.isAvailable())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Enabled: " + ((host.isEnabled())?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Address: " + ChatColor.WHITE + host.getAddress().getHostAddress());
|
||||
if (host.getSubData() != null) sender.sendMessage(" -> Connected: " + ChatColor.GREEN + "yes");
|
||||
sender.sendMessage(" -> SubServers: " + ((host.getSubServers().keySet().size() <= 0)?ChatColor.GRAY + "(none)":ChatColor.AQUA.toString() + host.getSubServers().keySet().size()));
|
||||
for (SubServer subserver : host.getSubServers().values()) sender.sendMessage(" - " + ((subserver.isEnabled())?ChatColor.WHITE:ChatColor.GRAY) + subserver.getDisplayName() + ((subserver.getName().equals(subserver.getDisplayName()))?"":" ("+subserver.getName()+')'));
|
||||
sender.sendMessage(" -> Templates: " + ((host.getCreator().getTemplates().keySet().size() <= 0)?ChatColor.GRAY + "(none)":ChatColor.AQUA.toString() + host.getCreator().getTemplates().keySet().size()));
|
||||
for (SubCreator.ServerTemplate template : host.getCreator().getTemplates().values()) sender.sendMessage(" - " + ((template.isEnabled())?ChatColor.WHITE:ChatColor.GRAY) + template.getDisplayName() + ((template.getName().equals(template.getDisplayName()))?"":" ("+template.getName()+')'));
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + host.getSignature());
|
||||
} else {
|
||||
if (type == null) {
|
||||
getGroup.run();
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no host with that name");
|
||||
}
|
||||
}
|
||||
});
|
||||
Runnable getProxy = () -> plugin.api.getProxy(name, proxy -> {
|
||||
if (proxy != null) {
|
||||
sender.sendMessage("SubServers > Info on Proxy: " + ChatColor.WHITE + proxy.getDisplayName());
|
||||
if (!proxy.getName().equals(proxy.getDisplayName())) sender.sendMessage(" -> System Name: " + ChatColor.WHITE + proxy.getName());
|
||||
sender.sendMessage(" -> Connected: " + ((proxy.getSubData() != null)?ChatColor.GREEN+"yes":ChatColor.RED+"no"));
|
||||
sender.sendMessage(" -> Redis: " + ((proxy.isRedis())?ChatColor.GREEN:ChatColor.RED+"un") + "available");
|
||||
if (proxy.isRedis()) sender.sendMessage(" -> Players: " + ChatColor.AQUA + proxy.getPlayers().size() + " online");
|
||||
sender.sendMessage(" -> Signature: " + ChatColor.AQUA + proxy.getSignature());
|
||||
} else {
|
||||
if (type == null) {
|
||||
getHost.run();
|
||||
} else {
|
||||
sender.sendMessage("SubServers > There is no proxy with that name");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (type == null) {
|
||||
getProxy.run();
|
||||
} else {
|
||||
switch (type.toLowerCase()) {
|
||||
case "p":
|
||||
case "proxy":
|
||||
getProxy.run();
|
||||
break;
|
||||
case "h":
|
||||
case "host":
|
||||
getHost.run();
|
||||
break;
|
||||
case "g":
|
||||
case "group":
|
||||
getGroup.run();
|
||||
break;
|
||||
case "s":
|
||||
case "server":
|
||||
case "subserver":
|
||||
getServer.run();
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage("SubServers > There is no object type with that name");
|
||||
}
|
||||
if (type == null) {
|
||||
getProxy.run();
|
||||
} else {
|
||||
switch (type.toLowerCase()) {
|
||||
case "p":
|
||||
case "proxy":
|
||||
getProxy.run();
|
||||
break;
|
||||
case "h":
|
||||
case "host":
|
||||
getHost.run();
|
||||
break;
|
||||
case "g":
|
||||
case "group":
|
||||
getGroup.run();
|
||||
break;
|
||||
case "s":
|
||||
case "server":
|
||||
case "subserver":
|
||||
getServer.run();
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage("SubServers > There is no object type with that name");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("SubServers > Usage: " + label + " " + args[1].toLowerCase() + " [proxy|host|group|server] <Name>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("start")) {
|
||||
if (args.length > 1) {
|
||||
plugin.subdata.sendPacket(new PacketStartServer(null, args[1], data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer's Host is not enabled");
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage("SubServers > That SubServer is not enabled");
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage("SubServers > That SubServer is already running");
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessages("That SubServer cannot start while these server(s) are running:", data.getRawString("m").split(":\\s")[1]);
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Server was started successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketStartServer(null, " + args[1] + ") responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Server was started successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
if (args.length > 1) {
|
||||
plugin.subdata.sendPacket(new PacketStopServer(null, args[1], false, data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer is not running");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Server was stopped successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketStopServer(null, " + args[1] + ", false) responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Server was stopped successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("kill") || args[0].equalsIgnoreCase("terminate")) {
|
||||
if (args.length > 1) {
|
||||
plugin.subdata.sendPacket(new PacketStopServer(null, args[1], true, data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer is not running");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Server was terminated successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketStopServer(null, " + args[1] + ", true) responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Server was terminated successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
|
||||
if (args.length > 2) {
|
||||
int i = 2;
|
||||
String str = args[2];
|
||||
if (args.length > 3) {
|
||||
do {
|
||||
i++;
|
||||
str = str + " " + args[i];
|
||||
} while ((i + 1) != args.length);
|
||||
}
|
||||
final String cmd = str;
|
||||
plugin.subdata.sendPacket(new PacketCommandServer(null, args[1], cmd, data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer is not running");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Command was sent successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketCommandServer(null, " + args[1] + ", /" + cmd + ") responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Command was sent successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer> <Command> [Args...]");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("create")) {
|
||||
if (args.length > 5) {
|
||||
if (Util.isException(() -> Integer.parseInt(args[5]))) {
|
||||
sender.sendMessage("Invalid Port Number");
|
||||
} else {
|
||||
plugin.subdata.sendPacket(new PacketCreateServer(null, args[1], args[2],args[3], new Version(args[4]), Integer.parseInt(args[5]), data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > There is already a SubServer with that name");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > There is no host with that name");
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage("SubServers > There is no template with that name");
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage("SubServers > SubCreator cannot create servers before Minecraft 1.8");
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage("SubServers > Invalid Port Number");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Launching SubCreator...");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketCreateServer(null, " + args[1] + ", " + args[2] + ", " + args[3] + ", " + args[4] + ", " + args[5] + ") responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Launching SubCreator...");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <Name> <Host> <Template> <Version> <Port>");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("SubServers > Unknown sub-command: " + args[0]);
|
||||
sender.sendMessage("SubServers > Usage: " + label + " " + args[1].toLowerCase() + " [proxy|host|group|server] <Name>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("start")) {
|
||||
if (args.length > 1) {
|
||||
plugin.subdata.sendPacket(new PacketStartServer(null, args[1], data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer's Host is not available");
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage("SubServers > That SubServer's Host is not enabled");
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage("SubServers > That SubServer is not enabled");
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage("SubServers > That SubServer is already running");
|
||||
break;
|
||||
case 9:
|
||||
sender.sendMessages("That SubServer cannot start while these server(s) are running:", data.getRawString("m").split(":\\s")[1]);
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Server was started successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketStartServer(null, " + args[1] + ") responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Server was started successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("stop")) {
|
||||
if (args.length > 1) {
|
||||
plugin.subdata.sendPacket(new PacketStopServer(null, args[1], false, data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer is not running");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Server was stopped successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketStopServer(null, " + args[1] + ", false) responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Server was stopped successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("kill") || args[0].equalsIgnoreCase("terminate")) {
|
||||
if (args.length > 1) {
|
||||
plugin.subdata.sendPacket(new PacketStopServer(null, args[1], true, data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer is not running");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Server was terminated successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketStopServer(null, " + args[1] + ", true) responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Server was terminated successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer>");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("cmd") || args[0].equalsIgnoreCase("command")) {
|
||||
if (args.length > 2) {
|
||||
int i = 2;
|
||||
String str = args[2];
|
||||
if (args.length > 3) {
|
||||
do {
|
||||
i++;
|
||||
str = str + " " + args[i];
|
||||
} while ((i + 1) != args.length);
|
||||
}
|
||||
final String cmd = str;
|
||||
plugin.subdata.sendPacket(new PacketCommandServer(null, args[1], cmd, data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
sender.sendMessage("SubServers > There is no server with that name");
|
||||
break;
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > That Server is not a SubServer");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > That SubServer is not running");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Command was sent successfully");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketCommandServer(null, " + args[1] + ", /" + cmd + ") responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Command was sent successfully");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <SubServer> <Command> [Args...]");
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("create")) {
|
||||
if (args.length > 5) {
|
||||
if (Util.isException(() -> Integer.parseInt(args[5]))) {
|
||||
sender.sendMessage("Invalid Port Number");
|
||||
} else {
|
||||
plugin.subdata.sendPacket(new PacketCreateServer(null, args[1], args[2],args[3], new Version(args[4]), Integer.parseInt(args[5]), data -> {
|
||||
switch (data.getInt("r")) {
|
||||
case 3:
|
||||
case 4:
|
||||
sender.sendMessage("SubServers > There is already a SubServer with that name");
|
||||
break;
|
||||
case 5:
|
||||
sender.sendMessage("SubServers > There is no host with that name");
|
||||
break;
|
||||
case 6:
|
||||
sender.sendMessage("SubServers > That Host is not available");
|
||||
break;
|
||||
case 7:
|
||||
sender.sendMessage("SubServers > That Host is not enabled");
|
||||
break;
|
||||
case 8:
|
||||
sender.sendMessage("SubServers > There is no template with that name");
|
||||
break;
|
||||
case 9:
|
||||
sender.sendMessage("SubServers > That Template is not available");
|
||||
break;
|
||||
case 10:
|
||||
sender.sendMessage("SubServers > SubCreator cannot create servers before Minecraft 1.8");
|
||||
break;
|
||||
case 11:
|
||||
sender.sendMessage("SubServers > Invalid Port Number");
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
sender.sendMessage("SubServers > Launching SubCreator...");
|
||||
break;
|
||||
default:
|
||||
System.out.println("PacketCreateServer(null, " + args[1] + ", " + args[2] + ", " + args[3] + ", " + args[4] + ", " + args[5] + ") responded with: " + data.getRawString("m"));
|
||||
sender.sendMessage("SubServers > Launching SubCreator...");
|
||||
break;
|
||||
}
|
||||
}));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("Usage: " + label + " <Name> <Host> <Template> <Version> <Port>");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessages(printHelp());
|
||||
sender.sendMessage("SubServers > Unknown sub-command: " + args[0]);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessages(printHelp());
|
||||
}
|
||||
} else {
|
||||
String str = label;
|
||||
|
@ -183,7 +183,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return (isPatched)?"SubServers.Sync":super.getName();
|
||||
return (isPatched)?"SubServers Platform":super.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user