#50 #46 Selecting Multiple Servers

This commit includes the following major changes and additions:
-> New Command & Permission Formatting
-> RemotePlayer API
-> SubData with Blocks
This commit is contained in:
ME1312 2020-06-12 01:45:49 -04:00
parent caf8ee793d
commit bb0dd55c95
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
150 changed files with 7996 additions and 4390 deletions

1
.gitignore vendored
View File

@ -42,6 +42,7 @@ crashlytics-build.properties
/Artifacts/-Icon/
/Artifacts/-Lite/
/Artifacts/*.jar
/BungeeCord/
/Javadoc/
/SubServers.Test/
/build.ant

Binary file not shown.

View File

@ -12,7 +12,7 @@ SubServers 2 is a rewrite of SubServers, the Server Management Platform.<br>
These are some quick links for common resources of SubServers 2.
### How to Install
> [https://github.com/ME1312/SubServers-2/wiki/Install](https://github.com/ME1312/SubServers-2/wiki/Install)
> [https://github.com/ME1312/SubServers-2/wiki/Install](https://github.com/ME1312/SubServers-2/wiki/Installation)
### Snapshot Downloads
> [https://dev.me1312.net/jenkins/job/SubServers Platform](https://dev.me1312.net/jenkins/job/SubServers%20Platform)

View File

@ -30,20 +30,20 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>20w08c</version>
<version>20w15a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiEngine</artifactId>
<version>20w08c</version>
<version>20w15a</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Server</artifactId>
<version>20w07d</version>
<version>20w15a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -162,7 +162,7 @@
<configuration>
<windowtitle>SubServers.Bungee Javadoc</windowtitle>
<doctitle>SubServers.Bungee Javadoc</doctitle>
<show>public</show>
<show>protected</show>
<destDir>./</destDir>
<outputDirectory>${basedir}/../Javadoc/SubServers.Bungee</outputDirectory>
<reportOutputDirectory>${basedir}/../Javadoc/SubServers.Bungee</reportOutputDirectory>

View File

@ -3,7 +3,7 @@ package net.ME1312.SubServers.Bungee.Event;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubServers.Bungee.Library.SubEvent;
import net.ME1312.Galaxi.Library.Util;
import net.md_5.bungee.api.plugin.Cancellable;

View File

@ -31,14 +31,14 @@ public class ExternalHost extends Host implements ClientHandler {
private HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
private HashMap<String, SubServer> servers = new HashMap<String, SubServer>();
private String name;
protected boolean available;
boolean available;
private boolean enabled;
private InetAddress address;
private SubCreator creator;
private String directory;
private LinkedList<PacketOut> queue;
private boolean clean;
protected SubProxy plugin;
SubProxy plugin;
/**
* Creates an External Host
@ -93,7 +93,7 @@ public class ExternalHost extends Host implements ClientHandler {
for (Integer channel : Util.getBackwards(subdata, (SubDataClient) client)) setSubData(null, channel);
}
protected void queue(PacketOut... packet) {
void queue(PacketOut... packet) {
for (PacketOut p : packet) if (getSubData()[0] == null || !available) {
queue.add(p);
} else {
@ -167,7 +167,7 @@ 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, String 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!");
ExternalSubServer server = new ExternalSubServer(this, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
ExternalSubServer server = ExternalSubServer.construct(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()) {
@ -184,18 +184,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();
String server = servers.get(name.toLowerCase()).getName();
SubServer server = servers.get(name.toLowerCase());
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, server);
plugin.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (getSubServer(server).isRunning()) {
getSubServer(server).stop();
getSubServer(server).waitFor();
if (server.isRunning()) {
server.stop();
server.waitFor();
}
queue(new PacketExRemoveServer(server, data -> {
queue(new PacketExRemoveServer(name.toLowerCase(), data -> {
if (data.getInt(0x0001) == 0 || data.getInt(0x0001) == 1) {
servers.remove(server.toLowerCase());
servers.remove(name.toLowerCase());
}
}));
return true;
@ -205,17 +205,17 @@ public class ExternalHost extends Host implements ClientHandler {
@Override
public boolean forceRemoveSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubServer server = servers.get(name.toLowerCase());
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, server);
plugin.getPluginManager().callEvent(event);
if (getSubServer(server).isRunning()) {
getSubServer(server).stop();
getSubServer(server).waitFor();
if (server.isRunning()) {
server.stop();
server.waitFor();
}
queue(new PacketExRemoveServer(server, data -> {
queue(new PacketExRemoveServer(name.toLowerCase(), data -> {
if (data.getInt(0x0001) == 0 || data.getInt(0x0001) == 1) {
servers.remove(server.toLowerCase());
servers.remove(name.toLowerCase());
}
}));
return true;
@ -224,14 +224,15 @@ public class ExternalHost extends Host implements ClientHandler {
@Override
public boolean recycleSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubServer s = servers.get(name.toLowerCase());
String server = s.getName();
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, s);
plugin.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (getSubServer(server).isRunning()) {
getSubServer(server).stop();
getSubServer(server).waitFor();
if (s.isRunning()) {
s.stop();
s.waitFor();
}
Logger.get("SubServers").info("Saving...");
@ -263,12 +264,14 @@ public class ExternalHost extends Host implements ClientHandler {
@Override
public boolean forceRecycleSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubServer s = servers.get(name.toLowerCase());
String server = s.getName();
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, s);
plugin.getPluginManager().callEvent(event);
if (getSubServer(server).isRunning()) {
getSubServer(server).terminate();
if (s.isRunning()) {
s.stop();
s.waitFor();
}
Logger.get("SubServers").info("Saving...");
@ -287,7 +290,6 @@ public class ExternalHost extends Host implements ClientHandler {
Logger.get("SubServers").info("Moving Files...");
queue(new PacketExDeleteServer(server, info, true, data -> {
if (data.getInt(0x0001) == 0 || data.getInt(0x0001) == 1) {
for (String group : getSubServer(server).getGroups()) getSubServer(server).removeGroup(group);
servers.remove(server.toLowerCase());
Logger.get("SubServers").info("Deleted SubServer: " + server);
} else {
@ -300,14 +302,15 @@ public class ExternalHost extends Host implements ClientHandler {
@Override
public boolean deleteSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubServer s = servers.get(name.toLowerCase());
String server = s.getName();
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
plugin.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (getSubServer(server).isRunning()) {
getSubServer(server).stop();
getSubServer(server).waitFor();
if (s.isRunning()) {
s.stop();
s.waitFor();
}
Logger.get("SubServers").info("Saving...");
@ -339,12 +342,14 @@ public class ExternalHost extends Host implements ClientHandler {
@Override
public boolean forceDeleteSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubServer s = servers.get(name.toLowerCase());
String server = s.getName();
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
plugin.getPluginManager().callEvent(event);
if (getSubServer(server).isRunning()) {
getSubServer(server).terminate();
if (s.isRunning()) {
s.stop();
s.waitFor();
}
Logger.get("SubServers").info("Saving...");
@ -363,7 +368,6 @@ public class ExternalHost extends Host implements ClientHandler {
Logger.get("SubServers").info("Removing Files...");
queue(new PacketExDeleteServer(server, info, false, data -> {
if (data.getInt(0x0001) == 0 || data.getInt(0x0001) == 1) {
for (String group : getSubServer(server).getGroups()) getSubServer(server).removeGroup(group);
servers.remove(server.toLowerCase());
Logger.get("SubServers").info("Deleted SubServer: " + server);
} else {

View File

@ -4,6 +4,8 @@ import com.google.common.collect.Range;
import net.ME1312.Galaxi.Library.*;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Callback.ReturnCallback;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
import net.ME1312.SubServers.Bungee.Event.SubCreatedEvent;
@ -103,7 +105,7 @@ public class ExternalSubCreator extends SubCreator {
if (!event.isCancelled()) {
Container<String> address = new Container<>("$address$");
ReturnCallback<Object, Object> conversion = obj -> convert(obj, new NamedContainer<>("$player$", (player == null)?"":player.toString()), new NamedContainer<>("$name$", name),
new NamedContainer<>("$template$", template.getName()), new NamedContainer<>("$type$", template.getType().toString()), new NamedContainer<>("$version$", (version != null)?version.toString().replace(" ", "@"):""),
new NamedContainer<>("$host$", host.getName()), new NamedContainer<>("$template$", template.getName()), new NamedContainer<>("$type$", template.getType().toString()), new NamedContainer<>("$version$", (version != null)?version.toString():""),
new NamedContainer<>("$address$", address.get()), new NamedContainer<>("$port$", Integer.toString(fport)));
logger.start();
@ -212,7 +214,7 @@ public class ExternalSubCreator extends SubCreator {
String name = server.getName();
String prefix = name + File.separator + "Updater";
Util.isException(() -> Util.reflect(SubServerContainer.class.getDeclaredField("updating"), server, true));
Util.isException(() -> Util.reflect(SubServerImpl.class.getDeclaredField("updating"), server, true));
ExternalSubLogger logger = new ExternalSubLogger(this, prefix, log, null);
thread.put(name.toLowerCase(), new NamedContainer<>(server.getAddress().getPort(), logger));
@ -221,7 +223,7 @@ public class ExternalSubCreator extends SubCreator {
if (!event.isCancelled()) {
logger.start();
host.queue(new PacketExCreateServer(server, version, logger.getExternalAddress(), data -> {
Util.isException(() -> Util.reflect(SubServerContainer.class.getDeclaredField("updating"), server, false));
Util.isException(() -> Util.reflect(SubServerImpl.class.getDeclaredField("updating"), server, false));
if (data.getInt(0x0001) == 0) {
Logger.get(prefix).info("Saving...");
} else {

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Bungee.Host.External;
import net.ME1312.SubServers.Bungee.Host.SubLogFilter;
import net.ME1312.SubServers.Bungee.Host.SubLogger;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketInExLogMessage;
@ -27,11 +27,11 @@ import java.util.regex.Pattern;
*/
public class ExternalSubLogger extends SubLogger {
private Object handle;
protected UUID id = null;
protected String name;
protected Container<Boolean> log;
UUID id = null;
String name;
Container<Boolean> log;
private List<SubLogFilter> filters = new CopyOnWriteArrayList<>();
protected File file;
File file;
private PrintWriter writer = null;
private boolean started = false;
@ -43,7 +43,7 @@ public class ExternalSubLogger extends SubLogger {
* @param log Console Logging Status
* @param file File to log to (or null for disabled)
*/
protected ExternalSubLogger(Object user, String name, Container<Boolean> log, File file) {
ExternalSubLogger(Object user, String name, Container<Boolean> log, File file) {
this.handle = user;
this.name = name;
this.log = log;

View File

@ -5,10 +5,10 @@ import net.ME1312.SubServers.Bungee.Event.*;
import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExEditServer;
import net.md_5.bungee.BungeeServerInfo;
@ -24,12 +24,12 @@ import java.util.UUID;
/**
* External SubServer Class
*/
public class ExternalSubServer extends SubServerContainer {
public class ExternalSubServer extends SubServerImpl {
private ExternalHost host;
private boolean enabled;
private Container<Boolean> log;
private String dir;
protected String exec;
String exec;
private String stopcmd;
private StopAction stopaction;
private LinkedList<LoggedCommand> history;
@ -53,8 +53,33 @@ public class ExternalSubServer extends SubServerContainer {
* @param restricted Restricted Status
* @throws InvalidServerException
*/
public ExternalSubServer(ExternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
public static ExternalSubServer construct(ExternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
try {
return new ExternalSubServer(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
} catch (NoSuchMethodError e) {
return new ExternalSubServer(host, name, enabled, (Integer) port, motd, log, directory, executable, stopcmd, hidden, restricted);
}
}
/**
* Super Method 2 (newest)
* @see #construct(ExternalHost, String, boolean, int, String, boolean, String, String, String, boolean, boolean) for method details
*/
protected ExternalSubServer(ExternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
super(host, name, port, motd, hidden, restricted);
init(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
}
/**
* Super Method 1 (oldest)
* @see #construct(ExternalHost, String, boolean, int, String, boolean, String, String, String, boolean, boolean) for method details
*/
protected ExternalSubServer(ExternalHost host, String name, boolean enabled, Integer port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
super(host, name, port, motd, hidden, restricted);
init(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
}
private void init(ExternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
if (Util.isNull(host, name, enabled, port, motd, log, stopcmd, hidden, restricted)) throw new NullPointerException();
this.host = host;
this.enabled = enabled;
@ -226,7 +251,7 @@ public class ExternalSubServer extends SubServerContainer {
break;
case "display":
if (value.isString()) {
Field f = ServerContainer.class.getDeclaredField("nick");
Field f = ServerImpl.class.getDeclaredField("nick");
f.setAccessible(true);
if (value.isNull() || value.asString().length() == 0 || getName().equals(value.asString())) {
f.set(this, null);
@ -259,7 +284,7 @@ public class ExternalSubServer extends SubServerContainer {
break;
case "group":
if (value.isList()) {
Util.reflect(ServerContainer.class.getDeclaredField("groups"), this, value.asStringList());
Util.reflect(ServerImpl.class.getDeclaredField("groups"), this, value.asStringList());
if (perma && this.host.plugin.servers.get().getMap("Servers").getKeys().contains(getName())) {
this.host.plugin.servers.get().getMap("Servers").getMap(getName()).set("Group", value.asStringList());
this.host.plugin.servers.save();
@ -283,7 +308,7 @@ public class ExternalSubServer extends SubServerContainer {
break;
case "template":
if (value.isString()) {
Util.reflect(SubServerContainer.class.getDeclaredField("template"), this, value.asString());
Util.reflect(SubServerImpl.class.getDeclaredField("template"), this, value.asString());
if (perma && this.host.plugin.servers.get().getMap("Servers").getKeys().contains(getName())) {
this.host.plugin.servers.get().getMap("Servers").getMap(getName()).set("Template", value.asString());
this.host.plugin.servers.save();
@ -422,7 +447,7 @@ public class ExternalSubServer extends SubServerContainer {
break;
case "hidden":
if (value.isBoolean()) {
Util.reflect(ServerContainer.class.getDeclaredField("hidden"), this, value.asBoolean());
Util.reflect(ServerImpl.class.getDeclaredField("hidden"), this, value.asBoolean());
if (perma && this.host.plugin.servers.get().getMap("Servers").getKeys().contains(getName())) {
this.host.plugin.servers.get().getMap("Servers").getMap(getName()).set("Hidden", isHidden());
this.host.plugin.servers.save();
@ -432,7 +457,7 @@ public class ExternalSubServer extends SubServerContainer {
break;
case "whitelist":
if (value.isList()) {
Util.reflect(ServerContainer.class.getDeclaredField("whitelist"), this, value.asUUIDList());
Util.reflect(ServerImpl.class.getDeclaredField("whitelist"), this, value.asUUIDList());
c++;
}
break;
@ -441,7 +466,7 @@ public class ExternalSubServer extends SubServerContainer {
forward.setStopAction(getStopAction());
if (!getName().equals(getDisplayName())) forward.setDisplayName(getDisplayName());
List<String> groups = new ArrayList<String>();
Util.reflect(SubServerContainer.class.getDeclaredField("template"), forward, Util.reflect(SubServerContainer.class.getDeclaredField("template"), this));
Util.reflect(SubServerImpl.class.getDeclaredField("template"), forward, Util.reflect(SubServerImpl.class.getDeclaredField("template"), this));
groups.addAll(getGroups());
for (String group : groups) {
removeGroup(group);

View File

@ -9,6 +9,7 @@ import net.ME1312.Galaxi.Library.ExtraDataHandler;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.net.InetAddress;
import java.util.*;
@ -108,6 +109,32 @@ public abstract class Host implements ExtraDataHandler {
}
}
/**
* Get players on servers provided by this host
*
* @return Local Player Collection
*/
public Collection<ProxiedPlayer> getPlayers() {
LinkedList<ProxiedPlayer> players = new LinkedList<ProxiedPlayer>();
for (SubServer server : getSubServers().values()) {
players.addAll(server.getPlayers());
}
return players;
}
/**
* Get players on servers provided by this host across all known proxies
*
* @return Remote Player Collection
*/
public Collection<RemotePlayer> getGlobalPlayers() {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (SubServer server : getSubServers().values()) {
players.addAll(server.getGlobalPlayers());
}
return players;
}
/**
* Starts the Servers Specified
*

View File

@ -31,7 +31,7 @@ public class InternalHost extends Host {
private InetAddress address;
private SubCreator creator;
private String directory;
protected SubProxy plugin;
SubProxy plugin;
/**
* Creates an Internal Host
@ -100,7 +100,7 @@ public class InternalHost extends Host {
@Override
public SubServer addSubServer(UUID player, String name, boolean enabled, int port, String motd, boolean log, String directory, String 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);
SubServer server = InternalSubServer.construct(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()) {
@ -115,17 +115,17 @@ public class InternalHost extends Host {
@Override
public boolean removeSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
SubServer server = servers.get(name.toLowerCase());
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, server);
plugin.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (getSubServer(server).isRunning()) {
getSubServer(server).stop();
getSubServer(server).waitFor();
if (server.isRunning()) {
server.stop();
server.waitFor();
}
if (UPnP.isUPnPAvailable() && UPnP.isMappedTCP(getSubServer(server).getAddress().getPort()))
UPnP.closePortTCP(getSubServer(server).getAddress().getPort());
servers.remove(server.toLowerCase());
if (UPnP.isUPnPAvailable() && UPnP.isMappedTCP(server.getAddress().getPort()))
UPnP.closePortTCP(server.getAddress().getPort());
servers.remove(name.toLowerCase());
return true;
} else return false;
}
@ -133,16 +133,16 @@ public class InternalHost extends Host {
@Override
public boolean forceRemoveSubServer(UUID player, String name) throws InterruptedException {
if (Util.isNull(name)) throw new NullPointerException();
String server = servers.get(name.toLowerCase()).getName();
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, getSubServer(server));
SubServer server = servers.get(name.toLowerCase());
SubRemoveServerEvent event = new SubRemoveServerEvent(player, this, server);
plugin.getPluginManager().callEvent(event);
if (getSubServer(server).isRunning()) {
getSubServer(server).stop();
getSubServer(server).waitFor();
if (server.isRunning()) {
server.stop();
server.waitFor();
}
if (UPnP.isUPnPAvailable() && UPnP.isMappedTCP(getSubServer(server).getAddress().getPort()))
UPnP.closePortTCP(getSubServer(server).getAddress().getPort());
servers.remove(server.toLowerCase());
if (UPnP.isUPnPAvailable() && UPnP.isMappedTCP(server.getAddress().getPort()))
UPnP.closePortTCP(server.getAddress().getPort());
servers.remove(name.toLowerCase());
return true;
}

View File

@ -6,6 +6,8 @@ import net.ME1312.Galaxi.Library.*;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Callback.ReturnCallback;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
import net.ME1312.SubServers.Bungee.Event.SubCreatedEvent;
import net.ME1312.SubServers.Bungee.Host.*;
@ -202,7 +204,7 @@ public class InternalSubCreator extends SubCreator {
public void run() {
ReturnCallback<Object, Object> conversion = obj -> convert(obj, new NamedContainer<>("$player$", (player == null)?"":player.toString()), new NamedContainer<>("$name$", name),
new NamedContainer<>("$template$", template.getName()), new NamedContainer<>("$type$", template.getType().toString()), new NamedContainer<>("$version$", (version != null)?version.toString().replace(" ", "@"):""),
new NamedContainer<>("$host$", host.getName()), new NamedContainer<>("$template$", template.getName()), new NamedContainer<>("$type$", template.getType().toString()), new NamedContainer<>("$version$", (version != null)?version.toString():""),
new NamedContainer<>("$address$", host.getAddress().getHostAddress()), new NamedContainer<>("$port$", Integer.toString(port)));
File dir = (update != null)?new File(update.getFullPath()):new File(host.getPath(),
@ -391,10 +393,10 @@ public class InternalSubCreator extends SubCreator {
if (host.isAvailable() && host.isEnabled() && host == server.getHost() && server.isAvailable() && !server.isRunning() && server.getTemplate() != null && server.getTemplate().isEnabled() && server.getTemplate().canUpdate() && (version != null || !server.getTemplate().requiresVersion())) {
StackTraceElement[] origin = new Exception().getStackTrace();
Util.isException(() -> Util.reflect(SubServerContainer.class.getDeclaredField("updating"), server, true));
Util.isException(() -> Util.reflect(SubServerImpl.class.getDeclaredField("updating"), server, true));
CreatorTask task = new CreatorTask(player, server, version, x -> {
Util.isException(() -> Util.reflect(SubServerContainer.class.getDeclaredField("updating"), server, false));
Util.isException(() -> Util.reflect(SubServerImpl.class.getDeclaredField("updating"), server, false));
if (callback != null) try {
callback.run(x != null);
} catch (Throwable e) {
@ -525,6 +527,17 @@ public class InternalSubCreator extends SubCreator {
return getTemplates().get(name.toLowerCase());
}
private static NamedContainer<YAMLSection, Map<String, Object>> subdata = null;
private Map<String, Object> getSubDataConfig() {
if (subdata == null || host.plugin.config.get() != subdata.name()) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("Address", host.plugin.config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1").replace("0.0.0.0", "127.0.0.1"));
if (host.plugin.config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() > 0) map.put("Password", host.plugin.config.get().getMap("Settings").getMap("SubData").getRawString("Password"));
subdata = new NamedContainer<>(host.plugin.config.get(), map);
}
return subdata.get();
}
private void generateClient(File dir, ServerType type, String name) throws IOException {
if (new UniversalFile(dir, "subservers.client").exists()) {
Files.delete(new UniversalFile(dir, "subservers.client").toPath());
@ -540,8 +553,7 @@ public class InternalSubCreator extends SubCreator {
YAMLSection config = new YAMLSection();
FileWriter writer = new FileWriter(new UniversalFile(dir, "subdata.json"), false);
config.set("Name", name);
config.set("Address", host.plugin.config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1").replace("0.0.0.0", "127.0.0.1"));
if (host.plugin.config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() > 0) config.set("Password", host.plugin.config.get().getMap("Settings").getMap("SubData").getRawString("Password"));
config.setAll(getSubDataConfig());
writer.write(config.toJSON().toString());
writer.close();

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Bungee.Host.Internal;
import net.ME1312.SubServers.Bungee.Host.SubLogFilter;
import net.ME1312.SubServers.Bungee.Host.SubLogger;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubAPI;
@ -21,12 +21,12 @@ import java.util.regex.Pattern;
* Internal Process Logger Class
*/
public class InternalSubLogger extends SubLogger {
protected Process process;
Process process;
private Object handle;
protected String name;
protected Container<Boolean> log;
String name;
Container<Boolean> log;
private List<SubLogFilter> filters = new CopyOnWriteArrayList<>();
protected File file;
File file;
private PrintWriter writer = null;
private boolean started = false;
private Thread out = null;
@ -41,7 +41,7 @@ public class InternalSubLogger extends SubLogger {
* @param log Console Logging Status
* @param file File to log to (or null for disabled)
*/
protected InternalSubLogger(Process process, Object user, String name, Container<Boolean> log, File file) {
InternalSubLogger(Process process, Object user, String name, Container<Boolean> log, File file) {
this.process = process;
this.handle = user;
this.name = name;

View File

@ -4,10 +4,10 @@ import net.ME1312.SubServers.Bungee.Event.*;
import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
@ -27,7 +27,7 @@ import java.util.jar.JarInputStream;
/**
* Internal SubServer Class
*/
public class InternalSubServer extends SubServerContainer {
public class InternalSubServer extends SubServerImpl {
private InternalHost host;
private boolean enabled;
private Container<Boolean> log;
@ -60,8 +60,33 @@ public class InternalSubServer extends SubServerContainer {
* @param restricted Restricted Status
* @throws InvalidServerException
*/
public InternalSubServer(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
public static InternalSubServer construct(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
try {
return new InternalSubServer(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
} catch (NoSuchMethodError e) {
return new InternalSubServer(host, name, enabled, (Integer) port, motd, log, directory, executable, stopcmd, hidden, restricted);
}
}
/**
* Super Method 2 (newest)
* @see #construct(InternalHost, String, boolean, int, String, boolean, String, String, String, boolean, boolean) for method details
*/
protected InternalSubServer(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
super(host, name, port, motd, hidden, restricted);
init(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
}
/**
* Super Method 1 (oldest)
* @see #construct(InternalHost, String, boolean, int, String, boolean, String, String, String, boolean, boolean) for method details
*/
protected InternalSubServer(InternalHost host, String name, boolean enabled, Integer port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
super(host, name, port, motd, hidden, restricted);
init(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted);
}
private void init(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, String executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException {
if (Util.isNull(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted)) throw new NullPointerException();
this.host = host;
this.enabled = enabled;
@ -302,7 +327,7 @@ public class InternalSubServer extends SubServerContainer {
break;
case "display":
if (value.isString()) {
Field f = ServerContainer.class.getDeclaredField("nick");
Field f = ServerImpl.class.getDeclaredField("nick");
f.setAccessible(true);
if (value.isNull() || value.asString().length() == 0 || getName().equals(value.asString())) {
f.set(this, null);
@ -334,7 +359,7 @@ public class InternalSubServer extends SubServerContainer {
break;
case "group":
if (value.isList()) {
Util.reflect(ServerContainer.class.getDeclaredField("groups"), this, value.asRawStringList());
Util.reflect(ServerImpl.class.getDeclaredField("groups"), this, value.asRawStringList());
if (perma && this.host.plugin.servers.get().getMap("Servers").getKeys().contains(getName())) {
this.host.plugin.servers.get().getMap("Servers").getMap(getName()).set("Group", value.asRawStringList());
this.host.plugin.servers.save();
@ -357,7 +382,7 @@ public class InternalSubServer extends SubServerContainer {
break;
case "template":
if (value.isString()) {
Util.reflect(SubServerContainer.class.getDeclaredField("template"), this, value.asRawString());
Util.reflect(SubServerImpl.class.getDeclaredField("template"), this, value.asRawString());
if (perma && this.host.plugin.servers.get().getMap("Servers").getKeys().contains(getName())) {
this.host.plugin.servers.get().getMap("Servers").getMap(getName()).set("Template", value.asRawString());
this.host.plugin.servers.save();
@ -494,7 +519,7 @@ public class InternalSubServer extends SubServerContainer {
break;
case "hidden":
if (value.isBoolean()) {
Util.reflect(ServerContainer.class.getDeclaredField("hidden"), this, value.asBoolean());
Util.reflect(ServerImpl.class.getDeclaredField("hidden"), this, value.asBoolean());
if (perma && this.host.plugin.servers.get().getMap("Servers").getKeys().contains(getName())) {
this.host.plugin.servers.get().getMap("Servers").getMap(getName()).set("Hidden", isHidden());
this.host.plugin.servers.save();
@ -504,7 +529,7 @@ public class InternalSubServer extends SubServerContainer {
break;
case "whitelist":
if (value.isList()) {
Util.reflect(ServerContainer.class.getDeclaredField("whitelist"), this, value.asUUIDList());
Util.reflect(ServerImpl.class.getDeclaredField("whitelist"), this, value.asUUIDList());
c++;
}
break;
@ -512,7 +537,7 @@ public class InternalSubServer extends SubServerContainer {
if (forward != null) {
forward.setStopAction(getStopAction());
if (!getName().equals(getDisplayName())) forward.setDisplayName(getDisplayName());
Util.reflect(SubServerContainer.class.getDeclaredField("template"), forward, Util.reflect(SubServerContainer.class.getDeclaredField("template"), this));
Util.reflect(SubServerImpl.class.getDeclaredField("template"), forward, Util.reflect(SubServerImpl.class.getDeclaredField("template"), this));
List<String> groups = new ArrayList<String>();
groups.addAll(getGroups());
for (String group : groups) {

View File

@ -6,12 +6,13 @@ import net.ME1312.SubServers.Bungee.Event.SubRemoveProxyEvent;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.ExtraDataHandler;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.ClientHandler;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.*;
@ -108,7 +109,7 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
}
/**
* Test if the proxy is connected to RedisBungee's server
* Determine if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
@ -118,19 +119,33 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
return plugin.redis != null && Util.getDespiteException(() -> plugin.redis("getPlayersOnProxy", new NamedContainer<>(String.class, getName())) != null, false);
}
/**
* Determine if the proxy is the Master Proxy
*
* @return Master Proxy Status
*/
public boolean isMaster() {
return SubAPI.getInstance().getMasterProxy() == this;
}
/**
* Get the players on this proxy (via RedisBungee)
*
* @return Player Collection
* @return Remote Player Collection
*/
@SuppressWarnings({"deprecation", "unchecked"})
public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
public Collection<RemotePlayer> getPlayers() {
List<RemotePlayer> players = new LinkedList<RemotePlayer>();
//List<UUID> used = new ArrayList<UUID>();
SubProxy plugin = SubAPI.getInstance().getInternals();
if (plugin.redis != null) {
try {
for (UUID player : (Set<UUID>) plugin.redis("getPlayersOnProxy", new NamedContainer<>(String.class, getName())))
players.add(new NamedContainer<>((String) plugin.redis("getNameFromUuid", new NamedContainer<>(UUID.class, player)), player));
for (UUID id : (Set<UUID>) plugin.redis("getPlayersOnProxy", new NamedContainer<>(String.class, getName()))) {
//if (!used.contains(id)) {
players.add(new RemotePlayer(id));
// used.add(id);
//}
}
} catch (Exception e) {}
}
return players;
@ -181,13 +196,11 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
info.set("name", getName());
info.set("display", getDisplayName());
ObjectMap<String> players = new ObjectMap<String>();
for (NamedContainer<String, UUID> player : getPlayers()) {
ObjectMap<String> pinfo = new ObjectMap<String>();
pinfo.set("name", player.name());
players.set(player.get().toString(), pinfo);
}
for (RemotePlayer player : getPlayers())
players.set(player.getUniqueId().toString(), player.getName());
info.set("players", players);
info.set("redis", isRedis());
info.set("master", isMaster());
ObjectMap<Integer> subdata = new ObjectMap<Integer>();
for (int channel : this.subdata.keySet()) subdata.set(channel, (this.subdata.get(channel) == null)?null:this.subdata.get(channel).getID());
info.set("subdata", subdata);

View File

@ -0,0 +1,148 @@
package net.ME1312.SubServers.Bungee.Host;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.SubDataSerializable;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.net.InetAddress;
import java.util.UUID;
/**
* Remote Player Class
*/
public class RemotePlayer implements SubDataSerializable {
private ProxiedPlayer local;
private UUID id;
private String name;
private InetAddress ip;
private Proxy proxy;
private Server server;
/**
* Translate a Local Player to a Remote Player
*
* @param player Local Player
*/
public RemotePlayer(ProxiedPlayer player) {
if (Util.isNull(player)) throw new NullPointerException();
this.local = player;
this.id = player.getUniqueId();
}
/**
* Search for a Remote Player using their ID
*
* @param player Remote Player ID
*/
public RemotePlayer(UUID player) {
if (Util.isNull(player)) throw new NullPointerException();
id = player;
refresh();
}
/**
* Download a new copy of the data
*/
@SuppressWarnings({"deprecation", "unchecked"})
public void refresh() {
SubProxy plugin = SubAPI.getInstance().getInternals();
UUID player = id;
this.local = plugin.getPlayer(player);
if (local == null) {
if (plugin.redis != null && Util.getDespiteException(() -> (boolean) plugin.redis("isPlayerOnline", new NamedContainer<>(UUID.class, player)), false)) {
server = Util.getDespiteException(() -> (Server) plugin.redis("getServerFor", new NamedContainer<>(UUID.class, player)), null);
proxy = Util.getDespiteException(() -> plugin.api.getProxy((String) plugin.redis("getProxy", new NamedContainer<>(UUID.class, player))), null);
ip = Util.getDespiteException(() -> (InetAddress) plugin.redis("getPlayerIp", new NamedContainer<>(UUID.class, player)), null);
name = Util.getDespiteException(() -> (String) plugin.redis("getNameFromUuid", new NamedContainer<>(UUID.class, player), new NamedContainer<>(boolean.class, false)), null);
}
if (name == null) throw new IllegalStateException("Player " + id.toString() + " not found!");
}
}
/**
* Get Local Player
*
* @return Local Player (or null when not local)
*/
public ProxiedPlayer get() {
return local;
}
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
public UUID getUniqueId() {
if (local != null) {
return local.getUniqueId();
} else return id;
}
/**
* Get the unique name of this player.
*
* @return the players username
*/
public String getName() {
if (local != null) {
return local.getName();
} else return name;
}
/**
* Gets the remote address of this connection.
*
* @return the remote address
*/
@SuppressWarnings("deprecation")
public InetAddress getAddress() {
if (local != null) {
return local.getAddress().getAddress();
} else return ip;
}
/**
* Gets the proxy this player is connected to.
*
* @return the proxy this player is connected to
*/
public Proxy getProxy() {
if (local != null) {
return SubAPI.getInstance().getMasterProxy();
} else return proxy;
}
/**
* Gets the server this player is connected to.
*
* @return the server this player is connected to
*/
public Server getServer() {
if (local != null) {
return (Server) local.getServer().getInfo();
} else return server;
}
@Override
public boolean equals(Object obj) {
return obj instanceof RemotePlayer && getUniqueId().equals(((RemotePlayer) obj).getUniqueId());
}
@Override
public ObjectMap<String> forSubData() {
ObjectMap<String> pinfo = new ObjectMap<String>();
pinfo.set("name", getName());
pinfo.set("id", getUniqueId());
if (getServer() != null) pinfo.set("server", getServer().getName());
if (getProxy() != null) pinfo.set("proxy", getProxy().getName());
return pinfo;
}
}

View File

@ -1,7 +1,7 @@
package net.ME1312.SubServers.Bungee.Host;
import net.ME1312.Galaxi.Library.ExtraDataHandler;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubData.Server.ClientHandler;
import net.ME1312.SubData.Server.DataClient;
import net.md_5.bungee.api.config.ServerInfo;
@ -61,9 +61,9 @@ public interface Server extends ServerInfo, ClientHandler, ExtraDataHandler {
/**
* Get players on this server across all known proxies
*
* @return Player Collection
* @return Remote Player Collection
*/
Collection<NamedContainer<String, UUID>> getGlobalPlayers();
Collection<RemotePlayer> getGlobalPlayers();
/**
* If the server is hidden from players

View File

@ -8,7 +8,7 @@ import net.ME1312.SubServers.Bungee.Event.SubNetworkDisconnectEvent;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExRunEvent;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExUpdateWhitelist;
@ -19,26 +19,61 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.*;
/**
* Server Class
*/
public class ServerContainer extends BungeeServerInfo implements Server {
public class ServerImpl extends BungeeServerInfo implements Server {
private HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
private ObjectMap<String> extra = new ObjectMap<String>();
private String nick = null;
private List<String> groups = new ArrayList<String>();
private List<UUID> whitelist = new ArrayList<UUID>();
private boolean hidden;
private final String signature;
private final String signature = SubAPI.getInstance().signAnonymousObject();
/**
* Construct a new Server data type
*
* @param name Server name
* @param address Server Address
* @param motd Server MOTD
* @param hidden Hidden Status
* @param restricted Restricted Status
* @return
*/
public static ServerImpl construct(String name, SocketAddress address, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
try {
return new ServerImpl(name, address, motd, hidden, restricted);
} catch (NoSuchMethodError e) {
return new ServerImpl(name, (InetSocketAddress) address, motd, hidden, restricted);
}
}
/**
* Super Method 2 (newest)
* @see #construct(String, SocketAddress, String, boolean, boolean) for method details
*/
protected ServerImpl(String name, SocketAddress address, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(name, address, motd, restricted);
init(name, address, motd, hidden, restricted);
}
/**
* Super Method 1 (oldest)
* @see #construct(String, SocketAddress, String, boolean, boolean) for method details
*/
protected ServerImpl(String name, InetSocketAddress address, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(name, address, motd, restricted);
init(name, address, motd, hidden, restricted);
}
@SuppressWarnings("deprecation")
public ServerContainer(String name, InetSocketAddress address, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(name, address, motd, restricted);
private void init(String name, SocketAddress address, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
if (Util.isNull(name, address, motd, hidden, restricted)) throw new NullPointerException();
if (name.contains(" ")) throw new InvalidServerException("Server names cannot have spaces: " + name);
signature = SubAPI.getInstance().signAnonymousObject();
SubAPI.getInstance().getInternals().subprotocol.whitelist(getAddress().getAddress().getHostAddress());
this.hidden = hidden;
@ -124,15 +159,23 @@ public class ServerContainer extends BungeeServerInfo implements Server {
@SuppressWarnings({"deprecation", "unchecked"})
@Override
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
public Collection<RemotePlayer> getGlobalPlayers() {
List<RemotePlayer> players = new LinkedList<RemotePlayer>();
List<UUID> used = new ArrayList<UUID>();
SubProxy plugin = SubAPI.getInstance().getInternals();
for (ProxiedPlayer player : getPlayers()) {
players.add(new RemotePlayer(player));
used.add(player.getUniqueId());
}
if (plugin.redis != null) {
try {
for (UUID player : (Set<UUID>) plugin.redis("getPlayersOnServer", new NamedContainer<>(String.class, getName()))) players.add(new NamedContainer<>((String) plugin.redis("getNameFromUuid", new NamedContainer<>(UUID.class, player)), player));
for (UUID id : (Set<UUID>) plugin.redis("getPlayersOnServer", new NamedContainer<>(String.class, getName()))) {
if (!used.contains(id)) {
players.add(new RemotePlayer(id));
used.add(id);
}
}
} catch (Exception e) {}
} else {
for (ProxiedPlayer player : getPlayers()) players.add(new NamedContainer<>(player.getName(), player.getUniqueId()));
}
return players;
}
@ -254,11 +297,8 @@ public class ServerContainer extends BungeeServerInfo implements Server {
info.set("restricted", isRestricted());
info.set("hidden", isHidden());
ObjectMap<String> players = new ObjectMap<String>();
for (NamedContainer<String, UUID> player : getGlobalPlayers()) {
ObjectMap<String> pinfo = new ObjectMap<String>();
pinfo.set("name", player.name());
players.set(player.get().toString(), pinfo);
}
for (RemotePlayer player : getGlobalPlayers())
players.set(player.getUniqueId().toString(), player.getName());
info.set("players", players);
ObjectMap<Integer> subdata = new ObjectMap<Integer>();
for (int channel : this.subdata.keySet()) subdata.set(channel, (this.subdata.get(channel) == null)?null:this.subdata.get(channel).getID());

View File

@ -9,7 +9,7 @@ import java.util.*;
* API-Safe SubServer Layout Class
*/
public abstract class SubServerController {
private final SubServerContainer control;
private final SubServerImpl control;
/**
* Creates a SubServer
@ -22,138 +22,154 @@ public abstract class SubServerController {
* @throws InvalidServerException
*/
public SubServerController(Host host, String name, int port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
control = new SubServerContainer(host, name, port, motd, hidden, restricted) {
@Override
public boolean start() {
if (SubServerController.this.start()) {
started = false;
return true;
} else return false;
}
SubServerImpl control;
try {
control = new ControlledSubServer(host, name, port, motd, hidden, restricted);
} catch (NoSuchMethodError e) {
control = new ControlledSubServer(host, name, (Integer) port, motd, hidden, restricted);
}
this.control = control;
}
@Override
public boolean start(UUID player) {
if (SubServerController.this.start(player)) {
started = false;
return true;
} else return false;
}
private final class ControlledSubServer extends SubServerImpl {
public ControlledSubServer(Host host, String name, int port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(host, name, port, motd, hidden, restricted);
}
@Override
public boolean stop() {
return SubServerController.this.stop();
}
public ControlledSubServer(Host host, String name, Integer port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(host, name, port, motd, hidden, restricted);
}
@Override
public boolean stop(UUID player) {
return SubServerController.this.stop(player);
}
@Override
public boolean start() {
if (SubServerController.this.start()) {
started = false;
return true;
} else return false;
}
@Override
public boolean terminate() {
return SubServerController.this.terminate();
}
@Override
public boolean start(UUID player) {
if (SubServerController.this.start(player)) {
started = false;
return true;
} else return false;
}
@Override
public boolean terminate(UUID player) {
return SubServerController.this.terminate(player);
}
@Override
public boolean stop() {
return SubServerController.this.stop();
}
@Override
public boolean command(String command) {
return SubServerController.this.command(command);
}
@Override
public boolean stop(UUID player) {
return SubServerController.this.stop(player);
}
@Override
public boolean command(UUID player, String command) {
return SubServerController.this.command(player, command);
}
@Override
public boolean terminate() {
return SubServerController.this.terminate();
}
@Override
public int permaEdit(ObjectMap<String> edit) {
return SubServerController.this.edit(edit);
}
@Override
public boolean terminate(UUID player) {
return SubServerController.this.terminate(player);
}
@Override
public int permaEdit(UUID player, ObjectMap<String> edit) {
return SubServerController.this.edit(player, edit);
}
@Override
public boolean command(String command) {
return SubServerController.this.command(command);
}
@Override
public void waitFor() throws InterruptedException {
SubServerController.this.waitFor();
}
@Override
public boolean command(UUID player, String command) {
return SubServerController.this.command(player, command);
}
@Override
public boolean isRunning() {
return SubServerController.this.isRunning();
}
@Override
public int permaEdit(ObjectMap<String> edit) {
return SubServerController.this.edit(edit);
}
@Override
public Host getHost() {
return SubServerController.this.getHost();
}
@Override
public int permaEdit(UUID player, ObjectMap<String> edit) {
return SubServerController.this.edit(player, edit);
}
@Override
public boolean isEnabled() {
return SubServerController.this.isEnabled();
}
@Override
public void waitFor() throws InterruptedException {
SubServerController.this.waitFor();
}
@Override
public void setEnabled(boolean value) {
SubServerController.this.setEnabled(value);
}
@Override
public boolean isRunning() {
return SubServerController.this.isRunning();
}
@Override
public boolean isLogging() {
return SubServerController.this.isLogging();
}
@Override
public Host getHost() {
return SubServerController.this.getHost();
}
@Override
public void setLogging(boolean value) {
SubServerController.this.setLogging(value);
}
@Override
public boolean isEnabled() {
return SubServerController.this.isEnabled();
}
@Override
public SubLogger getLogger() {
return SubServerController.this.getLogger();
}
@Override
public void setEnabled(boolean value) {
SubServerController.this.setEnabled(value);
}
@Override
public LinkedList<LoggedCommand> getCommandHistory() {
return SubServerController.this.getCommandHistory();
}
@Override
public boolean isLogging() {
return SubServerController.this.isLogging();
}
@Override
public String getPath() {
return SubServerController.this.getPath();
}
@Override
public void setLogging(boolean value) {
SubServerController.this.setLogging(value);
}
@Override
public String getExecutable() {
return SubServerController.this.getExecutable();
}
@Override
public SubLogger getLogger() {
return SubServerController.this.getLogger();
}
@Override
public String getStopCommand() {
return SubServerController.this.getStopCommand();
}
@Override
public LinkedList<LoggedCommand> getCommandHistory() {
return SubServerController.this.getCommandHistory();
}
@Override
public void setStopCommand(String value) {
SubServerController.this.setStopCommand(value);
}
@Override
public String getPath() {
return SubServerController.this.getPath();
}
@Override
public StopAction getStopAction() {
return SubServerController.this.getStopAction();
}
@Override
public String getExecutable() {
return SubServerController.this.getExecutable();
}
@Override
public void setStopAction(StopAction action) {
SubServerController.this.setStopAction(action);
}
};
@Override
public String getStopCommand() {
return SubServerController.this.getStopCommand();
}
@Override
public void setStopCommand(String value) {
SubServerController.this.setStopCommand(value);
}
@Override
public StopAction getStopAction() {
return SubServerController.this.getStopAction();
}
@Override
public void setStopAction(StopAction action) {
SubServerController.this.setStopAction(action);
}
}
/**

View File

@ -3,17 +3,18 @@ package net.ME1312.SubServers.Bungee.Host;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubServers.Bungee.Event.SubEditServerEvent;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubServers.Bungee.SubAPI;
import java.io.File;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.*;
/**
* SubServer Layout Class
*/
public abstract class SubServerContainer extends ServerContainer implements SubServer {
public abstract class SubServerImpl extends ServerImpl implements SubServer {
private List<NamedContainer<String, String>> incompatibilities = new ArrayList<NamedContainer<String, String>>();
private String template = null;
protected boolean started;
@ -26,10 +27,30 @@ public abstract class SubServerContainer extends ServerContainer implements SubS
* @param name Server Name
* @param port Port Number
* @param motd Server MOTD
* @param restricted Players will need a permission to join if true
* @param hidden Hidden Status
* @param restricted Restricted Status
*
* @see ServerImpl#ServerImpl(String, SocketAddress, String, boolean, boolean) Super Method 2
* @throws InvalidServerException
*/
public SubServerContainer(Host host, String name, int port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
protected SubServerImpl(Host host, String name, int port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(name, (SocketAddress) new InetSocketAddress(host.getAddress().getHostAddress(), port), motd, hidden, restricted);
}
/**
* Creates a SubServer
*
* @param host Host
* @param name Server Name
* @param port Port Number
* @param motd Server MOTD
* @param hidden Hidden Status
* @param restricted Restricted Status
*
* @see ServerImpl#ServerImpl(String, InetSocketAddress, String, boolean, boolean) Super Method 1
* @throws InvalidServerException
*/
protected SubServerImpl(Host host, String name, Integer port, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(name, new InetSocketAddress(host.getAddress().getHostAddress(), port), motd, hidden, restricted);
}

View File

@ -1,5 +1,6 @@
package net.ME1312.SubServers.Bungee;
import net.ME1312.Galaxi.Library.Platform;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiInfo;
@ -48,41 +49,13 @@ public final class Launch {
parser.accepts("noconsole");
joptsimple.OptionSet options = parser.parse(args);
if(options.has("version") || options.has("v")) {
String osarch;
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
osarch = arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64")?"x64":"x86";
} else if (System.getProperty("os.arch").endsWith("86")) {
osarch = "x86";
} else if (System.getProperty("os.arch").endsWith("64")) {
osarch = "x64";
} else {
osarch = System.getProperty("os.arch");
}
String javaarch = null;
switch (System.getProperty("sun.arch.data.model")) {
case "32":
javaarch = "x86";
break;
case "64":
javaarch = "x64";
break;
default:
if (!System.getProperty("sun.arch.data.model").equalsIgnoreCase("unknown"))
javaarch = System.getProperty("sun.arch.data.model");
}
Version galaxi = GalaxiInfo.getVersion();
Version galaxibuild = GalaxiInfo.getSignature();
System.out.println("");
System.out.println(System.getProperty("os.name") + ((!System.getProperty("os.name").toLowerCase().startsWith("windows"))?' ' + System.getProperty("os.version"):"") + ((osarch != null)?" [" + osarch + ']':"") + ',');
System.out.println("Java " + System.getProperty("java.version") + ((javaarch != null)?" [" + javaarch + ']':"") + ',');
if (galaxi != null)
System.out.println("GalaxiEngine v" + galaxi.toExtendedString() + ((galaxibuild != null)?" (" + galaxibuild + ')':"") + ',');
System.out.println(Platform.getSystemName() + ' ' + Platform.getSystemVersion() + ((!Platform.getSystemArchitecture().equals("unknown"))?" [" + Platform.getSystemArchitecture() + ']':"") + ',');
System.out.println("Java " + Platform.getJavaVersion() + ((!Platform.getJavaArchitecture().equals("unknown"))?" [" + Platform.getJavaArchitecture() + ']':"") + ',');
if (galaxi != null) System.out.println("GalaxiEngine v" + galaxi.toExtendedString() + ((galaxibuild != null)?" (" + galaxibuild + ')':"") + ',');
System.out.println("BungeeCord" + net.md_5.bungee.Bootstrap.class.getPackage().getImplementationVersion() + ((patched)?" [Patched]":"") + ',');
System.out.println("SubServers.Bungee v" + SubProxy.version.toExtendedString() + ((SubProxy.class.getPackage().getSpecificationTitle() != null)?" (" + SubProxy.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("");

View File

@ -1,6 +1,6 @@
package net.ME1312.SubServers.Bungee.Library.Compatibility;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;

View File

@ -0,0 +1,104 @@
package net.ME1312.SubServers.Bungee.Library.Compatibility;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/**
* Legacy Server Map Translation Class
*/
public class LegacyServerMap implements Map<String, ServerInfo> {
private final Map<String, ServerInfo> m;
/**
* Translate Legacy Server Map Modifications
*
* @param map Legacy Server Map
*/
public LegacyServerMap(Map<String, ServerInfo> map) {
this.m = map;
}
@Override
public ServerInfo get(Object key) {
return m.get(key);
}
@SuppressWarnings("deprecation")
@Override
public ServerInfo put(String key, ServerInfo value) {
if (value == null) throw new NullPointerException();
ServerInfo n = SubAPI.getInstance().addServer(value.getName(), value.getAddress().getAddress(), value.getAddress().getPort(), value.getMotd(), false, value.isRestricted()),
s = getOrDefault(key, null);
if (n != null)
m.put(n.getName(), n);
return s;
}
@Override
public ServerInfo remove(Object key) {
if (key instanceof String) {
ServerInfo s = getOrDefault(key, null);
if (s != null) {
if (SubAPI.getInstance().removeServer((String) key))
m.remove(key);
return s;
} else return null;
} else return null;
}
@Override
public void putAll(Map<? extends String, ? extends ServerInfo> m) {
if (m.size() > 0) {
for (Map.Entry<? extends String, ? extends ServerInfo> e : m.entrySet()) {
put(e.getKey(), e.getValue());
}
}
}
@Override
public void clear() {
// Disallow removing all servers
}
@Override
public int size() {
return m.size();
}
@Override
public boolean isEmpty() {
return m.isEmpty();
}
@Override
public boolean containsKey(Object key) {
return m.containsKey(key);
}
@Override
public boolean containsValue(Object value) {
return m.containsValue(value);
}
@Override
public Set<String> keySet() {
return m.keySet();
}
@Override
public Collection<ServerInfo> values() {
return m.values();
}
@Override
public Set<Entry<String, ServerInfo>> entrySet() {
return m.entrySet();
}
}

View File

@ -1,6 +1,6 @@
package net.ME1312.SubServers.Bungee.Library.Compatibility.mc1_13;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.md_5.bungee.api.CommandSender;
import java.util.LinkedList;

View File

@ -0,0 +1,512 @@
package net.ME1312.SubServers.Bungee.Library;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubAPI;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* SubServers Configuration Updater
*/
public class ConfigUpdater {
private static final Version UNSIGNED = new Version(new SimpleDateFormat("yy'w'ww'zz'").format(Calendar.getInstance().getTime()));
/**
* Update SubServers' config.yml
*
* @param file File to bring up-to-date
*/
public static void updateConfig(File file) throws IOException {
YAMLConfig config = new YAMLConfig(file);
YAMLSection existing = config.get().clone();
YAMLSection updated = existing.clone();
YAMLSection rewritten = new YAMLSection();
Version was = existing.getMap("Settings", new ObjectMap<>()).getVersion("Version", new Version(0));
Version now = SubAPI.getInstance().getWrapperBuild();
int i = 0;
if (now == null) now = UNSIGNED;
if (!existing.contains("Settings") || !existing.getMap("Settings").contains("Version")) {
YAMLSection hosts = new YAMLSection();
YAMLSection host = new YAMLSection();
host.set("Enabled", true);
host.set("Display", "Default");
hosts.set("~", host);
updated.set("Hosts", hosts);
i++;
Logger.get("SubServers").info("Created ./SubServers/config.yml");
} else {
if (was.compareTo(new Version("19w17a")) <= 0) {
if (existing.getMap("Settings", new YAMLSection()).contains("Log-Creator")) for (String name : existing.getMap("Hosts", new YAMLSection()).getKeys())
updated.getMap("Hosts").getMap(name).safeSet("Log-Creator", existing.getMap("Settings").getBoolean("Log-Creator"));
if (existing.getMap("Settings", new YAMLSection()).contains("SubData") && !existing.getMap("Settings", new YAMLSection()).getMap("SubData").contains("Encryption"))
updated.getMap("Settings").getMap("SubData").set("Encryption", "NONE");
if (existing.contains("Servers")) {
YAMLConfig sc = new YAMLConfig(new File(file.getParentFile(), "servers.yml"));
YAMLSection settings = new YAMLSection();
settings.set("Version", was.toString());
settings.set("Run-On-Launch-Timeout", (existing.getMap("Settings", new YAMLSection()).contains("Run-On-Launch-Timeout"))?existing.getMap("Settings").getInt("Run-On-Launch-Timeout"):0);
sc.get().safeSet("Settings", settings);
sc.get().safeSet("Servers", new YAMLSection());
sc.get().getMap("Servers").safeSetAll(existing.getMap("Servers"));
Logger.get("SubServers").info("Created ./SubServers/servers.yml (using existing data)");
sc.save();
}
existing = updated.clone();
i++;
} if (was.compareTo(new Version("19w35c")) <= 0) {
if (existing.getMap("Settings", new YAMLSection()).contains("SubData")) {
LinkedList<String> whitelist = new LinkedList<>();
LinkedList<String> newWhitelist = new LinkedList<>();
whitelist.addAll(existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getStringList("Allowed-Connections", Collections.emptyList()));
whitelist.addAll(existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getStringList("Whitelist", Collections.emptyList()));
boolean warnPls = false;
for (String address : whitelist) {
Matcher regAddress = Pattern.compile("^(\\d{1,3}|%)\\.(\\d{1,3}|%)\\.(\\d{1,3}|%)\\.(\\d{1,3}|%)$").matcher(address);
if (regAddress.find()) {
StringBuilder newAddress = new StringBuilder();
int subnet = -1;
boolean warn = false;
for (int o = 1; o <= 4; o++) {
if (o > 1) newAddress.append('.');
if (subnet == -1) {
if (!regAddress.group(o).equals("%")) {
newAddress.append(regAddress.group(o));
} else {
subnet = 8 * (o - 1);
newAddress.append('0');
}
} else {
if (!regAddress.group(o).equals("%")) warn = warnPls = true;
newAddress.append('0');
}
}
if (subnet < 0) subnet = 32;
if (warn) Logger.get("SubServers").warning("Updating non-standard mask: " + address);
newAddress.append('/');
newAddress.append(subnet);
newWhitelist.add(newAddress.toString());
}
}
updated.getMap("Settings").getMap("SubData").set("Whitelist", newWhitelist);
if (warnPls) Logger.get("SubServers").warning("Non-standard masks have been updated. This may expose SubData to unintended networks!");
}
existing = updated.clone();
i++;
} if (was.compareTo(new Version("20w08d")) <= 0) {
if (existing.contains("Hosts")) {
for (String name : existing.getMap("Hosts", new YAMLSection()).getKeys()) {
if (existing.getMap("Hosts").getMap(name).getRawString("Driver", "BUILT_IN").replace('-', '_').replace(' ', '_').equalsIgnoreCase("BUILT_IN"))
updated.getMap("Hosts").getMap(name).set("Driver", "VIRTUAL");
}
}
existing = updated.clone();
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// existing = updated.clone();
// i++
//}
if (i > 0) Logger.get("SubServers").info("Updated ./SubServers/config.yml (" + i + " pass" + ((i != 1)?"es":"") + ")");
}
if (i > 0) {
YAMLSection settings = new YAMLSection();
settings.set("Version", ((now.compareTo(was) <= 0)?was:now).toString());
settings.set("Smart-Fallback", updated.getMap("Settings", new YAMLSection()).getBoolean("Smart-Fallback", true));
settings.set("Override-Bungee-Commands", updated.getMap("Settings", new YAMLSection()).getBoolean("Override-Bungee-Commands", true));
YAMLSection upnp = new YAMLSection();
upnp.set("Forward-Proxy", updated.getMap("Settings", new YAMLSection()).getMap("UPnP", new YAMLSection()).getBoolean("Forward-Proxy", true));
upnp.set("Forward-SubData", updated.getMap("Settings", new YAMLSection()).getMap("UPnP", new YAMLSection()).getBoolean("Forward-SubData", false));
upnp.set("Forward-Servers", updated.getMap("Settings", new YAMLSection()).getMap("UPnP", new YAMLSection()).getBoolean("Forward-Servers", false));
settings.set("UPnP", upnp);
YAMLSection subdata = new YAMLSection();
subdata.set("Address", updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getRawString("Address", "127.0.0.1:4391"));
if (updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).contains("Password")) subdata.set("Password", updated.getMap("Settings").getMap("SubData").getRawString("Password"));
subdata.set("Encryption", updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getRawString("Encryption", "RSA/AES"));
subdata.set("Whitelist", updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getRawStringList("Whitelist", Collections.emptyList()));
settings.set("SubData", subdata);
rewritten.set("Settings", settings);
YAMLSection hosts = new YAMLSection();
for (String name : updated.getMap("Hosts", new YAMLSection()).getKeys()) {
YAMLSection host = new YAMLSection();
host.set("Enabled", updated.getMap("Hosts").getMap(name).getBoolean("Enabled", false));
host.set("Display", updated.getMap("Hosts").getMap(name).getRawString("Display", ""));
host.set("Driver", updated.getMap("Hosts").getMap(name).getRawString("Driver", "VIRTUAL"));
host.set("Address", updated.getMap("Hosts").getMap(name).getRawString("Address", "127.0.0.1"));
host.set("Port-Range", updated.getMap("Hosts").getMap(name).getRawString("Port-Range", "25500-25559"));
host.set("Directory", updated.getMap("Hosts").getMap(name).getRawString("Directory", (host.getRawString("Driver").equalsIgnoreCase("VIRTUAL"))?"./SubServers/Servers":"./Servers"));
host.set("Git-Bash", updated.getMap("Hosts").getMap(name).getRawString("Git-Bash", "%ProgramFiles%\\Git"));
host.set("Log-Creator", updated.getMap("Hosts").getMap(name).getBoolean("Log-Creator", true));
if (updated.getMap("Hosts").getMap(name).contains("Extra")) host.set("Extra", updated.getMap("Hosts").getMap(name).getMap("Extra"));
hosts.set(name, host);
}
rewritten.set("Hosts", hosts);
config.set(rewritten);
config.save();
}
}
/**
* Update SubServers' servers.yml
*
* @param file File to bring up-to-date
*/
public static void updateServers(File file) throws IOException {
YAMLConfig config = new YAMLConfig(file);
YAMLSection existing = config.get().clone();
YAMLSection updated = existing.clone();
YAMLSection rewritten = new YAMLSection();
Version was = existing.getMap("Settings", new ObjectMap<>()).getVersion("Version", new Version(0));
Version now = SubAPI.getInstance().getWrapperBuild();
int i = 0;
if (now == null) now = UNSIGNED;
if (!existing.contains("Settings") || !existing.getMap("Settings").contains("Version")) {
YAMLSection servers = new YAMLSection();
servers.set("Example", new YAMLSection());
updated.set("Servers", servers);
i++;
Logger.get("SubServers").info("Created ./SubServers/servers.yml");
} else {
if (was.compareTo(new Version("19w17a")) <= 0) {
if (existing.contains("Servers")) {
for (String name : existing.getMap("Servers", new YAMLSection()).getKeys()) {
if (existing.getMap("Servers").getMap(name).getBoolean("Auto-Restart", true))
updated.getMap("Servers").getMap(name).safeSet("Stop-Action", "RESTART");
if (existing.getMap("Servers").getMap(name).getRawString("Stop-Action", "NONE").equalsIgnoreCase("DELETE_SERVER"))
updated.getMap("Servers").getMap(name).set("Stop-Action", "RECYCLE_SERVER");
}
}
existing = updated.clone();
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// i++
//}
if (i > 0) Logger.get("SubServers").info("Updated ./SubServers/servers.yml (" + i + " pass" + ((i != 1)?"es":"") + ")");
}
if (i > 0) {
YAMLSection settings = new YAMLSection();
settings.set("Version", ((now.compareTo(was) <= 0)?was:now).toString());
settings.set("Run-On-Launch-Timeout", updated.getMap("Settings", new YAMLSection()).getInt("Run-On-Launch-Timeout", 0));
rewritten.set("Settings", settings);
YAMLSection servers = new YAMLSection();
for (String name : updated.getMap("Servers", new YAMLSection()).getKeys()) {
YAMLSection server = new YAMLSection();
server.set("Enabled", updated.getMap("Servers").getMap(name).getBoolean("Enabled", false));
server.set("Display", updated.getMap("Servers").getMap(name).getRawString("Display", ""));
server.set("Host", updated.getMap("Servers").getMap(name).getRawString("Host", "~"));
if (updated.getMap("Servers").getMap(name).contains("Template")) server.set("Template", updated.getMap("Servers").getMap(name).getRawString("Template"));
server.set("Group", updated.getMap("Servers").getMap(name).getRawStringList("Groups", Collections.emptyList()));
server.set("Port", updated.getMap("Servers").getMap(name).getInt("Port", 25567));
server.set("Motd", updated.getMap("Servers").getMap(name).getRawString("Motd", "Some SubServer"));
server.set("Log", updated.getMap("Servers").getMap(name).getBoolean("Log", true));
server.set("Directory", updated.getMap("Servers").getMap(name).getRawString("Directory", "." + File.separatorChar));
server.set("Executable", updated.getMap("Servers").getMap(name).getRawString("Executable", "java -Xmx1024M -Djline.terminal=jline.UnsupportedTerminal -jar Spigot.jar"));
server.set("Stop-Command", updated.getMap("Servers").getMap(name).getRawString("Stop-Command", "stop"));
server.set("Stop-Action", updated.getMap("Servers").getMap(name).getRawString("Stop-Action", "NONE"));
server.set("Run-On-Launch", updated.getMap("Servers").getMap(name).getBoolean("Run-On-Launch", false));
server.set("Restricted", updated.getMap("Servers").getMap(name).getBoolean("Restricted", false));
server.set("Incompatible", updated.getMap("Servers").getMap(name).getRawStringList("Incompatible", Collections.emptyList()));
server.set("Hidden", updated.getMap("Servers").getMap(name).getBoolean("Hidden", false));
if (updated.getMap("Servers").getMap(name).contains("Extra")) server.set("Extra", updated.getMap("Servers").getMap(name).getMap("Extra"));
servers.set(name, server);
}
rewritten.set("Servers", servers);
config.set(rewritten);
config.save();
}
}
/**
* Update SubServers' lang.yml
*
* @param file File to bring up-to-date
*/
public static void updateLang(File file) throws IOException {
YAMLConfig config = new YAMLConfig(file);
YAMLSection existing = config.get().clone();
YAMLSection updated = existing.clone();
YAMLSection rewritten = new YAMLSection();
Version was = existing.getMap("Settings", new ObjectMap<>()).getVersion("Version", new Version(0));
Version now = SubAPI.getInstance().getWrapperBuild();
int i = 0;
if (now == null) now = UNSIGNED;
if (!existing.contains("Settings") || !existing.getMap("Settings").contains("Version")) {
i++;
Logger.get("SubServers").info("Created ./SubServers/lang.yml");
} else {
if (was.compareTo(new Version("19w22b")) <= 0) {
if (existing.contains("Lang")) {
updated.getMap("Lang").remove("Interface.Host-Admin.SubServers");
updated.getMap("Lang").remove("Interface.SubServer-Admin.Command");
}
existing = updated.clone();
i++;
} if (was.compareTo(new Version("20w08d")) <= 0) {
if (existing.contains("Lang")) {
LinkedList<String> keys = new LinkedList<>(existing.getMap("Lang").getKeys());
for (String key : keys) if (key.startsWith("Command.")) {
updated.getMap("Lang").remove(key);
}
}
existing = updated.clone();
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// i++
//}
if (i > 0) Logger.get("SubServers").info("Updated ./SubServers/lang.yml (" + i + " pass" + ((i != 1)?"es":"") + ")");
}
if (i > 0) {
YAMLSection settings = new YAMLSection();
settings.set("Version", ((now.compareTo(was) <= 0)?was:now).toString());
rewritten.set("Settings", settings);
LinkedHashMap<String, String> def = new LinkedHashMap<String, String>();
def.put("Bungee.Feature.Smart-Fallback", "&6Returning from $str$: &r$msg$");
def.put("Bungee.Feature.Smart-Fallback.Result", "&6You are now on $str$.");
def.put("Bungee.Ping.Offline", "&6&l[&e&lWarning&6&l] &7Backend server(s) are not running");
def.put("Bungee.Server.Current", "&6You are currently connected to $str$");
def.put("Bungee.Server.Available", "&6You may connect to the following servers at this time:");
def.put("Bungee.Server.List", "&6$str$");
def.put("Bungee.Server.Hover", "$int$ player(s)\\n&oClick to connect to the server");
def.put("Bungee.Server.Divider", "&6, ");
def.put("Bungee.Server.Offline", "&cThe specified server is not currently running.");
def.put("Bungee.Server.Invalid", "&cThe specified server does not exist.");
def.put("Bungee.List.Format", "&a[$str$] &e($int$)&r: ");
def.put("Bungee.List.List", "&f$str$");
def.put("Bungee.List.Divider", "&f, ");
def.put("Bungee.List.Total", "Total players online: $int$");
def.put("Command.Generic.Player-Only", "&cSubServers &4&l\\u00BB&c The console cannot perform this command");
def.put("Command.Generic.Console-Only", "&cSubServers &4&l\\u00BB&c This command is for console use only");
def.put("Command.Generic.Usage", "&7SubServers &8&l\\u00BB&7 Usage: &f$str$");
def.put("Command.Generic.Exception", "&cSubServers &4&l\\u00BB&c An unexpected exception has occurred while parsing this command");
def.put("Command.Generic.Invalid-Subcommand", "&cSubServers &4&l\\u00BB&c Unknown sub-command: $str$");
def.put("Command.Generic.Invalid-Permission", "&cSubServers &4&l\\u00BB&c You need &4&n$str$&c to use this command");
def.put("Command.Generic.Invalid-Select-Permission", "&cSubServers &4&l\\u00BB&c You don't have permission to select &4$str$");
def.put("Command.Generic.Unknown-Proxy", "&cSubServers &4&l\\u00BB&c There is no proxy with name &4$str$");
def.put("Command.Generic.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no host with name &4$str$");
def.put("Command.Generic.Unknown-Group", "&cSubServers &4&l\\u00BB&c There is no group with name &4$str$");
def.put("Command.Generic.Unknown-Server", "&cSubServers &4&l\\u00BB&c There is no server with name &4$str$");
def.put("Command.Generic.Unknown-SubServer", "&cSubServers &4&l\\u00BB&c There is no subserver with name &4$str$");
def.put("Command.Generic.Unknown-Player", "&cSubServers &4&l\\u00BB&c There is no player with name &4$str$");
def.put("Command.Generic.No-Servers-On-Host", "&7SubServers &8&l\\u00BB&7 There are no servers on host &f$str$");
def.put("Command.Generic.No-SubServers-On-Host", "&7SubServers &8&l\\u00BB&7 There are no subservers on host &f$str$");
def.put("Command.Generic.No-Servers-In-Group", "&7SubServers &8&l\\u00BB&7 There are no servers in group &f$str$");
def.put("Command.Generic.No-SubServers-In-Group", "&7SubServers &8&l\\u00BB&7 There are no subservers in group &f$str$");
def.put("Command.Generic.No-Servers-Selected", "&cSubServers &4&l\\u00BB&c No servers were selected");
def.put("Command.Generic.No-SubServers-Selected", "&cSubServers &4&l\\u00BB&c No subservers were selected");
def.put("Command.Help.Header", "&7SubServers &8&l\\u00BB&7 Command Help:");
def.put("Command.Help.Help", " &7Help:&f $str$");
def.put("Command.Help.List", " &7List:&f $str$");
def.put("Command.Help.Version", " &7Version:&f $str$");
def.put("Command.Help.Info", " &7Info:&f $str$");
def.put("Command.Help.Host.Create", " &7Create Server:&f $str$");
def.put("Command.Help.SubServer.Start", " &7Start Server:&f $str$");
def.put("Command.Help.SubServer.Restart", " &7Restart Server:&f $str$");
def.put("Command.Help.SubServer.Stop", " &7Stop Server:&f $str$");
def.put("Command.Help.SubServer.Terminate", " &7Terminate Server:&f $str$");
def.put("Command.Help.SubServer.Command", " &7Command Server:&f $str$");
def.put("Command.Help.SubServer.Update", " &7Update Server:&f $str$");
def.put("Command.Version", "&7SubServers &8&l\\u00BB&7 These are the platforms and versions that are running &f$str$&7:");
def.put("Command.Version.Outdated", "&7$name$ &f$str$ &7is available. You are $int$ version(s) behind.");
def.put("Command.Version.Latest", "&7You are on the latest version.");
def.put("Command.List.Group-Header", "&7SubServers &8&l\\u00BB&7 Group/Server List:");
def.put("Command.List.Host-Header", "&7SubServers &8&l\\u00BB&7 Host/SubServer List:");
def.put("Command.List.Server-Header", "&7SubServers &8&l\\u00BB&7 Server List:");
def.put("Command.List.Proxy-Header", "&7SubServers &8&l\\u00BB&7 Proxy List:");
def.put("Command.List.Header", "&7: ");
def.put("Command.List.Divider", "&7, ");
def.put("Command.List.Empty", "&7(none)");
def.put("Command.Info", "&7SubServers &8&l\\u00BB&7 Info on $str$&7: &r");
def.put("Command.Info.Unknown", "&cSubServers &4&l\\u00BB&c There is no object with that name");
def.put("Command.Info.Unknown-Type", "&cSubServers &4&l\\u00BB&c There is no object type with that name");
def.put("Command.Info.Unknown-Proxy", "&cSubServers &4&l\\u00BB&c There is no proxy with that name");
def.put("Command.Info.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no host with that name");
def.put("Command.Info.Unknown-Group", "&cSubServers &4&l\\u00BB&c There is no group with that name");
def.put("Command.Info.Unknown-Server", "&cSubServers &4&l\\u00BB&c There is no server with that name");
def.put("Command.Info.Unknown-Player", "&cSubServers &4&l\\u00BB&c There is no player with that name");
def.put("Command.Info.Format", " -> &7$str$&7: &r");
def.put("Command.Info.List", " - ");
def.put("Command.Start", "&aSubServers &2&l\\u00BB&a Started &2$int$&a subserver(s)");
def.put("Command.Start.Disappeared", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c has disappeared");
def.put("Command.Start.Host-Unavailable", "&cSubServers &4&l\\u00BB&c The host for &4$str$&c is not available");
def.put("Command.Start.Host-Disabled", "&cSubServers &4&l\\u00BB&c The host for &4$str$&c is not enabled");
def.put("Command.Start.Server-Unavailable", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c is not available");
def.put("Command.Start.Server-Disabled", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c is not enabled");
def.put("Command.Start.Server-Incompatible", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c cannot start while incompatible server(s) are running");
def.put("Command.Start.Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 subserver(s) were already running");
def.put("Command.Restart", "&aSubServers &2&l\\u00BB&a Restarting &2$int$&a subserver(s)");
def.put("Command.Restart.Disappeared", "&cSubServers &4&l\\u00BB&c Could not restart server: Subserver &4$str$&c has disappeared");
def.put("Command.Restart.Host-Unavailable", "&cSubServers &4&l\\u00BB&c Could not restart server: The host for &4$str$&c is no longer available");
def.put("Command.Restart.Host-Disabled", "&cSubServers &4&l\\u00BB&c Could not restart server: The host for &4$str$&c is no longer enabled");
def.put("Command.Restart.Server-Unavailable", "&cSubServers &4&l\\u00BB&c Could not restart server: Subserver &4$str$&c is no longer available");
def.put("Command.Restart.Server-Disabled", "&cSubServers &4&l\\u00BB&c Could not restart server: Subserver &4$str$&c is no longer enabled");
def.put("Command.Restart.Server-Incompatible", "&cSubServers &4&l\\u00BB&c Could not restart server: Subserver &4$str$&c cannot start while incompatible server(s) are running");
def.put("Command.Stop", "&aSubServers &2&l\\u00BB&a Stopping &2$int$&a subserver(s)");
def.put("Command.Stop.Disappeared", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c has disappeared");
def.put("Command.Stop.Not-Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 subserver(s) were already offline");
def.put("Command.Terminate", "&aSubServers &2&l\\u00BB&a Terminated &2$int$&a subserver(s)");
def.put("Command.Terminate.Disappeared", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c has disappeared");
def.put("Command.Terminate.Not-Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 subserver(s) were already offline");
def.put("Command.Command", "&aSubServers &2&l\\u00BB&a Sent command to &2$int$&a subserver(s)");
def.put("Command.Command.No-Command", "&cSubServers &4&l\\u00BB&c No command was entered");
def.put("Command.Command.Not-Running", "&7SubServers &8&l\\u00BB&7 &f$int$&7 subserver(s) were offline");
def.put("Command.Creator", "&aSubServers &2&l\\u00BB&a Creating subserver &2$str$&a");
def.put("Command.Creator.Exists", "&cSubServers &4&l\\u00BB&c There is already a subserver with that name");
def.put("Command.Creator.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no host with that name");
def.put("Command.Creator.Host-Unavailable", "&cSubServers &4&l\\u00BB&c That host is not available");
def.put("Command.Creator.Host-Disabled", "&cSubServers &4&l\\u00BB&c That host is not enabled");
def.put("Command.Creator.Unknown-Template", "&cSubServers &4&l\\u00BB&c There is no template with that name");
def.put("Command.Creator.Template-Disabled", "&cSubServers &4&l\\u00BB&c That template is not enabled");
def.put("Command.Creator.Version-Required", "&cSubServers &4&l\\u00BB&c That template requires a Minecraft version to be specified");
def.put("Command.Creator.Invalid-Port", "&cSubServers &4&l\\u00BB&c Invalid port number");
def.put("Command.Update", "&aSubServers &2&l\\u00BB&a Updating &2$int$&a subserver(s)");
def.put("Command.Update.Disappeared", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c has disappeared");
def.put("Command.Update.Host-Unavailable", "&cSubServers &4&l\\u00BB&c The host for &4$str$&c is not available");
def.put("Command.Update.Host-Disabled", "&cSubServers &4&l\\u00BB&c The host for &4$str$&c is not enabled");
def.put("Command.Update.Server-Unavailable", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c is not available");
def.put("Command.Update.Running", "&cSubServers &4&l\\u00BB&c Cannot update &4$str$&c while it is still running");
def.put("Command.Update.Unknown-Template", "&cSubServers &4&l\\u00BB&c We don't know which template created &4$str$");
def.put("Command.Update.Template-Disabled", "&cSubServers &4&l\\u00BB&c The template that created &4$str$&c is not enabled");
def.put("Command.Update.Template-Invalid", "&cSubServers &4&l\\u00BB&c The template that created &4$str$&c does not support subserver updating");
def.put("Command.Update.Version-Required", "&cSubServers &4&l\\u00BB&c The template that created &4$str$&c requires a Minecraft version to be specified");
def.put("Command.Teleport", "&aSubServers &2&l\\u00BB&a Teleporting &2$str$&a to server");
def.put("Command.Teleport.Not-Running", "&cSubServers &4&l\\u00BB&c Subserver &4$str$&c is not running");
def.put("Interface.Generic.Back", "&cBack");
def.put("Interface.Generic.Back-Arrow", "&e&l<--");
def.put("Interface.Generic.Next-Arrow", "&e&l-->");
def.put("Interface.Generic.Undo", "&6Undo");
def.put("Interface.Generic.Downloading", "&7SubServers &8&l\\u00BB&7 Downloading:&f $str$");
def.put("Interface.Generic.Downloading.Title", "Downloading...");
def.put("Interface.Generic.Downloading.Title-Color", "&b");
def.put("Interface.Generic.Downloading.Title-Color-Alt", "&3");
def.put("Interface.Generic.Downloading.Response", "&eWaiting for response");
def.put("Interface.Generic.Invalid-Permission", "&4You need &n$str$");
def.put("Interface.Proxy-Menu.Proxy-Player-Count", "&2$int$ Player(s) Online");
def.put("Interface.Proxy-Menu.Proxy-Master", "&8Master Proxy");
def.put("Interface.Proxy-Menu.Proxy-SubData", "&9SubData Only");
def.put("Interface.Proxy-Menu.Proxy-Redis", "&7Redis Only");
def.put("Interface.Proxy-Menu.Proxy-Disconnected", "&4Disconnected");
def.put("Interface.Host-Menu.Title", "Host Menu");
def.put("Interface.Host-Menu.Host-Unavailable", "&4Unavailable");
def.put("Interface.Host-Menu.Host-Disabled", "&4Disabled");
def.put("Interface.Host-Menu.Host-Server-Count", "&9$int$ Server(s)");
def.put("Interface.Host-Menu.No-Hosts", "&c&oThere are No Hosts");
def.put("Interface.Host-Menu.Group-Menu", "&6&lView Servers by Group");
def.put("Interface.Host-Menu.Server-Menu", "&a&lView Servers");
def.put("Interface.Host-Admin.Title", "Host/$str$");
def.put("Interface.Host-Admin.Creator", "&eCreate a SubServer");
def.put("Interface.Host-Admin.SubServers", "&bView SubServers");
def.put("Interface.Host-Admin.Plugins", "&bPlugins...");
def.put("Interface.Host-Creator.Title", "Host/$str$/Create");
def.put("Interface.Host-Creator.Edit-Name", "Change Name");
def.put("Interface.Host-Creator.Edit-Name.Title", "&eSubCreator\\n&6Enter a Name for this Server");
def.put("Interface.Host-Creator.Edit-Name.Message", "&eSubCreator &6&l\\u00BB&e Enter a Name for this Server via Chat");
def.put("Interface.Host-Creator.Edit-Name.Exists", "&cSubCreator &4&l\\u00BB&c There is already a SubServer with that name");
def.put("Interface.Host-Creator.Edit-Name.Exists-Title", "&eSubCreator\\n&cThere is already a SubServer with that name");
def.put("Interface.Host-Creator.Edit-Name.Invalid", "&cSubCreator &4&l\\u00BB&c Invalid Server Name");
def.put("Interface.Host-Creator.Edit-Name.Invalid-Title", "&eSubCreator\\n&cInvalid Server Name");
def.put("Interface.Host-Creator.Edit-Template", "Change Server Template");
def.put("Interface.Host-Creator.Edit-Template.Title", "Host/$str$/Templates");
def.put("Interface.Host-Creator.Edit-Template.No-Templates", "&c&oThere are No Templates");
def.put("Interface.Host-Creator.Edit-Version", "Change Server Version");
def.put("Interface.Host-Creator.Edit-Version.Title", "&eSubCreator\\n&6Enter a Server Version");
def.put("Interface.Host-Creator.Edit-Version.Message", "&eSubCreator &6&l\\u00BB&e Enter a Server Version via Chat");
def.put("Interface.Host-Creator.Edit-Port", "Change Server Port");
def.put("Interface.Host-Creator.Edit-Port.Title", "&eSubCreator\\n&6Enter a Port Number");
def.put("Interface.Host-Creator.Edit-Port.Message", "&eSubCreator &6&l\\u00BB&e Enter a Port Number via Chat");
def.put("Interface.Host-Creator.Edit-Port.Invalid", "&cSubCreator &4&l\\u00BB&c Invalid Port Number");
def.put("Interface.Host-Creator.Edit-Port.Invalid-Title", "&eSubCreator\\n&cInvalid Port Number");
def.put("Interface.Host-Creator.Submit", "&eCreate SubServer");
def.put("Interface.Host-Creator.Form-Incomplete", "&4Buttons above must be green");
def.put("Interface.Host-Plugin.Title", "Host/$str$/Plugins");
def.put("Interface.Host-Plugin.No-Plugins", "&c&oThere are No Plugins Available");
def.put("Interface.Host-SubServer.Title", "Host/$str$/SubServers");
def.put("Interface.Group-Menu.Title", "Group Menu");
def.put("Interface.Group-Menu.Group-Server-Count", "&9$int$ Server(s)");
def.put("Interface.Group-Menu.No-Groups", "&c&oThere are No Groups");
def.put("Interface.Group-Menu.Server-Menu", "&a&lView All Servers");
def.put("Interface.Group-SubServer.Title", "Group/$str$/Servers");
def.put("Interface.Server-Menu.Title", "Server Menu");
def.put("Interface.Server-Menu.Server-Player-Count", "&2$int$ Player(s) Online");
def.put("Interface.Server-Menu.Server-External", "&7External Server");
def.put("Interface.Server-Menu.SubServer-Temporary", "&9Temporary");
def.put("Interface.Server-Menu.SubServer-Offline", "&6Offline");
def.put("Interface.Server-Menu.SubServer-Incompatible", "&4Incompatible with $str$");
def.put("Interface.Server-Menu.SubServer-Unavailable", "&4Unavailable");
def.put("Interface.Server-Menu.SubServer-Disabled", "&4Disabled");
def.put("Interface.Server-Menu.SubServer-Invalid", "&4Cannot be managed by SubServers");
def.put("Interface.Server-Menu.No-Servers", "&c&oThere are No Servers");
def.put("Interface.Server-Menu.Host-Menu", "&b&lView Hosts");
def.put("Interface.SubServer-Admin.Title", "SubServer/$str$");
def.put("Interface.SubServer-Admin.Start", "&aStart SubServer");
def.put("Interface.SubServer-Admin.Start.Title", "&aStarting SubServer");
def.put("Interface.SubServer-Admin.Stop", "&cStop SubServer");
def.put("Interface.SubServer-Admin.Stop.Title", "&cStopping $str$");
def.put("Interface.SubServer-Admin.Terminate", "&4Terminate SubServer");
def.put("Interface.SubServer-Admin.Terminate.Title", "&cTerminating $str$");
def.put("Interface.SubServer-Admin.Command", "&bSend a Command to the SubServer");
def.put("Interface.SubServer-Admin.Command.Title", "&eSubServers\\n&6Enter a Command to send via Chat");
def.put("Interface.SubServer-Admin.Command.Message", "&eSubServers &6&l\\u00BB&e Enter a Command to send via Chat");
def.put("Interface.SubServer-Admin.Update", "&eUpdate SubServer");
def.put("Interface.SubServer-Admin.Update.Title", "&eSubServers\\n&6Enter a Server Version to update to");
def.put("Interface.SubServer-Admin.Update.Message", "&eSubServers &6&l\\u00BB&e Enter a Server Version to update to via Chat");
def.put("Interface.SubServer-Admin.Plugins", "&bPlugins...");
def.put("Interface.SubServer-Plugin.Title", "SubServer/$str$/Plugins");
def.put("Interface.SubServer-Plugin.No-Plugins", "&c&oThere are No Plugins Available");
YAMLSection lang = new YAMLSection();
for (String key : def.keySet()) lang.set(key, updated.getMap("Lang", new YAMLSection()).getRawString(key, def.get(key)));
rewritten.set("Lang", lang);
config.set(rewritten);
config.save();
}
}
}

View File

@ -1,485 +0,0 @@
package net.ME1312.SubServers.Bungee.Library.Updates;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubAPI;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* SubServers Configuration Updater
*/
public class ConfigUpdater {
private static final Version UNSIGNED = new Version(new SimpleDateFormat("yy'w'ww'zz'").format(Calendar.getInstance().getTime()));
/**
* Update SubServers' config.yml
*
* @param file File to bring up-to-date
*/
public static void updateConfig(File file) throws IOException {
YAMLConfig config = new YAMLConfig(file);
YAMLSection existing = config.get().clone();
YAMLSection updated = existing.clone();
YAMLSection rewritten = new YAMLSection();
Version was = existing.getMap("Settings", new ObjectMap<>()).getVersion("Version", new Version(0));
Version now = SubAPI.getInstance().getWrapperBuild();
int i = 0;
if (now == null) now = UNSIGNED;
if (!existing.contains("Settings") || !existing.getMap("Settings").contains("Version")) {
YAMLSection hosts = new YAMLSection();
YAMLSection host = new YAMLSection();
host.set("Enabled", true);
host.set("Display", "Default");
hosts.set("~", host);
updated.set("Hosts", hosts);
i++;
Logger.get("SubServers").info("Created ./SubServers/config.yml");
} else {
if (was.compareTo(new Version("19w17a")) <= 0) {
if (existing.getMap("Settings", new YAMLSection()).contains("Log-Creator")) for (String name : existing.getMap("Hosts", new YAMLSection()).getKeys())
updated.getMap("Hosts").getMap(name).safeSet("Log-Creator", existing.getMap("Settings").getBoolean("Log-Creator"));
if (existing.getMap("Settings", new YAMLSection()).contains("SubData") && !existing.getMap("Settings", new YAMLSection()).getMap("SubData").contains("Encryption"))
updated.getMap("Settings").getMap("SubData").set("Encryption", "NONE");
if (existing.contains("Servers")) {
YAMLConfig sc = new YAMLConfig(new File(file.getParentFile(), "servers.yml"));
YAMLSection settings = new YAMLSection();
settings.set("Version", was.toString());
settings.set("Run-On-Launch-Timeout", (existing.getMap("Settings", new YAMLSection()).contains("Run-On-Launch-Timeout"))?existing.getMap("Settings").getInt("Run-On-Launch-Timeout"):0);
sc.get().safeSet("Settings", settings);
sc.get().safeSet("Servers", new YAMLSection());
sc.get().getMap("Servers").safeSetAll(existing.getMap("Servers"));
Logger.get("SubServers").info("Created ./SubServers/servers.yml (using existing data)");
sc.save();
}
existing = updated.clone();
i++;
} if (was.compareTo(new Version("19w35c")) <= 0) {
if (existing.getMap("Settings", new YAMLSection()).contains("SubData")) {
LinkedList<String> whitelist = new LinkedList<>();
LinkedList<String> newWhitelist = new LinkedList<>();
whitelist.addAll(existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getStringList("Allowed-Connections", Collections.emptyList()));
whitelist.addAll(existing.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getStringList("Whitelist", Collections.emptyList()));
boolean warnPls = false;
for (String address : whitelist) {
Matcher regAddress = Pattern.compile("^(\\d{1,3}|%)\\.(\\d{1,3}|%)\\.(\\d{1,3}|%)\\.(\\d{1,3}|%)$").matcher(address);
if (regAddress.find()) {
StringBuilder newAddress = new StringBuilder();
int subnet = -1;
boolean warn = false;
for (int o = 1; o <= 4; o++) {
if (o > 1) newAddress.append('.');
if (subnet == -1) {
if (!regAddress.group(o).equals("%")) {
newAddress.append(regAddress.group(o));
} else {
subnet = 8 * (o - 1);
newAddress.append('0');
}
} else {
if (!regAddress.group(o).equals("%")) warn = warnPls = true;
newAddress.append('0');
}
}
if (subnet < 0) subnet = 32;
if (warn) Logger.get("SubServers").warning("Updating non-standard mask: " + address);
newAddress.append('/');
newAddress.append(subnet);
newWhitelist.add(newAddress.toString());
}
}
updated.getMap("Settings").getMap("SubData").set("Whitelist", newWhitelist);
if (warnPls) Logger.get("SubServers").warning("Non-standard masks have been updated. This may expose SubData to unintended networks!");
}
existing = updated.clone();
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// existing = updated.clone();
// i++
//}
if (i > 0) Logger.get("SubServers").info("Updated ./SubServers/config.yml (" + i + " pass" + ((i != 1)?"es":"") + ")");
}
if (i > 0) {
YAMLSection settings = new YAMLSection();
settings.set("Version", ((now.compareTo(was) <= 0)?was:now).toString());
settings.set("Smart-Fallback", updated.getMap("Settings", new YAMLSection()).getBoolean("Smart-Fallback", true));
settings.set("Override-Bungee-Commands", updated.getMap("Settings", new YAMLSection()).getBoolean("Override-Bungee-Commands", true));
YAMLSection upnp = new YAMLSection();
upnp.set("Forward-Proxy", updated.getMap("Settings", new YAMLSection()).getMap("UPnP", new YAMLSection()).getBoolean("Forward-Proxy", true));
upnp.set("Forward-SubData", updated.getMap("Settings", new YAMLSection()).getMap("UPnP", new YAMLSection()).getBoolean("Forward-SubData", false));
upnp.set("Forward-Servers", updated.getMap("Settings", new YAMLSection()).getMap("UPnP", new YAMLSection()).getBoolean("Forward-Servers", false));
settings.set("UPnP", upnp);
YAMLSection subdata = new YAMLSection();
subdata.set("Address", updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getRawString("Address", "127.0.0.1:4391"));
if (updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).contains("Password")) subdata.set("Password", updated.getMap("Settings").getMap("SubData").getRawString("Password"));
subdata.set("Encryption", updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getRawString("Encryption", "RSA/AES"));
subdata.set("Whitelist", updated.getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getRawStringList("Whitelist", Collections.emptyList()));
settings.set("SubData", subdata);
rewritten.set("Settings", settings);
YAMLSection hosts = new YAMLSection();
for (String name : updated.getMap("Hosts", new YAMLSection()).getKeys()) {
YAMLSection host = new YAMLSection();
host.set("Enabled", updated.getMap("Hosts").getMap(name).getBoolean("Enabled", false));
host.set("Display", updated.getMap("Hosts").getMap(name).getRawString("Display", ""));
host.set("Driver", updated.getMap("Hosts").getMap(name).getRawString("Driver", "BUILT-IN"));
host.set("Address", updated.getMap("Hosts").getMap(name).getRawString("Address", "127.0.0.1"));
host.set("Port-Range", updated.getMap("Hosts").getMap(name).getRawString("Port-Range", "25500-25559"));
host.set("Directory", updated.getMap("Hosts").getMap(name).getRawString("Directory", (host.getRawString("Driver").equalsIgnoreCase("BUILT-IN"))?"./SubServers/Servers":"./Servers"));
host.set("Git-Bash", updated.getMap("Hosts").getMap(name).getRawString("Git-Bash", "%ProgramFiles%\\Git"));
host.set("Log-Creator", updated.getMap("Hosts").getMap(name).getBoolean("Log-Creator", true));
if (updated.getMap("Hosts").getMap(name).contains("Extra")) host.set("Extra", updated.getMap("Hosts").getMap(name).getMap("Extra"));
hosts.set(name, host);
}
rewritten.set("Hosts", hosts);
config.set(rewritten);
config.save();
}
}
/**
* Update SubServers' servers.yml
*
* @param file File to bring up-to-date
*/
public static void updateServers(File file) throws IOException {
YAMLConfig config = new YAMLConfig(file);
YAMLSection existing = config.get().clone();
YAMLSection updated = existing.clone();
YAMLSection rewritten = new YAMLSection();
Version was = existing.getMap("Settings", new ObjectMap<>()).getVersion("Version", new Version(0));
Version now = SubAPI.getInstance().getWrapperBuild();
int i = 0;
if (now == null) now = UNSIGNED;
if (!existing.contains("Settings") || !existing.getMap("Settings").contains("Version")) {
YAMLSection servers = new YAMLSection();
servers.set("Example", new YAMLSection());
updated.set("Servers", servers);
i++;
Logger.get("SubServers").info("Created ./SubServers/servers.yml");
} else {
if (was.compareTo(new Version("19w17a")) <= 0) {
for (String name : existing.getMap("Servers", new YAMLSection()).getKeys()) {
if (existing.getMap("Servers").getMap(name).getBoolean("Auto-Restart", true))
updated.getMap("Servers").getMap(name).safeSet("Stop-Action", "RESTART");
if (existing.getMap("Servers").getMap(name).getRawString("Stop-Action", "NONE").equalsIgnoreCase("DELETE_SERVER"))
updated.getMap("Servers").getMap(name).set("Stop-Action", "RECYCLE_SERVER");
}
existing = updated.clone();
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// i++
//}
if (i > 0) Logger.get("SubServers").info("Updated ./SubServers/servers.yml (" + i + " pass" + ((i != 1)?"es":"") + ")");
}
if (i > 0) {
YAMLSection settings = new YAMLSection();
settings.set("Version", ((now.compareTo(was) <= 0)?was:now).toString());
settings.set("Run-On-Launch-Timeout", updated.getMap("Settings", new YAMLSection()).getInt("Run-On-Launch-Timeout", 0));
rewritten.set("Settings", settings);
YAMLSection servers = new YAMLSection();
for (String name : updated.getMap("Servers", new YAMLSection()).getKeys()) {
YAMLSection server = new YAMLSection();
server.set("Enabled", updated.getMap("Servers").getMap(name).getBoolean("Enabled", false));
server.set("Display", updated.getMap("Servers").getMap(name).getRawString("Display", ""));
server.set("Host", updated.getMap("Servers").getMap(name).getRawString("Host", "~"));
if (updated.getMap("Servers").getMap(name).contains("Template")) server.set("Template", updated.getMap("Servers").getMap(name).getRawString("Template"));
server.set("Group", updated.getMap("Servers").getMap(name).getRawStringList("Groups", Collections.emptyList()));
server.set("Port", updated.getMap("Servers").getMap(name).getInt("Port", 25567));
server.set("Motd", updated.getMap("Servers").getMap(name).getRawString("Motd", "Some SubServer"));
server.set("Log", updated.getMap("Servers").getMap(name).getBoolean("Log", true));
server.set("Directory", updated.getMap("Servers").getMap(name).getRawString("Directory", "." + File.separatorChar));
server.set("Executable", updated.getMap("Servers").getMap(name).getRawString("Executable", "java -Xmx1024M -Djline.terminal=jline.UnsupportedTerminal -jar Spigot.jar"));
server.set("Stop-Command", updated.getMap("Servers").getMap(name).getRawString("Stop-Command", "stop"));
server.set("Stop-Action", updated.getMap("Servers").getMap(name).getRawString("Stop-Action", "NONE"));
server.set("Run-On-Launch", updated.getMap("Servers").getMap(name).getBoolean("Run-On-Launch", false));
server.set("Restricted", updated.getMap("Servers").getMap(name).getBoolean("Restricted", false));
server.set("Incompatible", updated.getMap("Servers").getMap(name).getRawStringList("Incompatible", Collections.emptyList()));
server.set("Hidden", updated.getMap("Servers").getMap(name).getBoolean("Hidden", false));
if (updated.getMap("Servers").getMap(name).contains("Extra")) server.set("Extra", updated.getMap("Servers").getMap(name).getMap("Extra"));
servers.set(name, server);
}
rewritten.set("Servers", servers);
config.set(rewritten);
config.save();
}
}
/**
* Update SubServers' lang.yml
*
* @param file File to bring up-to-date
*/
public static void updateLang(File file) throws IOException {
YAMLConfig config = new YAMLConfig(file);
YAMLSection existing = config.get().clone();
YAMLSection updated = existing.clone();
YAMLSection rewritten = new YAMLSection();
Version was = existing.getMap("Settings", new ObjectMap<>()).getVersion("Version", new Version(0));
Version now = SubAPI.getInstance().getWrapperBuild();
int i = 0;
if (now == null) now = UNSIGNED;
if (!existing.contains("Settings") || !existing.getMap("Settings").contains("Version")) {
i++;
Logger.get("SubServers").info("Created ./SubServers/lang.yml");
} else {
if (was.compareTo(new Version("19w22b")) <= 0) {
updated.getMap("Lang").remove("Interface.Host-Admin.SubServers");
updated.getMap("Lang").remove("Interface.SubServer-Admin.Command");
i++;
}// if (was.compareTo(new Version("99w99a")) <= 0) {
// // do something
// i++
//}
if (i > 0) Logger.get("SubServers").info("Updated ./SubServers/lang.yml (" + i + " pass" + ((i != 1)?"es":"") + ")");
}
if (i > 0) {
YAMLSection settings = new YAMLSection();
settings.set("Version", ((now.compareTo(was) <= 0)?was:now).toString());
rewritten.set("Settings", settings);
YAMLSection lang = new YAMLSection();
lang.set("Bungee.Feature.Smart-Fallback", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Feature.Smart-Fallback", "&6Returning from $str$: &r$msg$"));
lang.set("Bungee.Feature.Smart-Fallback.Result", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Feature.Smart-Fallback.Result", "&6You are now on $str$."));
lang.set("Bungee.Ping.Offline", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Ping.Offline", "&6&l[&e&lWarning&6&l] &7Backend server(s) are not running"));
lang.set("Bungee.Server.Current", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Current", "&6You are currently connected to $str$"));
lang.set("Bungee.Server.Available", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Available", "&6You may connect to the following servers at this time:"));
lang.set("Bungee.Server.List", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.List", "&6$str$"));
lang.set("Bungee.Server.Hover", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Hover", "$int$ player(s)\\n&oClick to connect to the server"));
lang.set("Bungee.Server.Divider", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Divider", "&6, "));
lang.set("Bungee.Server.Offline", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Offline", "&cThe specified server is not currently running."));
lang.set("Bungee.Server.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.Server.Invalid", "&cThe specified server does not exist."));
lang.set("Bungee.List.Format", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.List.Format", "&a[$str$] &e($int$)&r: "));
lang.set("Bungee.List.List", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.List.List", "&f$str$"));
lang.set("Bungee.List.Divider", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.List.Divider", "&f, "));
lang.set("Bungee.List.Total", updated.getMap("Lang", new YAMLSection()).getRawString("Bungee.List.Total", "Total players online: $int$"));
lang.set("Command.Generic.Player-Only", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Player-Only", "&cSubServers &4&l\\u00BB&c Console cannot run this command"));
lang.set("Command.Generic.Console-Only", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Console-Only", "&cSubServers &4&l\\u00BB&c This command is for console use only"));
lang.set("Command.Generic.Usage", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Usage", "&7SubServers &8&l\\u00BB&7 Usage: &f$str$"));
lang.set("Command.Generic.Exception", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Exception", "&cSubServers &4&l\\u00BB&c An unexpected exception has occurred while parsing this command"));
lang.set("Command.Generic.Invalid-Subcommand", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Invalid-Subcommand", "&cSubServers &4&l\\u00BB&c Unknown sub-command: $str$"));
lang.set("Command.Generic.Invalid-Permission", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Invalid-Permission", "&cSubServers &4&l\\u00BB&c You need &4&n$str$&c to use this command"));
lang.set("Command.Generic.Unknown-Proxy", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Unknown-Proxy", "&cSubServers &4&l\\u00BB&c There is no proxy with that name"));
lang.set("Command.Generic.Unknown-Host", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no host with that name"));
lang.set("Command.Generic.Unknown-Group", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Unknown-Group", "&cSubServers &4&l\\u00BB&c There is no group with that name"));
lang.set("Command.Generic.Unknown-Server", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Unknown-Server", "&cSubServers &4&l\\u00BB&c There is no server with that name"));
lang.set("Command.Generic.Unknown-SubServer", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Generic.Unknown-SubServer", "&cSubServers &4&l\\u00BB&c There is no subserver with that name"));
lang.set("Command.Help.Header", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.Header", "&7SubServers &8&l\\u00BB&7 Command Help:"));
lang.set("Command.Help.Help", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.Help", " &7Help:&f $str$"));
lang.set("Command.Help.List", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.List", " &7List:&f $str$"));
lang.set("Command.Help.Version", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.Version", " &7Version:&f $str$"));
lang.set("Command.Help.Info", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.Info", " &7Info:&f $str$"));
lang.set("Command.Help.Host.Create", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.Host.Create", " &7Create Server:&f $str$"));
lang.set("Command.Help.SubServer.Start", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.SubServer.Start", " &7Start Server:&f $str$"));
lang.set("Command.Help.SubServer.Restart", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.SubServer.Restart", " &7Restart Server:&f $str$"));
lang.set("Command.Help.SubServer.Stop", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.SubServer.Stop", " &7Stop Server:&f $str$"));
lang.set("Command.Help.SubServer.Terminate", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.SubServer.Terminate", " &7Terminate Server:&f $str$"));
lang.set("Command.Help.SubServer.Command", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.SubServer.Command", " &7Command Server:&f $str$"));
lang.set("Command.Help.SubServer.Update", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Help.SubServer.Update", " &7Update Server:&f $str$"));
lang.set("Command.Version", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Version", "&7SubServers &8&l\\u00BB&7 These are the platforms and versions that are running &f$str$&7:"));
lang.set("Command.Version.Outdated", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Version.Outdated", "&7$name$ &f$str$ &7is available. You are $int$ version(s) behind."));
lang.set("Command.Version.Latest", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Version.Latest", "&7You are on the latest version."));
lang.set("Command.List.Group-Header", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Group-Header", "&7SubServers &8&l\\u00BB&7 Group/Server List:"));
lang.set("Command.List.Host-Header", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Host-Header", "&7SubServers &8&l\\u00BB&7 Host/SubServer List:"));
lang.set("Command.List.Server-Header", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Server-Header", "&7SubServers &8&l\\u00BB&7 Server List:"));
lang.set("Command.List.Proxy-Header", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Proxy-Header", "&7SubServers &8&l\\u00BB&7 Proxy List:"));
lang.set("Command.List.Header", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Header", "&7: "));
lang.set("Command.List.Divider", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Divider", "&7, "));
lang.set("Command.List.Empty", updated.getMap("Lang", new YAMLSection()).getRawString("Command.List.Empty", "&7(none)"));
lang.set("Command.Info", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info", "&7SubServers &8&l\\u00BB&7 Info on $str$&7: &r"));
lang.set("Command.Info.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Unknown", "&cSubServers &4&l\\u00BB&c There is no object with that name"));
lang.set("Command.Info.Unknown-Type", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Unknown-Type", "&cSubServers &4&l\\u00BB&c There is no object type with that name"));
lang.set("Command.Info.Unknown-Proxy", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Unknown-Proxy", "&cSubServers &4&l\\u00BB&c There is no proxy with that name"));
lang.set("Command.Info.Unknown-Host", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no host with that name"));
lang.set("Command.Info.Unknown-Group", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Unknown-Group", "&cSubServers &4&l\\u00BB&c There is no group with that name"));
lang.set("Command.Info.Unknown-Server", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Unknown-Server", "&cSubServers &4&l\\u00BB&c There is no server with that name"));
lang.set("Command.Info.Format", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.Format", " -> &7$str$&7: &r"));
lang.set("Command.Info.List", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Info.List", " - "));
lang.set("Command.Start", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start", "&aSubServers &2&l\\u00BB&a Starting SubServer"));
lang.set("Command.Start.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Unknown", "&cSubServers &4&l\\u00BB&c There is no Server with that name"));
lang.set("Command.Start.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Invalid", "&cSubServers &4&l\\u00BB&c That Server is not a SubServer"));
lang.set("Command.Start.Host-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Host-Unavailable", "&cSubServers &4&l\\u00BB&c That SubServer\\u0027s Host is not available"));
lang.set("Command.Start.Host-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Host-Disabled", "&cSubServers &4&l\\u00BB&c That SubServer\\u0027s Host is not enabled"));
lang.set("Command.Start.Server-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Server-Unavailable", "&cSubServers &4&l\\u00BB&c That SubServer is not available"));
lang.set("Command.Start.Server-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Server-Disabled", "&cSubServers &4&l\\u00BB&c That SubServer is not enabled"));
lang.set("Command.Start.Server-Incompatible", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Server-Incompatible", "&cSubServers &4&l\\u00BB&c That SubServer cannot start while these server(s) are running: &4$str$"));
lang.set("Command.Start.Running", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Start.Running", "&cSubServers &4&l\\u00BB&c That SubServer is already running"));
lang.set("Command.Restart", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart", "&aSubServers &2&l\\u00BB&a Stopping SubServer"));
lang.set("Command.Restart.Finish", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Finish", "&aSubServers &2&l\\u00BB&a Starting SubServer"));
lang.set("Command.Restart.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Unknown", "&cSubServers &4&l\\u00BB&c There is no Server with that name"));
lang.set("Command.Restart.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Invalid", "&cSubServers &4&l\\u00BB&c That Server is not a SubServer"));
lang.set("Command.Restart.Disappeared", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Disappeared", "&cSubServers &4&l\\u00BB&c Could not restart server: That SubServer has disappeared"));
lang.set("Command.Restart.Host-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Host-Unavailable", "&cSubServers &4&l\\u00BB&c Could not restart server: That SubServer\\u0027s Host is no longer available"));
lang.set("Command.Restart.Host-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Host-Disabled", "&cSubServers &4&l\\u00BB&c Could not restart server: That SubServer\\u0027s Host is no longer enabled"));
lang.set("Command.Restart.Server-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Server-Unavailable", "&cSubServers &4&l\\u00BB&c Could not restart server: That SubServer is no longer available"));
lang.set("Command.Restart.Server-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Server-Disabled", "&cSubServers &4&l\\u00BB&c Could not restart server: That SubServer is no longer enabled"));
lang.set("Command.Restart.Server-Incompatible", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Restart.Server-Incompatible", "&cSubServers &4&l\\u00BB&c Could not restart server: That SubServer cannot start while these server(s) are running: &4$str$"));
lang.set("Command.Stop", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Stop", "&aSubServers &2&l\\u00BB&a Stopping SubServer"));
lang.set("Command.Stop.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Stop.Unknown", "&cSubServers &4&l\\u00BB&c There is no Server with that name"));
lang.set("Command.Stop.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Stop.Invalid", "&cSubServers &4&l\\u00BB&c That Server is not a SubServer"));
lang.set("Command.Stop.Not-Running", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Stop.Not-Running", "&cSubServers &4&l\\u00BB&c That SubServer is not running"));
lang.set("Command.Terminate", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Terminate", "&aSubServers &2&l\\u00BB&a Stopping SubServer"));
lang.set("Command.Terminate.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Terminate.Unknown", "&cSubServers &4&l\\u00BB&c There is no Server with that name"));
lang.set("Command.Terminate.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Terminate.Invalid", "&cSubServers &4&l\\u00BB&c That Server is not a SubServer"));
lang.set("Command.Terminate.Not-Running", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Terminate.Not-Running", "&cSubServers &4&l\\u00BB&c That SubServer is not running"));
lang.set("Command.Command", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Command", "&aSubServers &2&l\\u00BB&a Sending command to SubServer"));
lang.set("Command.Command.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Command.Unknown", "&cSubServers &4&l\\u00BB&c There is no Server with that name"));
lang.set("Command.Command.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Command.Invalid", "&cSubServers &4&l\\u00BB&c That Server is not a SubServer"));
lang.set("Command.Command.Not-Running", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Command.Not-Running", "&cSubServers &4&l\\u00BB&c That SubServer is not running"));
lang.set("Command.Creator", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator", "&aSubServers &2&l\\u00BB&a Creating SubServer"));
lang.set("Command.Creator.Exists", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Exists", "&cSubServers &4&l\\u00BB&c There is already a SubServer with that name"));
lang.set("Command.Creator.Unknown-Host", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Unknown-Host", "&cSubServers &4&l\\u00BB&c There is no Host with that name"));
lang.set("Command.Creator.Host-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Host-Unavailable", "&cSubServers &4&l\\u00BB&c That Host is not available"));
lang.set("Command.Creator.Host-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Host-Disabled", "&cSubServers &4&l\\u00BB&c That Host is not enabled"));
lang.set("Command.Creator.Unknown-Template", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Unknown-Template", "&cSubServers &4&l\\u00BB&c There is no Template with that name"));
lang.set("Command.Creator.Template-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Template-Disabled", "&cSubServers &4&l\\u00BB&c That Template is not enabled"));
lang.set("Command.Creator.Version-Required", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Version-Required", "&cSubServers &4&l\\u00BB&c That Template requires a Minecraft Version to be specified"));
lang.set("Command.Creator.Invalid-Port", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator.Invalid-Port", "&cSubServers &4&l\\u00BB&c Invalid Port Number"));
lang.set("Command.Update", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Creator", "&aSubServers &2&l\\u00BB&a Updating SubServer"));
lang.set("Command.Update.Unknown", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Unknown", "&cSubServers &4&l\\u00BB&c There is no Server with that name"));
lang.set("Command.Update.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Invalid", "&cSubServers &4&l\\u00BB&c That Server is not a SubServer"));
lang.set("Command.Update.Host-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Host-Unavailable", "&cSubServers &4&l\\u00BB&c That SubServer\\u0027s Host is not available"));
lang.set("Command.Update.Host-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Host-Disabled", "&cSubServers &4&l\\u00BB&c That SubServer\\u0027s Host is not enabled"));
lang.set("Command.Update.Server-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Server-Unavailable", "&cSubServers &4&l\\u00BB&c That SubServer is not available"));
lang.set("Command.Update.Running", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Running", "&cSubServers &4&l\\u00BB&c Cannot update servers while they are still running"));
lang.set("Command.Update.Unknown-Template", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Unknown-Template", "&cSubServers &4&l\\u00BB&c We don't know which template created that SubServer"));
lang.set("Command.Update.Template-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Template-Disabled", "&cSubServers &4&l\\u00BB&c That SubServer's Template is not enabled"));
lang.set("Command.Update.Template-Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Template-Invalid", "&cSubServers &4&l\\u00BB&c That SubServer's Template does not support server updating"));
lang.set("Command.Update.Version-Required", updated.getMap("Lang", new YAMLSection()).getRawString("Command.Update.Version-Required", "&cSubServers &4&l\\u00BB&c That SubServer's Template requires a Minecraft Version to be specified"));
lang.set("Interface.Generic.Back", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Back", "&cBack"));
lang.set("Interface.Generic.Back-Arrow", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Back-Arrow", "&e&l<--"));
lang.set("Interface.Generic.Next-Arrow", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Next-Arrow", "&e&l-->"));
lang.set("Interface.Generic.Undo", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Undo", "&6Undo"));
lang.set("Interface.Generic.Downloading", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Downloading", "&7SubServers &8&l\\u00BB&7 Downloading:&f $str$"));
lang.set("Interface.Generic.Downloading.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Downloading.Title", "Downloading..."));
lang.set("Interface.Generic.Downloading.Title-Color", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Downloading.Title-Color", "&b"));
lang.set("Interface.Generic.Downloading.Title-Color-Alt", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Downloading.Title-Color-Alt", "&3"));
lang.set("Interface.Generic.Downloading.Response", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Downloading.Response", "&eWaiting for response"));
lang.set("Interface.Generic.Invalid-Permission", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Generic.Invalid-Permission", "&4You need &n$str$"));
lang.set("Interface.Proxy-Menu.Proxy-Player-Count", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Proxy-Menu.Proxy-Player-Count", "&2$int$ Player(s) Online"));
lang.set("Interface.Proxy-Menu.Proxy-Master", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Proxy-Menu.Proxy-Master", "&8Master Proxy"));
lang.set("Interface.Proxy-Menu.Proxy-SubData", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Proxy-Menu.Proxy-SubData", "&9SubData Only"));
lang.set("Interface.Proxy-Menu.Proxy-Redis", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Proxy-Menu.Proxy-Redis", "&7Redis Only"));
lang.set("Interface.Proxy-Menu.Proxy-Disconnected", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Proxy-Menu.Proxy-Disconnected", "&4Disconnected"));
lang.set("Interface.Host-Menu.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.Title", "Host Menu"));
lang.set("Interface.Host-Menu.Host-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.Host-Unavailable", "&4Unavailable"));
lang.set("Interface.Host-Menu.Host-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.Host-Disabled", "&4Disabled"));
lang.set("Interface.Host-Menu.Host-Server-Count", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.Host-Server-Count", "&9$int$ Server(s)"));
lang.set("Interface.Host-Menu.No-Hosts", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.No-Hosts", "&c&oThere are No Hosts"));
lang.set("Interface.Host-Menu.Group-Menu", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.Group-Menu", "&6&lView Servers by Group"));
lang.set("Interface.Host-Menu.Server-Menu", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Menu.Server-Menu", "&a&lView Servers"));
lang.set("Interface.Host-Admin.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Admin.Title", "Host/$str$"));
lang.set("Interface.Host-Admin.Creator", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Admin.Creator", "&eCreate a SubServer"));
lang.set("Interface.Host-Admin.SubServers", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Admin.SubServers", "&bView SubServers"));
lang.set("Interface.Host-Admin.Plugins", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Admin.Plugins", "&bPlugins..."));
lang.set("Interface.Host-Creator.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Title", "Host/$str$/Create"));
lang.set("Interface.Host-Creator.Edit-Name", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name", "Change Name"));
lang.set("Interface.Host-Creator.Edit-Name.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name.Title", "&eSubCreator\\n&6Enter a Name for this Server"));
lang.set("Interface.Host-Creator.Edit-Name.Message", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name.Message", "&eSubCreator &6&l\\u00BB&e Enter a Name for this Server via Chat"));
lang.set("Interface.Host-Creator.Edit-Name.Exists", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name.Exists", "&cSubCreator &4&l\\u00BB&c There is already a SubServer with that name"));
lang.set("Interface.Host-Creator.Edit-Name.Exists-Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name.Exists-Title", "&eSubCreator\\n&cThere is already a SubServer with that name"));
lang.set("Interface.Host-Creator.Edit-Name.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name.Invalid", "&cSubCreator &4&l\\u00BB&c Invalid Server Name"));
lang.set("Interface.Host-Creator.Edit-Name.Invalid-Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Name.Invalid-Title", "&eSubCreator\\n&cInvalid Server Name"));
lang.set("Interface.Host-Creator.Edit-Template", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Template", "Change Server Template"));
lang.set("Interface.Host-Creator.Edit-Template.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Template.Title", "Host/$str$/Templates"));
lang.set("Interface.Host-Creator.Edit-Template.No-Templates", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Template.No-Templates", "&c&oThere are No Templates"));
lang.set("Interface.Host-Creator.Edit-Version", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Version", "Change Server Version"));
lang.set("Interface.Host-Creator.Edit-Version.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Version.Title", "&eSubCreator\\n&6Enter a Server Version"));
lang.set("Interface.Host-Creator.Edit-Version.Message", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Version.Message", "&eSubCreator &6&l\\u00BB&e Enter a Server Version via Chat"));
lang.set("Interface.Host-Creator.Edit-Port", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Port", "Change Server Port"));
lang.set("Interface.Host-Creator.Edit-Port.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Port.Title", "&eSubCreator\\n&6Enter a Port Number"));
lang.set("Interface.Host-Creator.Edit-Port.Message", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Port.Message", "&eSubCreator &6&l\\u00BB&e Enter a Port Number via Chat"));
lang.set("Interface.Host-Creator.Edit-Port.Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Port.Invalid", "&cSubCreator &4&l\\u00BB&c Invalid Port Number"));
lang.set("Interface.Host-Creator.Edit-Port.Invalid-Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Edit-Port.Invalid-Title", "&eSubCreator\\n&cInvalid Port Number"));
lang.set("Interface.Host-Creator.Submit", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Submit", "&eCreate SubServer"));
lang.set("Interface.Host-Creator.Form-Incomplete", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Creator.Form-Incomplete", "&4Buttons above must be green"));
lang.set("Interface.Host-Plugin.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Plugin.Title", "Host/$str$/Plugins"));
lang.set("Interface.Host-Plugin.No-Plugins", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-Plugin.No-Plugins", "&c&oThere are No Plugins Available"));
lang.set("Interface.Host-SubServer.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Host-SubServer.Title", "Host/$str$/SubServers"));
lang.set("Interface.Group-Menu.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Group-Menu.Title", "Group Menu"));
lang.set("Interface.Group-Menu.Group-Server-Count", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Group-Menu.Group-Server-Count", "&9$int$ Server(s)"));
lang.set("Interface.Group-Menu.No-Groups", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Group-Menu.No-Groups", "&c&oThere are No Groups"));
lang.set("Interface.Group-Menu.Server-Menu", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Group-Menu.Server-Menu", "&a&lView All Servers"));
lang.set("Interface.Group-SubServer.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Group-SubServer.Title", "Group/$str$/Servers"));
lang.set("Interface.Server-Menu.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.Title", "Server Menu"));
lang.set("Interface.Server-Menu.Server-Player-Count", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.Server-Player-Count", "&2$int$ Player(s) Online"));
lang.set("Interface.Server-Menu.Server-External", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.Server-External", "&7External Server"));
lang.set("Interface.Server-Menu.SubServer-Temporary", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.SubServer-Temporary", "&9Temporary"));
lang.set("Interface.Server-Menu.SubServer-Offline", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.SubServer-Offline", "&6Offline"));
lang.set("Interface.Server-Menu.SubServer-Incompatible", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.SubServer-Incompatible", "&4Incompatible with $str$"));
lang.set("Interface.Server-Menu.SubServer-Unavailable", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.SubServer-Unavailable", "&4Unavailable"));
lang.set("Interface.Server-Menu.SubServer-Disabled", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.SubServer-Disabled", "&4Disabled"));
lang.set("Interface.Server-Menu.SubServer-Invalid", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.SubServer-Invalid", "&4Cannot be managed by SubServers"));
lang.set("Interface.Server-Menu.No-Servers", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.No-Servers", "&c&oThere are No Servers"));
lang.set("Interface.Server-Menu.Host-Menu", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.Server-Menu.Host-Menu", "&b&lView Hosts"));
lang.set("Interface.SubServer-Admin.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Title", "SubServer/$str$"));
lang.set("Interface.SubServer-Admin.Start", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Start", "&aStart SubServer"));
lang.set("Interface.SubServer-Admin.Start.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Start.Title", "&aStarting SubServer"));
lang.set("Interface.SubServer-Admin.Stop", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Stop", "&cStop SubServer"));
lang.set("Interface.SubServer-Admin.Stop.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Stop.Title", "&cStopping $str$"));
lang.set("Interface.SubServer-Admin.Terminate", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Terminate", "&4Terminate SubServer"));
lang.set("Interface.SubServer-Admin.Terminate.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Terminate.Title", "&cTerminating $str$"));
lang.set("Interface.SubServer-Admin.Command", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Command", "&bSend a Command to the SubServer"));
lang.set("Interface.SubServer-Admin.Command.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Command.Title", "&eSubServers\\n&6Enter a Command to send via Chat"));
lang.set("Interface.SubServer-Admin.Command.Message", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Command.Message", "&eSubServers &6&l\\u00BB&e Enter a Command to send via Chat"));
lang.set("Interface.SubServer-Admin.Update", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Update", "&eUpdate SubServer"));
lang.set("Interface.SubServer-Admin.Update.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Update.Title", "&eSubServers\\n&6Enter a Server Version to update to"));
lang.set("Interface.SubServer-Admin.Update.Message", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Update.Message", "&eSubServers &6&l\\u00BB&e Enter a Server Version to update to via Chat"));
lang.set("Interface.SubServer-Admin.Plugins", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Admin.Plugins", "&bPlugins..."));
lang.set("Interface.SubServer-Plugin.Title", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Plugin.Title", "SubServer/$str$/Plugins"));
lang.set("Interface.SubServer-Plugin.No-Plugins", updated.getMap("Lang", new YAMLSection()).getRawString("Interface.SubServer-Plugin.No-Plugins", "&c&oThere are No Plugins Available"));
rewritten.set("Lang", lang);
config.set(rewritten);
config.save();
}
}
}

View File

@ -8,6 +8,9 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
@ -15,7 +18,7 @@ import java.util.UUID;
*/
public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubProxy plugin;
private String group;
private String[] groups;
private UUID tracker;
/**
@ -32,30 +35,34 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
* New PacketDownloadGroupInfo (Out)
*
* @param plugin SubPlugin
* @param group Group (or null for all)
* @param groups Groups (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadGroupInfo(SubProxy plugin, String group, UUID tracker) {
public PacketDownloadGroupInfo(SubProxy plugin, List<String> groups, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.group = group;
this.tracker = tracker;
if (groups != null) {
this.groups = new String[groups.size()];
for (int i = 0; i < this.groups.length; ++i) this.groups[i] = groups.get(i).toLowerCase();
Arrays.sort(this.groups);
}
}
@SuppressWarnings("unchecked")
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
ObjectMap<String> groups = new ObjectMap<String>();
for (String group : plugin.api.getGroups().keySet()) {
if (this.group == null || this.group.length() <= 0 || this.group.equalsIgnoreCase(group)) {
for (Map.Entry<String, List<Server>> group : plugin.api.getGroups().entrySet()) {
if (this.groups == null || this.groups.length <= 0 || Arrays.binarySearch(this.groups, group.getKey().toLowerCase()) >= 0) {
ObjectMap<String> servers = new ObjectMap<String>();
for (Server server : plugin.api.getGroup(group)) {
for (Server server : group.getValue()) {
servers.set(server.getName(), server.forSubData());
}
groups.set(group, servers);
groups.set(group.getKey(), servers);
}
}
data.set(0x0001, groups);
@ -64,7 +71,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
client.sendPacket(new PacketDownloadGroupInfo(plugin, (data.contains(0x0001))?data.getRawString(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
client.sendPacket(new PacketDownloadGroupInfo(plugin, (data.contains(0x0001))?data.getRawStringList(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -8,6 +8,8 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
@ -15,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubProxy plugin;
private String host;
private String[] hosts;
private UUID tracker;
/**
@ -32,17 +34,21 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
* New PacketDownloadHostInfo (Out)
*
* @param plugin SubPlugin
* @param host Host (or null for all)
* @param hosts Hosts (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadHostInfo(SubProxy plugin, String host, UUID tracker) {
public PacketDownloadHostInfo(SubProxy plugin, List<String> hosts, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.host = host;
this.tracker = tracker;
if (hosts != null) {
this.hosts = new String[hosts.size()];
for (int i = 0; i < this.hosts.length; ++i) this.hosts[i] = hosts.get(i).toLowerCase();
Arrays.sort(this.hosts);
}
}
@SuppressWarnings("unchecked")
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
@ -50,7 +56,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
ObjectMap<String> hosts = new ObjectMap<String>();
for (Host host : plugin.api.getHosts().values()) {
if (this.host == null || this.host.length() <= 0 || this.host.equalsIgnoreCase(host.getName())) {
if (this.hosts == null || this.hosts.length <= 0 || Arrays.binarySearch(this.hosts, host.getName().toLowerCase()) >= 0) {
hosts.set(host.getName(), host.forSubData());
}
}
@ -60,7 +66,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
client.sendPacket(new PacketDownloadHostInfo(plugin, (data.contains(0x0001))?data.getRawString(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
client.sendPacket(new PacketDownloadHostInfo(plugin, (data.contains(0x0001))?data.getRawStringList(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -0,0 +1,90 @@
package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.Host.RemotePlayer;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
* Download Player Info Packet
*/
public class PacketDownloadPlayerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubProxy plugin;
private String[] names;
private UUID[] ids;
private UUID tracker;
/**
* New PacketDownloadPlayerInfo (In)
*
* @param plugin SubPlugin
*/
public PacketDownloadPlayerInfo(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
/**
* New PacketDownloadPlayerInfo (Out)
*
* @param plugin SubPlugin
* @param names Player names (or null for all)
* @param ids Player IDs (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadPlayerInfo(SubProxy plugin, List<String> names, List<UUID> ids, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.tracker = tracker;
if (ids != null) {
this.ids = new UUID[ids.size()];
for (int i = 0; i < this.ids.length; ++i) this.ids[i] = ids.get(i);
}
if (names != null) {
this.names = new String[names.size()];
for (int i = 0; i < this.names.length; ++i) this.names[i] = names.get(i);
}
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
ObjectMap<String> players = new ObjectMap<String>();
if (ids == null && names == null) {
for (RemotePlayer player : plugin.api.getGlobalPlayers().values()) {
players.set(player.getUniqueId().toString(), player.forSubData());
}
} else {
if (ids != null) for (UUID id : ids) {
RemotePlayer player = plugin.api.getGlobalPlayer(id);
if (player != null) players.set(player.getUniqueId().toString(), player.forSubData());
}
if (names != null) for (String name : names) {
RemotePlayer player = plugin.api.getGlobalPlayer(name);
if (player != null) players.set(player.getUniqueId().toString(), player.forSubData());
}
}
data.set(0x0001, players);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
client.sendPacket(new PacketDownloadPlayerInfo(plugin, (data.contains(0x0001))?data.getRawStringList(0x0001):null, (data.contains(0x0002))?data.getUUIDList(0x0002):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -1,76 +0,0 @@
package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.UUID;
/**
* Download Player List Packet
*/
public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubProxy plugin;
private UUID tracker;
/**
* New PacketDownloadPlayerList (In)
*
* @param plugin SubPlugin
*/
public PacketDownloadPlayerList(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
/**
* New PacketDownloadPlayerList (Out)
*
* @param plugin SubPlugin
* @param tracker Receiver ID
*/
public PacketDownloadPlayerList(SubProxy plugin, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.tracker = tracker;
}
@SuppressWarnings("unchecked")
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
ObjectMap<String> players = new ObjectMap<String>();
for (NamedContainer<String, UUID> player : plugin.api.getGlobalPlayers()) {
ObjectMap<String> pinfo = new ObjectMap<String>();
pinfo.set("name", player.get());
if (plugin.redis != null) {
try {
pinfo.set("server", ((ServerInfo) plugin.redis("getServerFor", new NamedContainer<>(UUID.class, player.get()))).getName());
} catch (Exception e) {
e.printStackTrace();
}
} else {
pinfo.set("server", plugin.getPlayer(player.get()).getServer().getInfo().getName());
}
players.set(player.get().toString(), pinfo);
}
data.set(0x0001, players);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
client.sendPacket(new PacketDownloadPlayerList(plugin, (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -8,6 +8,8 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
@ -15,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubProxy plugin;
private String proxy;
private String[] proxies;
private UUID tracker;
/**
@ -32,17 +34,21 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
* New PacketDownloadProxyInfo (Out)
*
* @param plugin SubPlugin
* @param proxy Proxy (or null for all)
* @param proxies Proxies (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadProxyInfo(SubProxy plugin, String proxy, UUID tracker) {
public PacketDownloadProxyInfo(SubProxy plugin, List<String> proxies, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.proxy = proxy;
this.tracker = tracker;
if (proxies != null) {
this.proxies = new String[proxies.size()];
for (int i = 0; i < this.proxies.length; ++i) this.proxies[i] = proxies.get(i).toLowerCase();
Arrays.sort(this.proxies);
}
}
@SuppressWarnings("unchecked")
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
@ -50,18 +56,18 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
ObjectMap<String> proxies = new ObjectMap<String>();
for (Proxy proxy : plugin.api.getProxies().values()) {
if (this.proxy == null || this.proxy.equalsIgnoreCase(proxy.getName())) {
if (this.proxies == null || Arrays.binarySearch(this.proxies, proxy.getName().toLowerCase()) >= 0) {
proxies.set(proxy.getName(), proxy.forSubData());
}
}
data.set(0x0001, proxies);
if ((this.proxy == null || this.proxy.length() <= 0) && plugin.api.getMasterProxy() != null) data.set(0x0002, plugin.api.getMasterProxy().forSubData());
if (this.proxies != null && plugin.api.getMasterProxy() != null && (this.proxies.length <= 0 || Arrays.binarySearch(this.proxies, plugin.api.getMasterProxy().getName().toLowerCase()) >= 0)) data.set(0x0002, plugin.api.getMasterProxy().forSubData());
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
client.sendPacket(new PacketDownloadProxyInfo(plugin, (data.contains(0x0001))?data.getRawString(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
client.sendPacket(new PacketDownloadProxyInfo(plugin, (data.contains(0x0001))?data.getRawStringList(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -8,6 +8,8 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
/**
@ -15,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubProxy plugin;
private String server;
private String[] servers;
private UUID tracker;
/**
@ -32,17 +34,21 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
* New PacketDownloadServerInfo (Out)
*
* @param plugin SubPlugin
* @param server Server (or null for all)
* @param servers Servers (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadServerInfo(SubProxy plugin, String server, UUID tracker) {
public PacketDownloadServerInfo(SubProxy plugin, List<String> servers, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.server = server;
this.tracker = tracker;
if (servers != null) {
this.servers = new String[servers.size()];
for (int i = 0; i < this.servers.length; ++i) this.servers[i] = servers.get(i).toLowerCase();
Arrays.sort(this.servers);
}
}
@SuppressWarnings("unchecked")
@Override
public ObjectMap<Integer> send(SubDataClient client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
@ -50,7 +56,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
ObjectMap<String> servers = new ObjectMap<String>();
for (Server server : plugin.api.getServers().values()) {
if (this.server == null || this.server.length() <= 0 || this.server.equalsIgnoreCase(server.getName())) {
if (this.servers == null || this.servers.length <= 0 || Arrays.binarySearch(this.servers, server.getName().toLowerCase()) >= 0) {
servers.set(server.getName(), server.forSubData());
}
}
@ -60,7 +66,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
client.sendPacket(new PacketDownloadServerInfo(plugin, (data.contains(0x0001))?data.getRawString(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
client.sendPacket(new PacketDownloadServerInfo(plugin, (data.contains(0x0001))?data.getRawStringList(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -11,8 +11,10 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import static net.ME1312.SubServers.Bungee.Network.Packet.PacketLinkServer.req;
import static net.ME1312.SubServers.Bungee.Network.Packet.PacketLinkServer.last;
/**
* Link External Host Packet
@ -64,7 +66,7 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
if (!subdata.keySet().contains(channel) || (channel == 0 && subdata.get(0) == null)) {
((ExternalHost) host).setSubData(client, channel);
Logger.get("SubData").info(client.getAddress().toString() + " has been defined as Host: " + host.getName() + ((channel > 0)?" (Sub-"+channel+")":""));
client.sendPacket(new PacketLinkExHost(0, null));
queue(host.getName(), () -> client.sendPacket(new PacketLinkExHost(0, null)));
setReady(client, true);
} else {
client.sendPacket(new PacketLinkExHost(3, "Host already linked"));
@ -81,6 +83,20 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
}
}
private void queue(String name, Runnable action) {
final long now = Calendar.getInstance().getTime().getTime();
new Timer("SubServers.Bungee::ExHost_Linker(" + name + ")").schedule(new TimerTask() {
@Override
public void run() {
action.run();
--req;
}
}, (now - last < 500) ? (req * 500) : 0);
++req;
last = now;
}
@Override
public int version() {
return 0x0001;

View File

@ -8,11 +8,15 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
import static net.ME1312.SubServers.Bungee.Network.Packet.PacketLinkServer.req;
import static net.ME1312.SubServers.Bungee.Network.Packet.PacketLinkServer.last;
/**
* Link Proxy Packet
@ -75,7 +79,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
proxy.setSubData(client, channel);
if (isnew) plugin.getPluginManager().callEvent(new SubAddProxyEvent(proxy));
Logger.get("SubData").info(client.getAddress().toString() + " has been defined as Proxy: " + proxy.getName() + ((channel > 0)?" (Sub-"+channel+")":""));
client.sendPacket(new PacketLinkProxy(proxy.getName(), 0, null));
queue(proxy.getName(), () -> client.sendPacket(new PacketLinkProxy(proxy.getName(), 0, null)));
setReady(client, true);
} else {
client.sendPacket(new PacketLinkProxy(proxy.getName(), 2, "Proxy already linked"));
@ -87,6 +91,20 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
}
}
private void queue(String name, Runnable action) {
final long now = Calendar.getInstance().getTime().getTime();
new Timer("SubServers.Bungee::Proxy_Linker(" + name + ")").schedule(new TimerTask() {
@Override
public void run() {
action.run();
--req;
}
}, (now - last < 500) ? (req * 500) : 0);
++req;
last = now;
}
@Override
public int version() {
return 0x0001;

View File

@ -5,22 +5,19 @@ import net.ME1312.SubData.Server.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Event.SubStartedEvent;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Host.ServerContainer;
import net.ME1312.SubServers.Bungee.Host.ServerImpl;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.Host.SubServerContainer;
import net.ME1312.SubServers.Bungee.Host.SubServerImpl;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.ProxyServer;
import java.net.InetSocketAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -103,8 +100,10 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
}
}
static int req = 1;
static long last = Calendar.getInstance().getTime().getTime();
private void link(SubDataClient client, Server server, int channel) throws Throwable {
HashMap<Integer, SubDataClient> subdata = Util.getDespiteException(() -> Util.reflect(ServerContainer.class.getDeclaredField("subdata"), server), null);
HashMap<Integer, SubDataClient> subdata = Util.getDespiteException(() -> Util.reflect(ServerImpl.class.getDeclaredField("subdata"), server), null);
if (!subdata.keySet().contains(channel) || (channel == 0 && subdata.get(0) == null)) {
server.setSubData(client, channel);
Logger.get("SubData").info(client.getAddress().toString() + " has been defined as " + ((server instanceof SubServer) ? "SubServer" : "Server") + ": " + server.getName() + ((channel > 0)?" (Sub-"+channel+")":""));
@ -118,25 +117,26 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
Util.isException(() -> Util.reflect(SubDataClient.class.getDeclaredMethod("close", DisconnectReason.class), client, DisconnectReason.CLOSE_REQUESTED));
}
} else {
if (server instanceof SubServer && !Util.getDespiteException(() -> Util.reflect(SubServerContainer.class.getDeclaredField("started"), server), true)) {
Util.isException(() -> Util.reflect(SubServerContainer.class.getDeclaredField("started"), server, true));
if (server instanceof SubServer && !Util.getDespiteException(() -> Util.reflect(SubServerImpl.class.getDeclaredField("started"), server), true)) {
Util.isException(() -> Util.reflect(SubServerImpl.class.getDeclaredField("started"), server, true));
SubStartedEvent event = new SubStartedEvent((SubServer) server);
ProxyServer.getInstance().getPluginManager().callEvent(event);
}
client.sendPacket(new PacketLinkServer(server.getName(), 0, null));
}
--req;
};
if (server instanceof SubServer && !((SubServer) server).isRunning()) {
new Timer("SubServers.Bungee::Rogue_SubServer_Detection(" + server.getName() + ")").schedule(new TimerTask() {
@Override
public void run() {
register.run();
}
}, TimeUnit.SECONDS.toMillis(5));
} else {
register.run();
}
final long now = Calendar.getInstance().getTime().getTime();
new Timer("SubServers.Bungee::Server_Linker(" + server.getName() + ")").schedule(new TimerTask() {
@Override
public void run() {
register.run();
}
}, ((server instanceof SubServer && !((SubServer) server).isRunning()) ? TimeUnit.SECONDS.toMillis(5) : 0) + ((now - last < 500) ? (req * 500) : 0));
++req;
last = now;
setReady(client, true);
} else {
client.sendPacket(new PacketLinkServer(null, 4, "Server already linked"));

View File

@ -29,7 +29,7 @@ public class SubProtocol extends SubDataProtocol {
plugin.getPluginManager().registerListener(null, new PacketOutExRunEvent(plugin));
instance.setName("SubServers 2");
instance.setVersion(new Version("2.14a+"));
instance.setVersion(new Version("2.16a+"));
// 00-0F: Object Link Packets
@ -49,7 +49,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0013, PacketDownloadHostInfo.class);
instance.registerPacket(0x0014, PacketDownloadGroupInfo.class);
instance.registerPacket(0x0015, PacketDownloadServerInfo.class);
instance.registerPacket(0x0016, PacketDownloadPlayerList.class);
instance.registerPacket(0x0016, PacketDownloadPlayerInfo.class);
instance.registerPacket(0x0017, PacketCheckPermission.class);
instance.registerPacket(0x0018, PacketCheckPermissionResponse.class);
@ -59,7 +59,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0013, new PacketDownloadHostInfo(plugin));
instance.registerPacket(0x0014, new PacketDownloadGroupInfo(plugin));
instance.registerPacket(0x0015, new PacketDownloadServerInfo(plugin));
instance.registerPacket(0x0016, new PacketDownloadPlayerList(plugin));
instance.registerPacket(0x0016, new PacketDownloadPlayerInfo(plugin));
instance.registerPacket(0x0017, new PacketCheckPermission());
instance.registerPacket(0x0018, new PacketCheckPermissionResponse());
@ -75,6 +75,9 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0037, PacketStopServer.class);
instance.registerPacket(0x0038, PacketRemoveServer.class);
instance.registerPacket(0x0039, PacketDeleteServer.class);
//instance.registerPacket(0x003A, PacketRestoreServer.class); // TODO
//instance.registerPacket(0x003B, PacketTeleportPlayer.class);
//instance.registerPacket(0x003C, PacketTeleportPlayerResponse.class);
instance.registerPacket(0x0030, new PacketCreateServer(plugin));
instance.registerPacket(0x0031, new PacketAddServer(plugin));
@ -86,6 +89,9 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0037, new PacketStopServer(plugin));
instance.registerPacket(0x0038, new PacketRemoveServer(plugin));
instance.registerPacket(0x0039, new PacketDeleteServer(plugin));
//instance.registerPacket(0x003A, new PacketRestoreServer(plugin)); // TODO
//instance.registerPacket(0x003B, new PacketTeleportPlayer(plugin));
//instance.registerPacket(0x003C, new PacketTeleportPlayerResponse(plugin));
// 50-6F: External Host Packets
@ -96,8 +102,9 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0054, PacketExAddServer.class);
instance.registerPacket(0x0055, PacketExEditServer.class);
//instance.registerPacket(0x0056, PacketInExLogMessage.class);
instance.registerPacket(0x0057, PacketExDeleteServer.class);
instance.registerPacket(0x0058, PacketExRemoveServer.class);
instance.registerPacket(0x0057, PacketExRemoveServer.class);
instance.registerPacket(0x0058, PacketExDeleteServer.class);
//instance.registerPacket(0x0059, PacketExRestoreServer.class);
instance.registerPacket(0x0050, new PacketExConfigureHost(plugin));
instance.registerPacket(0x0051, new PacketExDownloadTemplates(plugin));
@ -106,8 +113,9 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0054, new PacketExAddServer());
instance.registerPacket(0x0055, new PacketExEditServer(plugin));
instance.registerPacket(0x0056, new PacketInExLogMessage());
instance.registerPacket(0x0057, new PacketExDeleteServer());
instance.registerPacket(0x0058, new PacketExRemoveServer());
instance.registerPacket(0x0057, new PacketExRemoveServer());
instance.registerPacket(0x0058, new PacketExDeleteServer());
//instance.registerPacket(0x0059, new PacketExRestoreServer());
// 70-7F: External Misc Packets

View File

@ -1,6 +1,7 @@
package net.ME1312.SubServers.Bungee;
import com.google.common.collect.Range;
import net.ME1312.SubData.Server.DataProtocol;
import net.ME1312.SubData.Server.DataServer;
import net.ME1312.SubServers.Bungee.Event.SubAddHostEvent;
import net.ME1312.SubServers.Bungee.Event.SubAddServerEvent;
@ -8,7 +9,7 @@ import net.ME1312.SubServers.Bungee.Event.SubRemoveHostEvent;
import net.ME1312.SubServers.Bungee.Event.SubRemoveServerEvent;
import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidHostException;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
@ -33,7 +34,7 @@ public final class SubAPI {
private final SubProxy plugin;
private static SubAPI api;
protected SubAPI(SubProxy plugin) {
SubAPI(SubProxy plugin) {
this.plugin = plugin;
GAME_VERSION = getGameVersion();
api = this;
@ -83,14 +84,23 @@ public final class SubAPI {
}
/**
* Gets the SubData Network Manager
* Gets the SubData Network
*
* @return SubData Network Manager
* @return SubData Network
*/
public DataServer getSubDataNetwork() {
return plugin.subdata;
}
/**
* Gets the SubData Network Protocol
*
* @return SubData Network Protocol
*/
public DataProtocol getSubDataProtocol() {
return plugin.subprotocol;
}
/**
* Adds a Driver for Hosts
*
@ -354,9 +364,12 @@ public final class SubAPI {
* @param name Group name
* @return a Server Group
*/
public List<Server> getGroup(String name) {
public NamedContainer<String, List<Server>> getGroup(String name) {
if (Util.isNull(name)) throw new NullPointerException();
return Util.getCaseInsensitively(getGroups(), name);
for (Map.Entry<String, List<Server>> group : getLowercaseGroups().entrySet()) {
if (group.getKey().equalsIgnoreCase(name)) return new NamedContainer<>(group.getKey(), group.getValue());
}
return null;
}
/**
@ -413,7 +426,7 @@ public final class SubAPI {
*/
public Server addServer(UUID player, String name, InetAddress ip, int port, String motd, boolean hidden, boolean restricted) {
if (getServers().keySet().contains(name.toLowerCase())) throw new InvalidServerException("A Server already exists with this name!");
Server server = new ServerContainer(name, new InetSocketAddress(ip, port), motd, hidden, restricted);
Server server = ServerImpl.construct(name, new InetSocketAddress(ip, port), motd, hidden, restricted);
SubAddServerEvent event = new SubAddServerEvent(player, null, server);
plugin.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
@ -517,7 +530,9 @@ public final class SubAPI {
*/
public Proxy getProxy(String name) {
if (Util.isNull(name)) throw new NullPointerException();
return getProxies().get(name.toLowerCase());
Proxy proxy = getProxies().getOrDefault(name.toLowerCase(), null);
if (proxy == null && plugin.redis != null && plugin.redis.getName().equalsIgnoreCase(name)) proxy = plugin.redis;
return proxy;
}
/**
@ -532,21 +547,62 @@ public final class SubAPI {
/**
* Get players on this network across all known proxies
*
* @return Player Collection
* @return Remote Player Collection
*/
@SuppressWarnings("unchecked")
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
public Map<UUID, RemotePlayer> getGlobalPlayers() {
TreeMap<UUID, RemotePlayer> players = new TreeMap<UUID, RemotePlayer>();
SubProxy plugin = SubAPI.getInstance().getInternals();
for (ProxiedPlayer player : plugin.getPlayers()) {
players.put(player.getUniqueId(), new RemotePlayer(player));
}
if (plugin.redis != null) {
try {
for (UUID player : (Set<UUID>) plugin.redis("getPlayersOnline")) players.add(new NamedContainer<>((String) plugin.redis("getNameFromUuid", new NamedContainer<>(UUID.class, player)), player));
for (UUID id : (Set<UUID>) plugin.redis("getPlayersOnline")) {
if (!players.keySet().contains(id)) {
players.put(id, new RemotePlayer(id));
}
}
} catch (Exception e) {}
} else {
for (ProxiedPlayer player : plugin.getPlayers()) players.add(new NamedContainer<>(player.getName(), player.getUniqueId()));
}
return players;
}
/**
* Get a player on this network by searching across all known proxies
*
* @param name Player name
* @return Remote Player
*/
@SuppressWarnings("unchecked")
public RemotePlayer getGlobalPlayer(String name) {
if (Util.isNull(name)) throw new NullPointerException();
SubProxy plugin = SubAPI.getInstance().getInternals();
RemotePlayer remote;
ProxiedPlayer local = plugin.getPlayer(name);
if (local != null) remote = new RemotePlayer(local);
else remote = Util.getDespiteException(() -> new RemotePlayer((UUID) plugin.redis("getUuidFromName", new NamedContainer<>(String.class, name), new NamedContainer<>(boolean.class, false))), null);
return remote;
}
/**
* Get a player on this network by searching across all known proxies
*
* @param id Player UUID
* @return Remote Player
*/
public RemotePlayer getGlobalPlayer(UUID id) {
if (Util.isNull(id)) throw new NullPointerException();
SubProxy plugin = SubAPI.getInstance().getInternals();
RemotePlayer remote;
ProxiedPlayer local = plugin.getPlayer(id);
if (local != null) remote = new RemotePlayer(local);
else remote = Util.getDespiteException(() -> new RemotePlayer(id), null);
return remote;
}
/**
* Adds to the SubServers Lang
*

View File

@ -4,21 +4,24 @@ import com.dosse.upnp.UPnP;
import com.google.common.collect.Range;
import com.google.gson.Gson;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.*;
import net.ME1312.SubData.Server.Encryption.AES;
import net.ME1312.SubData.Server.Encryption.DHE;
import net.ME1312.SubData.Server.Encryption.RSA;
import net.ME1312.SubData.Server.Library.DataSize;
import net.ME1312.SubServers.Bungee.Event.*;
import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.SubServers.Bungee.Library.*;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiCommand;
import net.ME1312.SubServers.Bungee.Library.Compatibility.LegacyServerMap;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Library.Fallback.SmartReconnectHandler;
import net.ME1312.SubServers.Bungee.Library.Updates.ConfigUpdater;
import net.ME1312.SubServers.Bungee.Library.ConfigUpdater;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidHostException;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.Version.Version;
@ -54,8 +57,8 @@ import java.util.concurrent.TimeUnit;
* Main Plugin Class
*/
public final class SubProxy extends BungeeCord implements Listener {
protected final LinkedHashMap<String, LinkedHashMap<String, String>> exLang = new LinkedHashMap<String, LinkedHashMap<String, String>>();
protected final HashMap<String, Class<? extends Host>> hostDrivers = new HashMap<String, Class<? extends Host>>();
final LinkedHashMap<String, LinkedHashMap<String, String>> exLang = new LinkedHashMap<String, LinkedHashMap<String, String>>();
final HashMap<String, Class<? extends Host>> hostDrivers = new HashMap<String, Class<? extends Host>>();
public final HashMap<String, Proxy> proxies = new HashMap<String, Proxy>();
public final HashMap<String, Host> hosts = new HashMap<String, Host>();
public final HashMap<String, Server> exServers = new HashMap<String, Server>();
@ -72,7 +75,7 @@ public final class SubProxy extends BungeeCord implements Listener {
public SubProtocol subprotocol;
public SubDataServer subdata = null;
public SubServer sudo = null;
public static final Version version = Version.fromString("2.15.2a");
public static final Version version = Version.fromString("2.16a");
public Proxy redis = null;
public boolean canSudo = false;
@ -84,7 +87,7 @@ public final class SubProxy extends BungeeCord implements Listener {
private static BigInteger lastSignature = BigInteger.valueOf(-1);
@SuppressWarnings("unchecked")
protected SubProxy(PrintStream out, boolean isPatched) throws Exception {
SubProxy(PrintStream out, boolean isPatched) throws Exception {
this.isPatched = isPatched;
this.isGalaxi = !Util.isException(() ->
Util.reflect(Class.forName("net.ME1312.Galaxi.Engine.PluginManager").getMethod("findClasses", Class.class),
@ -215,7 +218,7 @@ public final class SubProxy extends BungeeCord implements Listener {
}
}, TimeUnit.DAYS.toMillis(7), TimeUnit.DAYS.toMillis(7));
api.addHostDriver(net.ME1312.SubServers.Bungee.Host.Internal.InternalHost.class, "built-in");
api.addHostDriver(net.ME1312.SubServers.Bungee.Host.Internal.InternalHost.class, "virtual");
api.addHostDriver(net.ME1312.SubServers.Bungee.Host.External.ExternalHost.class, "network");
getPluginManager().registerListener(null, this);
@ -224,7 +227,7 @@ public final class SubProxy extends BungeeCord implements Listener {
for (String name : servers.get().getMap("Servers").getKeys()) {
try {
if (Util.getCaseInsensitively(config.get().getMap("Hosts").get(), servers.get().getMap("Servers").getMap(name).getString("Host")) == null) throw new InvalidServerException("There is no host with this name: " + servers.get().getMap("Servers").getMap(name).getString("Host"));
legServers.put(name, new BungeeServerInfo(name, new InetSocketAddress(InetAddress.getByName((String) ((Map<String, ?>) Util.getCaseInsensitively(config.get().getMap("Hosts").get(), servers.get().getMap("Servers").getMap(name).getString("Host"))).get("Address")), servers.get().getMap("Servers").getMap(name).getInt("Port")),
legServers.put(name, constructServerInfo(name, new InetSocketAddress(InetAddress.getByName((String) ((Map<String, ?>) Util.getCaseInsensitively(config.get().getMap("Hosts").get(), servers.get().getMap("Servers").getMap(name).getString("Host"))).get("Address")), servers.get().getMap("Servers").getMap(name).getInt("Port")),
ChatColor.translateAlternateColorCodes('&', servers.get().getMap("Servers").getMap(name).getString("Motd")), servers.get().getMap("Servers").getMap(name).getBoolean("Restricted")));
} catch (Exception e) {
e.printStackTrace();
@ -232,6 +235,10 @@ public final class SubProxy extends BungeeCord implements Listener {
}
subprotocol = SubProtocol.get();
subprotocol.registerCipher("DHE", DHE.get(128));
subprotocol.registerCipher("DHE-128", DHE.get(128));
subprotocol.registerCipher("DHE-192", DHE.get(192));
subprotocol.registerCipher("DHE-256", DHE.get(256));
Logger.get("SubServers").info("Loading BungeeCord Libraries...");
if (isGalaxi) Util.reflect(net.ME1312.SubServers.Bungee.Library.Compatibility.Galaxi.GalaxiEventListener.class.getConstructor(SubProxy.class), this);
}
@ -349,6 +356,7 @@ public final class SubProxy extends BungeeCord implements Listener {
host.getCreator().setPortRange(Range.closed(Integer.parseInt(config.get().getMap("Hosts").getMap(name).getRawString("Port-Range", "25500-25559").split("-")[0]), Integer.parseInt(config.get().getMap("Hosts").getMap(name).getRawString("Port-Range", "25500-25559").split("-")[1])));
if (config.get().getMap("Hosts").getMap(name).getBoolean("Log-Creator", true) != host.getCreator().isLogging())
host.getCreator().setLogging(config.get().getMap("Hosts").getMap(name).getBoolean("Log-Creator", true));
host.getCreator().reload();
} // Check for other changes
if (config.get().getMap("Hosts").getMap(name).getKeys().contains("Display") && ((config.get().getMap("Hosts").getMap(name).getString("Display").length() == 0 && !host.getName().equals(host.getDisplayName())) || (config.get().getMap("Hosts").getMap(name).getString("Display").length() > 0 && !config.get().getMap("Hosts").getMap(name).getString("Display").equals(host.getDisplayName()))))
host.setDisplayName(config.get().getMap("Hosts").getMap(name).getString("Display"));
@ -527,8 +535,13 @@ public final class SubProxy extends BungeeCord implements Listener {
subprotocol.unregisterCipher("AES-192");
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
subprotocol.setTimeout(TimeUnit.SECONDS.toMillis(config.get().getMap("Settings").getMap("SubData").getInt("Timeout", 30)));
String cipher = config.get().getMap("Settings").getMap("SubData").getRawString("Encryption", "NULL");
String[] ciphers = (cipher.contains("/"))?cipher.split("/"):new String[]{cipher};
if (ciphers[0].equals("AES") || ciphers[0].equals("AES-128") || ciphers[0].equals("AES-192") || ciphers[0].equals("AES-256")) {
if (config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() == 0) {
byte[] bytes = new byte[32];
@ -545,7 +558,11 @@ public final class SubProxy extends BungeeCord implements Listener {
subprotocol.registerCipher("AES-256", new AES(256, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
Logger.get("SubData").info("Encrypting SubData with AES:");
Logger.get("SubData").info("Use the password in config.yml to allow clients to connect");
Logger.get("SubData").info("Use the password field in config.yml to allow clients to connect");
} else if (ciphers[0].equals("DHE") || ciphers[0].equals("DHE-128") || ciphers[0].equals("DHE-192") || ciphers[0].equals("DHE-256")) {
Logger.get("SubData").info("Encrypting SubData with DHE/AES:");
Logger.get("SubData").info("SubData will negotiate what password to use automatically using the Diffie-Hellman Exchange");
} else if (ciphers[0].equals("RSA") || ciphers[0].equals("RSA-2048") || ciphers[0].equals("RSA-3072") || ciphers[0].equals("RSA-4096")) {
try {
int length = (ciphers[0].contains("-"))?Integer.parseInt(ciphers[0].split("-")[1]):2048;
@ -750,7 +767,7 @@ public final class SubProxy extends BungeeCord implements Listener {
for (int i = 0; i < args.length; i++) {
classargs[i] = args[i].name();
objargs[i] = args[i].get();
if (!classargs[i].isInstance(objargs[i])) throw new ClassCastException(classargs[i].getCanonicalName() + " != " + objargs[i].getClass().getCanonicalName());
if (!classargs[i].isPrimitive() && !classargs[i].isInstance(objargs[i])) throw new ClassCastException(classargs[i].getCanonicalName() + " != " + objargs[i].getClass().getCanonicalName());
}
return api.getClass().getMethod(method, classargs).invoke(api, objargs);
} else {
@ -784,6 +801,15 @@ public final class SubProxy extends BungeeCord implements Listener {
*/
@Override
public Map<String, ServerInfo> getServers() {
return new LegacyServerMap(getServersCopy());
}
/**
* Emulate Waterfall's getServersCopy()
*
* @return Server Map Copy
*/
public Map<String, ServerInfo> getServersCopy() {
HashMap<String, ServerInfo> servers = new HashMap<String, ServerInfo>();
if (!api.ready) {
servers.putAll(super.getServers());
@ -797,15 +823,6 @@ public final class SubProxy extends BungeeCord implements Listener {
return servers;
}
/**
* Emulate Waterfall's getServersCopy()
*
* @return Server Map Copy (which is the default, by the way)
*/
public Map<String, ServerInfo> getServersCopy() {
return getServers();
}
/**
* Force BungeeCord's implementation of getServerInfo()
*
@ -813,7 +830,7 @@ public final class SubProxy extends BungeeCord implements Listener {
*/
@Override
public ServerInfo getServerInfo(String name) {
return getServers().get(name);
return getServersCopy().get(name);
}
@EventHandler(priority = Byte.MAX_VALUE)

View File

@ -48,14 +48,14 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>20w08c</version>
<version>20w15a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w07d</version>
<version>20w15a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -150,7 +150,7 @@
<configuration>
<windowtitle>SubServers.Client.Bukkit Javadoc</windowtitle>
<doctitle>SubServers.Client.Bukkit Javadoc</doctitle>
<show>public</show>
<show>protected</show>
<destDir>./</destDir>
<outputDirectory>${basedir}/../../Javadoc/SubServers.Client.Bukkit</outputDirectory>
<reportOutputDirectory>${basedir}/../../Javadoc/SubServers.Client.Bukkit</reportOutputDirectory>

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Client.Bukkit.Event;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubServers.Client.Bukkit.Library.SubEvent;
import net.ME1312.Galaxi.Library.Util;
import org.bukkit.event.Event;

View File

@ -1,7 +1,7 @@
package net.ME1312.SubServers.Client.Bukkit.Graphic;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
@ -104,13 +104,14 @@ public class DefaultUIHandler implements UIHandler, Listener {
gui.back();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Undo"))) {
player.closeInventory();
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).undo();
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).undo();
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Host-Creator.Submit"))) {
if (player.hasPermission("subservers.host.create.*") || player.hasPermission("subservers.host.create." + ((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).getHost().toLowerCase())) {
String host = ((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).getHost().toLowerCase();
if (player.hasPermission("subservers.host.*.*") || player.hasPermission("subservers.host.*.create") || player.hasPermission("subservers.host." + host + ".*") || player.hasPermission("subservers.host." + host + ".create")) {
player.closeInventory();
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketCreateServer(player.getUniqueId(), ((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketCreateServer(player.getUniqueId(), ((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]), data -> {
gui.back();
}));
} else {
@ -124,7 +125,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
if (m.getString("message").contains(" ")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Invalid-Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Invalid"));
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4 * 20);
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]), 4 * 20);
} else {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
plugin.api.getSubServer(m.getString("message"), server -> {
@ -132,26 +133,26 @@ public class DefaultUIHandler implements UIHandler, Listener {
gui.setDownloading(null);
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Exists-Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Exists"));
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4 * 20);
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]), 4 * 20);
} else {
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setName(m.getString("message"));
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).setName(m.getString("message"));
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
}
});
}
});
} else if (ChatColor.stripColor(item).equals(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template")))) {
player.closeInventory();
gui.hostCreatorTemplates(1, (UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
gui.hostCreatorTemplates(1, (UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
} else if (ChatColor.stripColor(item).equals(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Version")))) {
player.closeInventory();
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Version.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Version.Message"));
input.put(player.getUniqueId(), m -> {
if (m.getString("message").length() <= 0) {
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setVersion(null);
} else ((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setVersion(new Version(m.getString("message")));
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).setVersion(null);
} else ((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).setVersion(new Version(m.getString("message")));
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
});
} else if (ChatColor.stripColor(item).equals(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port")))) {
player.closeInventory();
@ -159,15 +160,15 @@ public class DefaultUIHandler implements UIHandler, Listener {
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port.Message"));
input.put(player.getUniqueId(), m -> {
if (m.getString("message").length() <= 0) {
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setPort(null);
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).setPort(null);
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
} else if (Util.isException(() -> Integer.parseInt(m.getString("message"))) || Integer.parseInt(m.getString("message")) <= 0 || Integer.parseInt(m.getString("message")) > 65535) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port.Invalid-Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port.Invalid"));
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4 * 20);
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]), 4 * 20);
} else {
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setPort(Integer.valueOf(m.getString("message")));
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).setPort(Integer.valueOf(m.getString("message")));
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
}
});
}
@ -179,13 +180,13 @@ public class DefaultUIHandler implements UIHandler, Listener {
String item = event.getCurrentItem().getItemMeta().getDisplayName();
if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"))) {
player.closeInventory();
gui.hostCreatorTemplates(gui.lastPage - 1, (UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
gui.hostCreatorTemplates(gui.lastPage - 1, (UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"))) {
player.closeInventory();
gui.hostCreatorTemplates(gui.lastPage + 1, (UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
gui.hostCreatorTemplates(gui.lastPage + 1, (UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
player.closeInventory();
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
} else {
player.closeInventory();
String obj;
@ -194,8 +195,8 @@ public class DefaultUIHandler implements UIHandler, Listener {
} else {
obj = ChatColor.stripColor(item);
}
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setTemplate(obj);
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]).setTemplate(obj);
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjectz[0]);
}
}
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.Host-Plugin.Title").split("\\$str\\$")[0]) && // Host Plugin
@ -205,10 +206,10 @@ public class DefaultUIHandler implements UIHandler, Listener {
String item = event.getCurrentItem().getItemMeta().getDisplayName();
if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"))) {
player.closeInventory();
gui.hostPlugin(gui.lastPage - 1, ((String) gui.lastVisitedObjects[0]));
gui.hostPlugin(gui.lastPage - 1, ((Host) gui.lastVisitedObjectz[0]).getName());
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"))) {
player.closeInventory();
gui.hostPlugin(gui.lastPage + 1, ((String) gui.lastVisitedObjects[0]));
gui.hostPlugin(gui.lastPage + 1, ((Host) gui.lastVisitedObjectz[0]).getName());
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
player.closeInventory();
gui.back();
@ -221,8 +222,8 @@ public class DefaultUIHandler implements UIHandler, Listener {
if (plugin.get() == null) {
gui.reopen();
} else {
gui.setDownloading(ChatColor.stripColor(this.plugin.api.getLang("SubServers", "Interface.Host-Plugin.Title").replace("$str$", (String) gui.lastVisitedObjects[0])));
this.plugin.api.getHost((String) gui.lastVisitedObjects[0], host -> {
gui.setDownloading(ChatColor.stripColor(this.plugin.api.getLang("SubServers", "Interface.Host-Plugin.Title").replace("$str$", ((Host) gui.lastVisitedObjectz[0]).getName())));
this.plugin.api.getHost(((Host) gui.lastVisitedObjectz[0]).getName(), host -> {
if (host != null) {
gui.setDownloading(null);
plugin.get().open(player, host);
@ -264,10 +265,10 @@ public class DefaultUIHandler implements UIHandler, Listener {
if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"))) {
player.closeInventory();
gui.serverMenu(gui.lastPage - 1, (String) gui.lastVisitedObjects[0], (String) gui.lastVisitedObjects[1]);
gui.serverMenu(gui.lastPage - 1, (String) gui.lastVisitedObjectz[0], (String) gui.lastVisitedObjectz[1]);
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"))) {
player.closeInventory();
gui.serverMenu(gui.lastPage + 1, (String) gui.lastVisitedObjects[0], (String) gui.lastVisitedObjects[1]);
gui.serverMenu(gui.lastPage + 1, (String) gui.lastVisitedObjectz[0], (String) gui.lastVisitedObjectz[1]);
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Menu.Host-Menu"))) {
player.closeInventory();
gui.hostMenu(1);
@ -296,15 +297,15 @@ public class DefaultUIHandler implements UIHandler, Listener {
gui.back();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Host-Admin.Creator"))) {
player.closeInventory();
if (player.hasPermission("subservers.host.create.*") || player.hasPermission("subservers.host.create." + ((String) gui.lastVisitedObjects[0]).toLowerCase())) {
gui.hostCreator(new UIRenderer.CreatorOptions((String) gui.lastVisitedObjects[0]));
if (player.hasPermission("subservers.host.create.*") || player.hasPermission("subservers.host.create." + ((Host) gui.lastVisitedObjectz[0]).getName().toLowerCase())) {
gui.hostCreator(new UIRenderer.CreatorOptions(((Host) gui.lastVisitedObjectz[0]).getName()));
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Host-Admin.SubServers"))) {
player.closeInventory();
gui.serverMenu(1, (String) gui.lastVisitedObjects[0], null);
gui.serverMenu(1, ((Host) gui.lastVisitedObjectz[0]).getName(), null);
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Host-Admin.Plugins"))) {
player.closeInventory();
gui.hostPlugin(1, (String) gui.lastVisitedObjects[0]);
gui.hostPlugin(1, ((Host) gui.lastVisitedObjectz[0]).getName());
}
}
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Title").split("\\$str\\$")[0]) && // SubServer Admin
@ -318,12 +319,12 @@ public class DefaultUIHandler implements UIHandler, Listener {
gui.back();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update"))) {
player.closeInventory();
if (player.hasPermission("subservers.subserver.command.*") || player.hasPermission("subservers.subserver.update." + ((String) gui.lastVisitedObjects[0]).toLowerCase())) {
if (((SubServer) gui.lastVisitedObjectz[0]).permits(player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Update.Message"));
input.put(player.getUniqueId(), m -> {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketUpdateServer(player.getUniqueId(), (String) gui.lastVisitedObjects[0],
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketUpdateServer(player.getUniqueId(), ((SubServer) gui.lastVisitedObjectz[0]).getName(),
(m.getString("message").length() == 0 || m.getString("message").equals("/"))?null:new Version((m.getString("message").startsWith("/"))?m.getString("message").substring(1):m.getString("message")), data -> {
gui.reopen();
}));
@ -331,23 +332,23 @@ public class DefaultUIHandler implements UIHandler, Listener {
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start"))) {
player.closeInventory();
if (player.hasPermission("subservers.subserver.start.*") || player.hasPermission("subservers.subserver.start." + ((String) gui.lastVisitedObjects[0]).toLowerCase())) {
if (((SubServer) gui.lastVisitedObjectz[0]).permits(player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketStartServer(player.getUniqueId(), (String) gui.lastVisitedObjects[0], data -> {
((SubServer) gui.lastVisitedObjectz[0]).start(player.getUniqueId(), response -> {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Start.Title"));
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 30);
}));
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop"))) {
player.closeInventory();
if (player.hasPermission("subservers.subserver.stop.*") || player.hasPermission("subservers.subserver.stop." + ((String) gui.lastVisitedObjects[0]).toLowerCase())) {
if (((SubServer) gui.lastVisitedObjectz[0]).permits(player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
final Container<Boolean> listening = new Container<Boolean>(true);
PacketInExRunEvent.callback("SubStoppedEvent", new Callback<ObjectMap<String>>() {
@Override
public void run(ObjectMap<String> json) {
try {
if (listening.get()) if (!json.getString("server").equalsIgnoreCase((String) gui.lastVisitedObjects[0])) {
if (listening.get()) if (!json.getString("server").equalsIgnoreCase(((SubServer) gui.lastVisitedObjectz[0]).getName())) {
PacketInExRunEvent.callback("SubStoppedEvent", this);
} else {
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 5);
@ -355,23 +356,23 @@ public class DefaultUIHandler implements UIHandler, Listener {
} catch (Exception e) {}
}
});
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketStopServer(player.getUniqueId(), (String) gui.lastVisitedObjects[0], false, data -> {
if (data.getInt(0x0001) != 0) {
((SubServer) gui.lastVisitedObjectz[0]).stop(player.getUniqueId(), response -> {
if (response != 0) {
gui.reopen();
listening.set(false);
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop.Title").replace("$str$", (String) gui.lastVisitedObjects[0]));
}));
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Stop.Title").replace("$str$", ((SubServer) gui.lastVisitedObjectz[0]).getName()));
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate"))) {
player.closeInventory();
if (player.hasPermission("subservers.subserver.terminate.*") || player.hasPermission("subservers.subserver.terminate." + ((String) gui.lastVisitedObjects[0]).toLowerCase())) {
if (((SubServer) gui.lastVisitedObjectz[0]).permits(player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
final Container<Boolean> listening = new Container<Boolean>(true);
PacketInExRunEvent.callback("SubStoppedEvent", new Callback<ObjectMap<String>>() {
@Override
public void run(ObjectMap<String> json) {
try {
if (listening.get()) if (!json.getString("server").equalsIgnoreCase((String) gui.lastVisitedObjects[0])) {
if (listening.get()) if (!json.getString("server").equalsIgnoreCase(((SubServer) gui.lastVisitedObjectz[0]).getName())) {
PacketInExRunEvent.callback("SubStoppedEvent", this);
} else {
gui.reopen();
@ -379,28 +380,28 @@ public class DefaultUIHandler implements UIHandler, Listener {
} catch (Exception e) {}
}
});
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketStopServer(player.getUniqueId(), (String) gui.lastVisitedObjects[0], false, data -> {
if (data.getInt(0x0001) != 0) {
((SubServer) gui.lastVisitedObjectz[0]).terminate(player.getUniqueId(), response -> {
if (response != 0) {
gui.reopen();
listening.set(false);
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate.Title").replace("$str$", (String) gui.lastVisitedObjects[0]));
}));
} else gui.setDownloading(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Terminate.Title").replace("$str$", ((SubServer) gui.lastVisitedObjectz[0]).getName()));
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command"))) {
player.closeInventory();
if (player.hasPermission("subservers.subserver.command.*") || player.hasPermission("subservers.subserver.command." + ((String) gui.lastVisitedObjects[0]).toLowerCase())) {
if (((SubServer) gui.lastVisitedObjectz[0]).permits(player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command.Title"), 4 * 20))
player.sendMessage(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Command.Message"));
input.put(player.getUniqueId(), m -> {
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketCommandServer(player.getUniqueId(), (String) gui.lastVisitedObjects[0], (m.getString("message").startsWith("/"))?m.getString("message").substring(1):m.getString("message"), data -> {
((SubServer) gui.lastVisitedObjectz[0]).command(player.getUniqueId(), (m.getString("message").startsWith("/"))?m.getString("message").substring(1):m.getString("message"), response -> {
gui.reopen();
}));
});
});
} else gui.reopen();
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.SubServer-Admin.Plugins"))) {
player.closeInventory();
gui.subserverPlugin(1, (String) gui.lastVisitedObjects[0]);
gui.subserverPlugin(1, ((SubServer) gui.lastVisitedObjectz[0]).getName());
}
}
} else if (title.startsWith(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").split("\\$str\\$")[0]) && // SubServer Plugin
@ -410,10 +411,10 @@ public class DefaultUIHandler implements UIHandler, Listener {
String item = event.getCurrentItem().getItemMeta().getDisplayName();
if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back-Arrow"))) {
player.closeInventory();
gui.subserverPlugin(gui.lastPage - 1, (String) gui.lastVisitedObjects[0]);
gui.subserverPlugin(gui.lastPage - 1, ((SubServer) gui.lastVisitedObjectz[0]).getName());
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Next-Arrow"))) {
player.closeInventory();
gui.subserverPlugin(gui.lastPage + 1, (String) gui.lastVisitedObjects[0]);
gui.subserverPlugin(gui.lastPage + 1, ((SubServer) gui.lastVisitedObjectz[0]).getName());
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Generic.Back"))) {
player.closeInventory();
gui.back();
@ -426,8 +427,8 @@ public class DefaultUIHandler implements UIHandler, Listener {
if (plugin.get() == null) {
gui.reopen();
} else {
gui.setDownloading(ChatColor.stripColor(this.plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", (String) gui.lastVisitedObjects[0])));
this.plugin.api.getSubServer((String) gui.lastVisitedObjects[0], subserver -> {
gui.setDownloading(ChatColor.stripColor(this.plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", ((SubServer) gui.lastVisitedObjectz[0]).getName())));
this.plugin.api.getSubServer(((SubServer) gui.lastVisitedObjectz[0]).getName(), subserver -> {
if (subserver != null) {
gui.setDownloading(null);
plugin.get().open(player, subserver);

View File

@ -1,7 +1,7 @@
package net.ME1312.SubServers.Client.Bukkit.Graphic;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Client.Bukkit.Network.API.Host;
@ -12,6 +12,7 @@ import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -25,14 +26,14 @@ import java.util.*;
public class DefaultUIRenderer extends UIRenderer {
private static int MAX_VISITED_OBJECTS = 2;
private List<Runnable> windowHistory = new LinkedList<Runnable>();
protected Object[] lastVisitedObjects = new Object[MAX_VISITED_OBJECTS];
protected int lastPage = 1;
protected Runnable lastMenu = null;
protected boolean open = false;
protected final UUID player;
Object[] lastVisitedObjectz = new Object[MAX_VISITED_OBJECTS];
int lastPage = 1;
Runnable lastMenu = null;
boolean open = false;
final UUID player;
private SubPlugin plugin;
protected DefaultUIRenderer(SubPlugin plugin, UUID player) {
DefaultUIRenderer(SubPlugin plugin, UUID player) {
super(plugin, player);
this.plugin = plugin;
this.player = player;
@ -83,7 +84,7 @@ public class DefaultUIRenderer extends UIRenderer {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Menu.Title")));
plugin.api.getHosts(hosts -> plugin.api.getGroups(groups -> {
setDownloading(null);
lastVisitedObjects[0] = null;
lastVisitedObjectz[0] = null;
lastPage = page;
lastMenu = () -> hostMenu(1);
windowHistory.add(() -> hostMenu(page));
@ -219,7 +220,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (hasHistory()) back();
} else {
setDownloading(null);
lastVisitedObjects[0] = name;
lastVisitedObjectz[0] = host;
ItemStack block;
ItemMeta blockMeta;
@ -236,7 +237,8 @@ public class DefaultUIRenderer extends UIRenderer {
i++;
}
if (!(Bukkit.getPlayer(player).hasPermission("subservers.host.create.*") || Bukkit.getPlayer(player).hasPermission("subservers.host.create." + name.toLowerCase()))) {
Player player = Bukkit.getPlayer(this.player);
if (!(player.hasPermission("subservers.host.*.*") || player.hasPermission("subservers.host.*.create") || player.hasPermission("subservers.host." + name.toLowerCase() + ".*") || player.hasPermission("subservers.host." + name.toLowerCase() + ".create"))) {
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.Host-Admin.Creator")));
@ -317,7 +319,7 @@ public class DefaultUIRenderer extends UIRenderer {
inv.setItem(35, block);
}
Bukkit.getPlayer(player).openInventory(inv);
Bukkit.getPlayer(this.player).openInventory(inv);
open = true;
}
});
@ -325,13 +327,12 @@ public class DefaultUIRenderer extends UIRenderer {
public void hostCreator(final CreatorOptions options) {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Title").replace("$str$", options.getHost())));
if (!options.init())
windowHistory.add(() -> hostCreator(options));
lastVisitedObjects[0] = options;
if (!options.init()) windowHistory.add(() -> hostCreator(options));
lastVisitedObjectz[0] = options;
plugin.api.getHost(options.getHost(), host -> {
if (host == null || !host.isAvailable() || !host.isEnabled()) {
lastVisitedObjects[0] = null;
lastVisitedObjectz[0] = null;
if (hasHistory()) back();
} else {
setDownloading(null);
@ -453,11 +454,11 @@ public class DefaultUIRenderer extends UIRenderer {
public void hostCreatorTemplates(final int page, final CreatorOptions options) {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template.Title").replace("$str$", options.getHost())));
lastVisitedObjects[0] = options;
if (!options.init()) lastVisitedObjects[0] = options.getHost();
options.init();
lastVisitedObjectz[0] = options;
plugin.api.getHost(options.getHost(), host -> {
if (host == null || !host.isAvailable() || !host.isEnabled()) {
lastVisitedObjects[0] = null;
lastVisitedObjectz[0] = null;
if (hasHistory()) back();
} else {
lastPage = page;
@ -572,7 +573,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (hasHistory()) back();
} else {
setDownloading(null);
lastVisitedObjects[0] = name;
lastVisitedObjectz[0] = host;
lastPage = page;
List<String> renderers = new LinkedList<String>();
for (String renderer : renderers) {
@ -676,7 +677,7 @@ public class DefaultUIRenderer extends UIRenderer {
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Group-Menu.Title")));
plugin.api.getGroups(groups -> {
setDownloading(null);
lastVisitedObjects[0] = null;
lastVisitedObjectz[0] = null;
lastPage = page;
lastMenu = () -> groupMenu(1);
windowHistory.add(() -> groupMenu(page));
@ -790,8 +791,8 @@ public class DefaultUIRenderer extends UIRenderer {
lastPage = page;
List<Server> servers = servercontainer.get();
lastVisitedObjects[0] = host;
lastVisitedObjects[1] = group;
lastVisitedObjectz[0] = host;
lastVisitedObjectz[1] = group;
windowHistory.add(() -> serverMenu(page, host, group));
ItemStack block;
@ -837,7 +838,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (!server.getName().equals(server.getDisplayName()))
lore.add(ChatColor.GRAY + server.getName());
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External"));
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getPlayers().size())));
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())));
lore.add(plugin.api.getLang("SubServers", "Interface.Server-Menu.SubServer-Invalid"));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
blockMeta.setLore(lore);
@ -852,7 +853,7 @@ public class DefaultUIRenderer extends UIRenderer {
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(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?server.getAddress().getAddress().getHostAddress()+':':"") + server.getAddress().getPort());
blockMeta.setLore(lore);
} else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
@ -961,7 +962,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (servers == null) {
if (hasHistory()) back();
} else {
servercontainer.get().addAll(servers);
servercontainer.get().addAll(servers.get());
renderer.run();
}
});
@ -984,7 +985,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (hasHistory()) back();
} else {
setDownloading(null);
lastVisitedObjects[0] = name;
lastVisitedObjectz[0] = subserver;
ItemStack block;
ItemMeta blockMeta;
ItemStack div = createItem("STAINED_GLASS_PANE", "BLACK_STAINED_GLASS_PANE", (short) 15);
@ -1001,8 +1002,9 @@ public class DefaultUIRenderer extends UIRenderer {
}
i = 0;
Player player = Bukkit.getPlayer(this.player);
if (subserver.isRunning()) {
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.terminate." + name.toLowerCase()))) {
if (!subserver.permits(player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
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")));
@ -1017,7 +1019,7 @@ public class DefaultUIRenderer extends UIRenderer {
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()))) {
if (!subserver.permits(player, "subservers.subserver.%.*", "subservers.subserver.%.stop")) {
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")));
@ -1033,7 +1035,7 @@ public class DefaultUIRenderer extends UIRenderer {
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()))) {
if (!subserver.permits(player, "subservers.subserver.%.*", "subservers.subserver.%.command")) {
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")));
@ -1051,7 +1053,7 @@ public class DefaultUIRenderer extends UIRenderer {
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()))) {
if (!subserver.permits(player, "subservers.subserver.%.*", "subservers.subserver.%.start")) {
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")));
@ -1082,7 +1084,7 @@ public class DefaultUIRenderer extends UIRenderer {
inv.setItem(11, block);
inv.setItem(12, block);
if (!(Bukkit.getPlayer(player).hasPermission("subservers.subserver.update.*") || Bukkit.getPlayer(player).hasPermission("subservers.subserver.update." + name.toLowerCase()))) {
if (!subserver.permits(player, "subservers.subserver.%.*", "subservers.subserver.%.update")) {
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.Update")));
@ -1127,7 +1129,7 @@ public class DefaultUIRenderer extends UIRenderer {
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(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getGlobalPlayers().size())));
lore.add(ChatColor.WHITE + ((plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false))?subserver.getAddress().getAddress().getHostAddress()+':':"") + subserver.getAddress().getPort());
blockMeta.setLore(lore);
} else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
@ -1173,7 +1175,7 @@ public class DefaultUIRenderer extends UIRenderer {
inv.setItem(35, block);
}
Bukkit.getPlayer(player).openInventory(inv);
player.openInventory(inv);
open = true;
}
});
@ -1189,7 +1191,7 @@ public class DefaultUIRenderer extends UIRenderer {
if (hasHistory()) back();
} else {
setDownloading(null);
lastVisitedObjects[0] = name;
lastVisitedObjectz[0] = subserver;
lastPage = page;
List<String> renderers = new LinkedList<String>();
for (String renderer : renderers) {

View File

@ -1,7 +1,7 @@
package net.ME1312.SubServers.Client.Bukkit.Graphic;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Bukkit.Network.API.Host;
@ -20,8 +20,8 @@ import java.util.regex.Pattern;
* GUI Renderer Layout Class
*/
public abstract class UIRenderer {
protected static HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
protected static HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
static HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
static HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
private NamedContainer<String, Integer> tdownload = null;
private int download = -1;
private final UUID player;

View File

@ -65,7 +65,7 @@ public class BungeeChat {
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())) + ChatColor.RESET);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())) + ChatColor.RESET);
} else if (((SubServer) server).isAvailable() && ((SubServer) server).isEnabled() && ((SubServer) server).getCurrentIncompatibilities().size() == 0) {
message.setColor(ChatColor.YELLOW);
hover.setColor(ChatColor.YELLOW);
@ -118,7 +118,7 @@ public class BungeeChat {
hoverm.add(hover);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\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())) + ChatColor.RESET);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())) + ChatColor.RESET);
hoverm.add(hover);
if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress() + ':' + server.getAddress().getPort());
@ -199,7 +199,7 @@ public class BungeeChat {
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())) + ChatColor.RESET);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(subserver.getGlobalPlayers().size())) + ChatColor.RESET);
} else if (subserver.isAvailable() && subserver.isEnabled() && subserver.getCurrentIncompatibilities().size() == 0) {
message.setColor(ChatColor.YELLOW);
hover.setColor(ChatColor.YELLOW);
@ -268,7 +268,7 @@ public class BungeeChat {
}
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-External") + '\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())) + ChatColor.RESET);
hover = new TextComponent(plugin.api.getLang("SubServers", "Interface.Server-Menu.Server-Player-Count").replace("$int$", new DecimalFormat("#,###").format(server.getGlobalPlayers().size())) + ChatColor.RESET);
hoverm.add(hover);
if (plugin.config.get().getMap("Settings").getBoolean("Show-Addresses", false)) {
hover = new TextComponent('\n' + server.getAddress().getAddress().getHostAddress()+':'+server.getAddress().getPort());

View File

@ -1,4 +1,4 @@
package net.ME1312.SubServers.Client.Bukkit.Library.Updates;
package net.ME1312.SubServers.Client.Bukkit.Library;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;

View File

@ -1,6 +1,7 @@
package net.ME1312.SubServers.Client.Bukkit.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Util;
@ -10,6 +11,7 @@ import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.*;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
import org.bukkit.permissions.Permissible;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
@ -19,6 +21,7 @@ import java.util.*;
public class Host {
HashMap<String, SubServer> servers = new HashMap<String, SubServer>();
private SubCreator creator;
private List<RemotePlayer> players = null;
ObjectMap<String> raw;
long timestamp;
@ -38,6 +41,7 @@ public class Host {
private void load(ObjectMap<String> raw) {
this.raw = raw;
this.players = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
servers.clear();
@ -52,7 +56,7 @@ public class Host {
*/
public void refresh() {
String name = getName();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(name, data -> load(data.getMap(name))));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(Collections.singletonList(name), data -> load(data.getMap(name))));
}
/**
@ -74,6 +78,29 @@ public class Host {
}
}
/**
* Determine if an <i>object</i> can perform some action on this host using possible permissions
*
* @param object Object to check against
* @param permissions Permissions to check (use <b>%</b> as a placeholder for the host name)
* @return Permission Check Result
*/
public boolean permits(Permissible object, String... permissions) {
if (Util.isNull(object)) throw new NullPointerException();
boolean permitted = false;
for (int p = 0; !permitted && p < permissions.length; p++) {
String perm = permissions[p];
if (perm != null) {
// Check all proxies & individual proxies permission
permitted = object.hasPermission(perm.replace("%", "*"))
|| object.hasPermission(perm.replace("%", this.getName().toLowerCase()));
}
}
return permitted;
}
/**
* Is this Host Available?
*
@ -132,6 +159,54 @@ public class Host {
return raw.getRawString("display");
}
/**
* Get players on servers provided by this host across all known proxies
*
* @return Remote Player Collection
*/
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) {
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
}
return players;
}
/**
* Get the players on servers provided by this host across all known proxies
*
* @param callback Remote Player Collection
*/
public void getGlobalPlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(players);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>();
for (SubServer server : getSubServers().values()) for (NamedContainer<String, UUID> player : server.getGlobalPlayers()) ids.add(player.get());
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) {
players.add(new RemotePlayer(data.getMap(player)));
}
this.players = players;
run.run();
}));
} else {
run.run();
}
}
/**
* Starts the Servers Specified
*
@ -343,7 +418,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void removeSubServer(String name) throws InterruptedException {
public void removeSubServer(String name) {
removeSubServer(null, name);
}
@ -353,7 +428,7 @@ public class Host {
* @param player Player Removing
* @param name SubServer Name
*/
public void removeSubServer(UUID player, String name) throws InterruptedException {
public void removeSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
removeSubServer(player, name, false, i -> {});
}
@ -363,7 +438,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void forceRemoveSubServer(String name) throws InterruptedException {
public void forceRemoveSubServer(String name) {
forceRemoveSubServer(null, name);
}
@ -384,7 +459,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void removeSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void removeSubServer(String name, Callback<Integer> response) {
removeSubServer(null, name, response);
}
@ -395,7 +470,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void removeSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void removeSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
removeSubServer(player, name, false, response);
}
@ -406,7 +481,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void forceRemoveSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void forceRemoveSubServer(String name, Callback<Integer> response) {
forceRemoveSubServer(null, name, response);
}
@ -441,7 +516,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void recycleSubServer(String name) throws InterruptedException {
public void recycleSubServer(String name) {
recycleSubServer(null, name);
}
@ -451,7 +526,7 @@ public class Host {
* @param player Player Deleting
* @param name SubServer Name
*/
public void recycleSubServer(UUID player, String name) throws InterruptedException {
public void recycleSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, false, i -> {});
}
@ -461,7 +536,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void forceRecycleSubServer(String name) throws InterruptedException {
public void forceRecycleSubServer(String name) {
forceRecycleSubServer(null, name);
}
@ -471,7 +546,7 @@ public class Host {
* @param player Player Deleting
* @param name SubServer Name
*/
public void forceRecycleSubServer(UUID player, String name) throws InterruptedException {
public void forceRecycleSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, true, i -> {});
}
@ -482,7 +557,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void recycleSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void recycleSubServer(String name, Callback<Integer> response) {
recycleSubServer(null, name, response);
}
@ -493,7 +568,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void recycleSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void recycleSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, false, response);
}
@ -504,7 +579,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void forceRecycleSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void forceRecycleSubServer(String name, Callback<Integer> response) {
forceRecycleSubServer(null, name, response);
}
@ -515,7 +590,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void forceRecycleSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void forceRecycleSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, true, response);
}
@ -526,7 +601,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(String name) throws InterruptedException {
public void deleteSubServer(String name) {
deleteSubServer(null, name);
}
@ -537,7 +612,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(UUID player, String name) throws InterruptedException {
public void deleteSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, false, i -> {});
}
@ -548,7 +623,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(String name) throws InterruptedException {
public void forceDeleteSubServer(String name) {
forceDeleteSubServer(null, name);
}
@ -559,7 +634,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(UUID player, String name) throws InterruptedException {
public void forceDeleteSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, true, i -> {});
}
@ -570,7 +645,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void deleteSubServer(String name, Callback<Integer> response) {
deleteSubServer(null, name, response);
}
@ -581,7 +656,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void deleteSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, false, response);
}
@ -592,7 +667,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void forceDeleteSubServer(String name, Callback<Integer> response) {
forceDeleteSubServer(null, name, response);
}
@ -603,7 +678,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void forceDeleteSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, true, response);
}

View File

@ -1,20 +1,25 @@
package net.ME1312.SubServers.Client.Bukkit.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadProxyInfo;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
import org.bukkit.permissions.Permissible;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
public class Proxy {
ObjectMap<String> raw;
private List<RemotePlayer> players = null;
long timestamp;
/**
@ -33,6 +38,7 @@ public class Proxy {
private void load(ObjectMap<String> raw) {
this.raw = raw;
this.players = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
}
@ -41,7 +47,7 @@ public class Proxy {
*/
public void refresh() {
String name = getName();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(name, data -> load(data.getMap(name))));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(Collections.singletonList(name), data -> load(data.getMap(name))));
}
/**
@ -59,6 +65,29 @@ public class Proxy {
return channels.toArray(new SubDataSender[0]);
}
/**
* Determine if an <i>object</i> can perform some action on this proxy using possible permissions
*
* @param object Object to check against
* @param permissions Permissions to check (use <b>%</b> as a placeholder for the proxy name)
* @return Permission Check Result
*/
public boolean permits(Permissible object, String... permissions) {
if (Util.isNull(object)) throw new NullPointerException();
boolean permitted = false;
for (int p = 0; !permitted && p < permissions.length; p++) {
String perm = permissions[p];
if (perm != null) {
// Check all proxies & individual proxies permission
permitted = object.hasPermission(perm.replace("%", "*"))
|| object.hasPermission(perm.replace("%", this.getName().toLowerCase()));
}
}
return permitted;
}
/**
* Get the Name of this Proxy
*
@ -78,7 +107,7 @@ public class Proxy {
}
/**
* Test if the proxy is connected to RedisBungee's server
* Determine if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
@ -86,19 +115,63 @@ public class Proxy {
return raw.getBoolean("redis");
}
/**
* Determine if the proxy is the Master Proxy
*
* @return Master Proxy Status
*/
public boolean isMaster() {
return raw.getBoolean("master");
}
/**
* Get the players on this proxy (via RedisBungee)
*
* @return Player Collection
* @return Remote Player Collection
*/
public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) {
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getMap(id).getRawString("name"), UUID.fromString(id)));
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
}
return players;
}
/**
* Get the players on this proxy (via RedisBungee)
*
* @param callback Remote Player Collection
*/
public void getPlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(players);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>();
for (String id : raw.getMap("players").getKeys()) ids.add(UUID.fromString(id));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) {
players.add(new RemotePlayer(data.getMap(player)));
}
this.players = players;
run.run();
}));
} else {
run.run();
}
}
/**
* Get the Signature of this Object
*

View File

@ -0,0 +1,167 @@
package net.ME1312.SubServers.Client.Bukkit.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.util.*;
public class RemotePlayer {
ObjectMap<String> raw;
private Proxy proxy = null;
private Server server = null;
long timestamp;
/**
* Create an API representation of a Remote Player
*
* @param raw Raw representation of the Remote Player
*/
public RemotePlayer(ObjectMap<String> raw) {
load(raw);
}
@Override
public boolean equals(Object obj) {
return obj instanceof RemotePlayer && getUniqueId().equals(((RemotePlayer) obj).getUniqueId());
}
void load(ObjectMap<String> raw) {
this.raw = raw;
this.proxy = null;
this.server = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
}
/**
* Download a new copy of the data from SubData
*/
public void refresh() {
UUID id = getUniqueId();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> load(data.getMap(id.toString()))));
}
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
public UUID getUniqueId() {
return raw.getUUID("id");
}
/**
* Get the unique name of this player.
*
* @return the players username
*/
public String getName() {
return raw.getRawString("name");
}
/**
* Gets the remote address of this connection.
*
* @return the remote address
*/
public InetAddress getAddress() {
return Util.getDespiteException(() -> InetAddress.getByName(raw.getRawString("address")), null);
}
/**
* Gets the proxy this player is connected to.
*
* @return the proxy this player is connected to
*/
public String getProxy() {
return raw.getRawString("proxy");
}
/**
* Gets the proxy this player is connected to.
*
* @param callback the proxy this player is connected to
*/
public void getProxy(Callback<Proxy> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(proxy);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (proxy == null || !proxy.getName().equalsIgnoreCase(raw.getRawString("proxy"))) {
SubAPI.getInstance().getProxy(raw.getRawString("proxy"), proxy -> {
this.proxy = proxy;
run.run();
});
} else {
run.run();
}
}
/**
* Gets the server this player is connected to.
*
* @return the server this player is connected to
*/
public String getServer() {
return raw.getRawString("server");
}
/**
* Gets the server this player is connected to.
*
* @param callback the server this player is connected to
*/
public void getServer(Callback<Server> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(server);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (server == null || !server.getName().equalsIgnoreCase(raw.getRawString("server"))) {
SubAPI.getInstance().getServer(raw.getRawString("server"), server -> {
this.server = server;
run.run();
});
} else {
run.run();
}
}
/**
* Get the Timestamp for when the data was last refreshed
*
* @return Data Timestamp
*/
public long getTimestamp() {
return timestamp;
}
/**
* Get the raw representation of the Server
*
* @return Raw Server
*/
public ObjectMap<String> getRaw() {
return raw.clone();
}
}

View File

@ -1,19 +1,25 @@
package net.ME1312.SubServers.Client.Bukkit.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadServerInfo;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
import org.bukkit.permissions.Permissible;
import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.util.*;
public class Server {
ObjectMap<String> raw;
private List<RemotePlayer> players = null;
long timestamp;
/**
@ -32,6 +38,7 @@ public class Server {
void load(ObjectMap<String> raw) {
this.raw = raw;
this.players = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
}
@ -40,7 +47,7 @@ public class Server {
*/
public void refresh() {
String name = getName();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(name, data -> load(data.getMap(name))));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(Collections.singletonList(name), data -> load(data.getMap(name))));
}
/**
@ -58,6 +65,44 @@ public class Server {
return channels.toArray(new SubDataSender[0]);
}
/**
* Determine if an <i>object</i> can perform some action on this server using possible permissions
*
* @param object Object to check against
* @param permissions Permissions to check (use <b>%</b> as a placeholder for the server name)
* @return Permission Check Result
*/
public boolean permits(Permissible object, String... permissions) {
if (Util.isNull(object)) throw new NullPointerException();
boolean permitted = false;
for (int p = 0; !permitted && p < permissions.length; p++) {
String perm = permissions[p];
if (perm != null) {
// Check all servers & individual servers permission
permitted = object.hasPermission(perm.replace("%", "*"))
|| object.hasPermission(perm.replace("%", this.getName().toLowerCase()));
// Check all hosts & individual hosts permission
if (this instanceof SubServer) {
permitted = permitted || object.hasPermission(perm.replace("%", "::*"))
|| object.hasPermission(perm.replace("%", "::" + ((SubServer) this).getHost().toLowerCase()));
}
// Check all groups & individual groups permission
List<String> groups = this.getGroups();
if (groups.size() > 0) {
permitted = permitted || object.hasPermission(perm.replace("%", ":*"));
for (int g = 0; !permitted && g < groups.size(); g++) {
permitted = object.hasPermission(perm.replace("%", ":" + groups.get(g).toLowerCase()));
}
}
}
}
return permitted;
}
/**
* Get the Name of this Server
*
@ -94,18 +139,53 @@ public class Server {
}
/**
* Get the players on this server
* Get players on this server across all known proxies
*
* @return Player Collection
* @return Remote Player Collection
*/
public Collection<NamedContainer<String, UUID>> getPlayers() {
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) {
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getMap(id).getRawString("name"), UUID.fromString(id)));
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
}
return players;
}
/**
* Get players on this server across all known proxies
*
* @param callback Remote Player Collection
*/
public void getGlobalPlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(players);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>();
for (String id : raw.getMap("players").getKeys()) ids.add(UUID.fromString(id));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) {
players.add(new RemotePlayer(data.getMap(player)));
}
this.players = players;
run.run();
}));
} else {
run.run();
}
}
/**
* If the server is hidden from players
*

View File

@ -12,6 +12,7 @@ import java.util.*;
public class SubServer extends Server {
private List<SubServer> incompatibilities = null;
private List<SubServer> currentIncompatibilities = null;
private Host host = null;
/**
@ -59,6 +60,7 @@ public class SubServer extends Server {
public void refresh() {
host = null;
incompatibilities = null;
currentIncompatibilities = null;
super.refresh();
}
@ -643,16 +645,17 @@ public class SubServer extends Server {
};
if (incompatibilities == null) {
LinkedList<String> incompatableNames = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible-list")) incompatableNames.add(subserver.toLowerCase());
SubAPI.getInstance().getSubServers(subservers -> {
LinkedList<String> incompatible = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible-list")) incompatible.add(subserver.toLowerCase());
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(incompatible, data -> {
LinkedList<SubServer> incompatibilities = new LinkedList<SubServer>();
for (SubServer subserver : subservers.values())
if (incompatableNames.contains(subserver.getName().toLowerCase()))
incompatibilities.add(subserver);
for (String server : data.getKeys()) {
if (data.getMap(server).getRawString("type", "Server").equals("SubServer")) incompatibilities.add(new SubServer(data.getMap(server)));
}
this.incompatibilities = incompatibilities;
run.run();
});
}));
} else {
run.run();
}
@ -673,16 +676,33 @@ public class SubServer extends Server {
* @param callback Current Incompatibility List
*/
public void getCurrentIncompatibilities(Callback<List<SubServer>> callback) {
getIncompatibilities(incompatibilities -> {
LinkedList<String> incompatableNames = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible")) incompatableNames.add(subserver.toLowerCase());
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(currentIncompatibilities);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
LinkedList<SubServer> current = new LinkedList<SubServer>();
for (SubServer subserver : incompatibilities)
if (incompatableNames.contains(subserver.getName().toLowerCase()))
current.add(subserver);
callback.run(current);
});
if (currentIncompatibilities == null) {
LinkedList<String> incompatible = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible")) incompatible.add(subserver.toLowerCase());
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(incompatible, data -> {
LinkedList<SubServer> incompatibilities = new LinkedList<SubServer>();
for (String server : data.getKeys()) {
if (data.getMap(server).getRawString("type", "Server").equals("SubServer")) incompatibilities.add(new SubServer(data.getMap(server)));
}
this.currentIncompatibilities = incompatibilities;
run.run();
}));
} else {
run.run();
}
}
/**

View File

@ -8,6 +8,7 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private String group;
private List<String> groups;
private UUID tracker;
/**
@ -27,13 +28,13 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
/**
* New PacketDownloadGroupInfo (Out)
*
* @param group Group name (or null for all)
* @param groups Group names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadGroupInfo(String group, Callback<ObjectMap<String>>... callback) {
public PacketDownloadGroupInfo(List<String> groups, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.group = group;
this.groups = groups;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -42,7 +43,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
if (groups != null) json.set(0x0001, groups);
return json;
}

View File

@ -3,12 +3,12 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -17,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private String group;
private List<String> hosts;
private UUID tracker;
/**
@ -28,13 +28,13 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
/**
* New PacketDownloadHostInfo (Out)
*
* @param group Host name (or null for all)
* @param hosts Host names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadHostInfo(String group, Callback<ObjectMap<String>>... callback) {
public PacketDownloadHostInfo(List<String> hosts, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.group = group;
this.hosts = hosts;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -43,7 +43,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
if (hosts != null) json.set(0x0001, hosts);
return json;
}

View File

@ -1,10 +1,9 @@
package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;

View File

@ -8,25 +8,46 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.*;
/**
* Download Player List Packet
* Download Player Info Packet
*/
public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
public class PacketDownloadPlayerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private Collection<String> names;
private Collection<UUID> ids;
private UUID tracker;
/**
* New PacketDownloadPlayerList
* New PacketDownloadPlayerInfo (In)
*/
public PacketDownloadPlayerInfo() {}
/**
* New PacketDownloadPlayerInfo (Out)
*
* @param players Player Names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadPlayerList(Callback<ObjectMap<String>>... callback) {
public PacketDownloadPlayerInfo(Collection<String> players, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.names = players;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
/**
* New PacketDownloadPlayerInfo (Out)
*
* @param players Player IDs (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadPlayerInfo(List<UUID> players, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.ids = players;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -35,6 +56,8 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (names != null) json.set(0x0001, names);
if (ids != null) json.set(0x0002, ids);
return json;
}

View File

@ -2,13 +2,14 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,8 +17,8 @@ import java.util.UUID;
* Download Proxy Info Packet
*/
public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, NamedContainer<Boolean, Callback<ObjectMap<String>>[]>> callbacks = new HashMap<UUID, NamedContainer<Boolean, Callback<ObjectMap<String>>[]>>();
private String proxy;
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private List<String> proxies;
private UUID tracker;
/**
@ -28,33 +29,34 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
/**
* New PacketDownloadProxyInfo (Out)
*
* @param proxy Proxy name (or null for all)
* @param proxies Proxies name (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadProxyInfo(String proxy, Callback<ObjectMap<String>>... callback) {
public PacketDownloadProxyInfo(List<String> proxies, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.proxy = proxy;
this.proxies = proxies;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, new NamedContainer<>(proxy != null && proxy.length() <= 0, callback));
callbacks.put(tracker, callback);
}
@Override
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (proxy != null) json.set(0x0001, proxy);
if (proxies != null) json.set(0x0001, proxies);
return json;
}
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) {
boolean mode = callbacks.get(data.getUUID(0x0000)).name();
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000)).get()) {
if (mode) {
callback.run((data.contains(0x0002))?new ObjectMap<String>((Map<String, ?>) data.getObject(0x0002)):null);
} else callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) {
ObjectMap<String> map = new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001));
ObjectMap<String> master = (data.contains(0x0002))?new ObjectMap<String>((Map<String, ?>) data.getObject(0x0002)):null;
if (master != null) map.set(master.getString("name"), master);
callback.run(map);
}
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -8,6 +8,7 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private String server;
private List<String> servers;
private UUID tracker;
/**
@ -27,13 +28,13 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
/**
* New PacketDownloadServerInfo (Out)
*
* @param server Server name (or null for all)
* @param servers Server names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadServerInfo(String server, Callback<ObjectMap<String>>... callback) {
public PacketDownloadServerInfo(List<String> servers, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.server = server;
this.servers = servers;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -42,7 +43,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (server != null) json.set(0x0001, server);
if (servers != null) json.set(0x0001, servers);
return json;
}

View File

@ -5,7 +5,7 @@ import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Event.*;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;

View File

@ -52,10 +52,8 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) {
Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
}
if (data.contains(0x0000)) Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -1,7 +1,8 @@
package net.ME1312.SubServers.Client.Bukkit.Network;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.SubDataClient;
@ -31,7 +32,7 @@ public class SubProtocol extends SubDataProtocol {
SubPlugin plugin = SubAPI.getInstance().getInternals();
instance.setName("SubServers 2");
instance.addVersion(new Version("2.14a+"));
instance.addVersion(new Version("2.16a+"));
// 00-0F: Object Link Packets
@ -46,7 +47,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0013, PacketDownloadHostInfo.class);
instance.registerPacket(0x0014, PacketDownloadGroupInfo.class);
instance.registerPacket(0x0015, PacketDownloadServerInfo.class);
instance.registerPacket(0x0016, PacketDownloadPlayerList.class);
instance.registerPacket(0x0016, PacketDownloadPlayerInfo.class);
instance.registerPacket(0x0017, PacketCheckPermission.class);
instance.registerPacket(0x0018, PacketCheckPermissionResponse.class);
@ -56,7 +57,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0013, new PacketDownloadHostInfo());
instance.registerPacket(0x0014, new PacketDownloadGroupInfo());
instance.registerPacket(0x0015, new PacketDownloadServerInfo());
instance.registerPacket(0x0016, new PacketDownloadPlayerList());
instance.registerPacket(0x0016, new PacketDownloadPlayerInfo());
instance.registerPacket(0x0017, new PacketCheckPermission());
instance.registerPacket(0x0018, new PacketCheckPermissionResponse());
@ -133,7 +134,7 @@ public class SubProtocol extends SubDataProtocol {
}
@Override
protected SubDataClient sub(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port) throws IOException {
protected SubDataClient sub(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port, ObjectMap<?> login) throws IOException {
SubPlugin plugin = SubAPI.getInstance().getInternals();
HashMap<Integer, SubDataClient> map = Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("subdata"), plugin), null);
@ -141,7 +142,7 @@ public class SubProtocol extends SubDataProtocol {
while (map.keySet().contains(channel)) channel++;
final int fc = channel;
SubDataClient subdata = super.open(scheduler, getLogger(fc), address, port);
SubDataClient subdata = super.open(scheduler, getLogger(fc), address, port, login);
map.put(fc, subdata);
subdata.sendPacket(new PacketLinkServer(plugin, fc));
subdata.on.closed(client -> map.remove(fc));
@ -164,7 +165,6 @@ public class SubProtocol extends SubDataProtocol {
if (plugin.isEnabled()) {
Bukkit.getPluginManager().callEvent(event);
Bukkit.getLogger().info("SubData > Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
} else map.put(0, null);
});

View File

@ -1,15 +1,13 @@
package net.ME1312.SubServers.Client.Bukkit;
import net.ME1312.SubData.Client.DataClient;
import net.ME1312.SubData.Client.DataProtocol;
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIHandler;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Bukkit.Network.API.Host;
import net.ME1312.SubServers.Client.Bukkit.Network.API.Proxy;
import net.ME1312.SubServers.Client.Bukkit.Network.API.Server;
import net.ME1312.SubServers.Client.Bukkit.Network.API.SubServer;
import net.ME1312.SubServers.Client.Bukkit.Network.API.*;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.*;
import net.ME1312.SubData.Client.SubDataClient;
import org.bukkit.Bukkit;
@ -27,7 +25,7 @@ public final class SubAPI {
private static SubAPI api;
String name;
protected SubAPI(SubPlugin plugin) {
SubAPI(SubPlugin plugin) {
this.plugin = plugin;
GAME_VERSION = getGameVersion();
api = this;
@ -104,7 +102,7 @@ public final class SubAPI {
public void getHost(String name, Callback<Host> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(name, data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(Collections.singletonList(name), data -> {
Host host = null;
if (data.getKeys().size() > 0) {
host = new Host(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
@ -174,14 +172,14 @@ public final class SubAPI {
* @param name Group name
* @param callback a Server Group
*/
public void getGroup(String name, Callback<List<Server>> callback) {
public void getGroup(String name, Callback<NamedContainer<String, List<Server>>> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadGroupInfo(name, data -> {
List<Server> servers = null;
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadGroupInfo(Collections.singletonList(name), data -> {
NamedContainer<String, List<Server>> group = null;
if (data.getKeys().size() > 0) {
String key = new LinkedList<String>(data.getKeys()).getFirst();
servers = new ArrayList<Server>();
List<Server> servers = new ArrayList<Server>();
for (String server : data.getMap(key).getKeys()) {
if (data.getMap(key).getMap(server).getRawString("type", "Server").equals("SubServer")) {
servers.add(new SubServer(data.getMap(key).getMap(server)));
@ -189,10 +187,11 @@ public final class SubAPI {
servers.add(new Server(data.getMap(key).getMap(server)));
}
}
group = new NamedContainer<>(key, servers);
}
try {
callback.run(servers);
callback.run(group);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
@ -238,7 +237,7 @@ public final class SubAPI {
public void getServer(String name, Callback<Server> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(name, data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(Collections.singletonList(name), data -> {
Server server = null;
if (data.getKeys().size() > 0) {
String key = new LinkedList<String>(data.getKeys()).getFirst();
@ -487,7 +486,7 @@ public final class SubAPI {
public void getProxy(String name, Callback<Proxy> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(name, data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(Collections.singletonList(name), data -> {
Proxy proxy = null;
if (data.getKeys().size() > 0) {
proxy = new Proxy(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
@ -511,10 +510,10 @@ public final class SubAPI {
public void getMasterProxy(Callback<Proxy> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo("", data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(Collections.emptyList(), data -> {
Proxy proxy = null;
if (data != null) {
proxy = new Proxy(data);
if (data.getKeys().size() > 0) {
proxy = new Proxy(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
}
try {
@ -530,16 +529,15 @@ public final class SubAPI {
/**
* Get players on this network across all known proxies
*
* @param callback Player Collection
* @param callback Remote Player Collection
*/
@SuppressWarnings("unchecked")
public void getGlobalPlayers(Callback<Collection<NamedContainer<String, UUID>>> callback) {
public void getGlobalPlayers(Callback<Map<UUID, RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerList(data -> {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : data.getKeys()) {
players.add(new NamedContainer<String, UUID>(data.getMap(id).getRawString("name"), UUID.fromString(id)));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo((List<UUID>) null, data -> {
TreeMap<UUID, RemotePlayer> players = new TreeMap<UUID, RemotePlayer>();
for (String player : data.getKeys()) {
players.put(UUID.fromString(player), new RemotePlayer(data.getMap(player)));
}
try {
@ -553,9 +551,59 @@ public final class SubAPI {
}
/**
* Gets the SubData Network Manager
* Get a player on this network by searching across all known proxies
*
* @return SubData Network Manager
* @param name Player name
* @param callback Remote Player
*/
public void getGlobalPlayer(String name, Callback<RemotePlayer> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(name), data -> {
RemotePlayer player = null;
if (data.getKeys().size() > 0) {
player = new RemotePlayer(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
}
try {
callback.run(player);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
}));
}
/**
* Get a player on this network by searching across all known proxies
*
* @param id Player UUID
* @param callback Remote Player
*/
public void getGlobalPlayer(UUID id, Callback<RemotePlayer> callback) {
if (Util.isNull(id, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> {
RemotePlayer player = null;
if (data.getKeys().size() > 0) {
player = new RemotePlayer(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
}
try {
callback.run(player);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
}));
}
/**
* Gets the SubData Network Connections
*
* @return SubData Network Connections
*/
public DataClient[] getSubDataNetwork() {
LinkedList<Integer> keys = new LinkedList<Integer>(plugin.subdata.keySet());
@ -565,6 +613,15 @@ public final class SubAPI {
return channels.toArray(new DataClient[0]);
}
/**
* Gets the SubData Network Protocol
*
* @return SubData Network Protocol
*/
public DataProtocol getSubDataProtocol() {
return plugin.subprotocol;
}
/**
* Gets the current SubServers Lang Channels
*

View File

@ -3,22 +3,25 @@ package net.ME1312.SubServers.Client.Bukkit;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubData.Client.DataClient;
import net.ME1312.SubData.Client.Encryption.AES;
import net.ME1312.SubData.Client.Encryption.DHE;
import net.ME1312.SubData.Client.Encryption.RSA;
import net.ME1312.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.Library.DisconnectReason;
import net.ME1312.SubServers.Client.Bukkit.Graphic.DefaultUIHandler;
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIHandler;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;
import net.ME1312.SubServers.Client.Bukkit.Library.Metrics;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Bukkit.Library.Updates.ConfigUpdater;
import net.ME1312.SubServers.Client.Bukkit.Library.ConfigUpdater;
import net.ME1312.SubServers.Client.Bukkit.Network.SubProtocol;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
@ -80,7 +83,12 @@ public final class SubPlugin extends JavaPlugin {
Files.move(new UniversalFile(new File(System.getProperty("user.dir")), "subdata.rsa.key").toPath(), new UniversalFile(getDataFolder(), "subdata.rsa.key").toPath());
}
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
subprotocol = SubProtocol.get();
subprotocol.registerCipher("DHE", DHE.get(128));
subprotocol.registerCipher("DHE-128", DHE.get(128));
subprotocol.registerCipher("DHE-192", DHE.get(192));
subprotocol.registerCipher("DHE-256", DHE.get(256));
reload(false);
if (!config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
@ -136,7 +144,9 @@ public final class SubPlugin extends JavaPlugin {
subprotocol.unregisterCipher("AES-192");
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", null);
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", System.getenv("name"));
if (config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() > 0) {
subprotocol.registerCipher("AES", new AES(128, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
@ -178,6 +188,7 @@ public final class SubPlugin extends JavaPlugin {
int reconnect = config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30);
if (disconnect == null || (this.reconnect && reconnect > 0 && disconnect.name() != DisconnectReason.PROTOCOL_MISMATCH && disconnect.name() != DisconnectReason.ENCRYPTION_MISMATCH)) {
long reset = resetDate;
if (disconnect != null) Bukkit.getLogger().info("SubData > Attempting reconnect in " + reconnect + " seconds");
Bukkit.getScheduler().runTaskLaterAsynchronously(this, new Runnable() {
@Override
public void run() {
@ -239,4 +250,24 @@ public final class SubPlugin extends JavaPlugin {
//Class<?> gson = com.google.gson.Gson.class;
return (Map<String, ?>) gson.getMethod("fromJson", String.class, Class.class).invoke(gson.newInstance(), json, Map.class);
}
/**
* Send a message to the BungeeCord Plugin Messaging Channel
*
* @param player Player that will send
* @param message Message contents
*/
public void pmc(Player player, String... message) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream data = new DataOutputStream(stream);
try {
for (String m : message) data.writeUTF(m);
data.flush();
} catch (IOException e) {
e.printStackTrace();
}
player.sendPluginMessage(this, "BungeeCord", stream.toByteArray());
}
}

View File

@ -1,9 +1,9 @@
name: 'SubServers-Client-Bukkit'
main: 'net.ME1312.SubServers.Client.Bukkit.SubPlugin'
version: '2.15.2a'
authors: [ME1312]
name: SubServers-Client-Bukkit
main: net.ME1312.SubServers.Client.Bukkit.SubPlugin
version: "2.16a"
authors: ["ME1312"]
softdepend: [Vault, TitleManager]
website: 'https://github.com/ME1312/SubServers-2'
website: "https://github.com/ME1312/SubServers-2"
#commands:
# subservers:
# description: 'The SubServers Command'
@ -26,38 +26,50 @@ permissions:
description: 'Grants Access to the SubServers Command'
default: op
subservers.host.*:
description: 'Grants Access to SubServers Host Actions'
description: 'Grants Access to all Host Actions on all Hosts'
default: op
children:
subservers.host.create.*:
description: 'Grants Access to Create a SubServer'
subservers.host.*.*:
description: 'Grants Access to all Host Actions on all Hosts'
default: op
children:
subservers.host.*.create:
description: 'Grants Access to Create a SubServer on all Hosts'
default: op
subservers.subserver.*:
description: 'Grants Access to SubServers SubServer Actions'
description: 'Grants Access to all SubServer Actions on all SubServers'
default: op
children:
subservers.subserver.update.*:
description: 'Grants Access to Update a SubServer'
default: op
subservers.subserver.start.*:
description: 'Grants Access to Start a SubServer'
default: op
subservers.subserver.stop.*:
description: 'Grants Access to Stop a SubServer'
default: op
subservers.subserver.terminate.*:
description: 'Grants Access to Terminate a SubServer'
default: op
subservers.subserver.command.*:
description: 'Grants Access to Send Commands to a SubServer'
subservers.subserver.*.*:
description: 'Grants Access to all SubServer Actions on all SubServers'
default: op
children:
subservers.subserver.*.start:
description: 'Grants Access to Start all SubServers'
default: op
subservers.subserver.*.stop:
description: 'Grants Access to Stop all SubServers'
default: op
subservers.subserver.*.terminate:
description: 'Grants Access to Terminate all SubServers'
default: op
subservers.subserver.*.command:
description: 'Grants Access to Send Commands to all SubServers'
default: op
subservers.subserver.*.update:
description: 'Grants Access to Update all SubServers'
default: op
subservers.server.*:
description: 'Grants Access to SubServer Server Actions'
description: 'Grants Access to Server Actions on all Servers'
default: op
children:
subservers.server.teleport-others:
description: 'Grants Access to Teleport Others to a Server'
subservers.server.*.*:
description: 'Grants Access to Server Actions on all Servers'
default: op
subservers.server.teleport.*:
description: 'Grants Access to Teleport to a Server'
default: op
children:
subservers.server.*.teleport:
description: 'Grants Access to Teleport to any Server'
default: op
subservers.server.*.teleport-others:
description: 'Grants Access to Teleport Others to any Server'
default: op

View File

@ -30,14 +30,14 @@
<dependency>
<groupId>net.ME1312.Galaxi</groupId>
<artifactId>GalaxiUtil</artifactId>
<version>20w08c</version>
<version>20w15a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w07d</version>
<version>20w15a</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -120,6 +120,7 @@
<configuration>
<windowtitle>SubServers.Client.Sponge Javadoc</windowtitle>
<doctitle>SubServers.Client.Sponge Javadoc</doctitle>
<show>protected</show>
<destDir>./</destDir>
<outputDirectory>${basedir}/../../Javadoc/SubServers.Client.Sponge</outputDirectory>
<reportOutputDirectory>${basedir}/../../Javadoc/SubServers.Client.Sponge</reportOutputDirectory>

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Client.Sponge.Event;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.SubServers.Client.Sponge.Library.SubEvent;
import net.ME1312.Galaxi.Library.Util;
import org.spongepowered.api.event.cause.Cause;

View File

@ -1,8 +1,8 @@
package net.ME1312.SubServers.Client.Sponge.Graphic;
import net.ME1312.SubServers.Client.Sponge.Library.ChatColor;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.SubServers.Client.Sponge.Library.Compatibility.ChatColor;
import net.ME1312.Galaxi.Library.Container.Container;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Sponge.Network.API.Host;
@ -21,8 +21,8 @@ import java.util.concurrent.TimeUnit;
* GUI Renderer Layout Class
*/
public abstract class UIRenderer {
protected static HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
protected static HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
static HashMap<String, PluginRenderer<Host>> hostPlugins = new HashMap<String, PluginRenderer<Host>>();
static HashMap<String, PluginRenderer<SubServer>> subserverPlugins = new HashMap<String, PluginRenderer<SubServer>>();
private NamedContainer<String, Integer> tdownload = null;
private UUID download = null;
private final UUID player;

View File

@ -1,4 +1,4 @@
package net.ME1312.SubServers.Client.Sponge.Library;
package net.ME1312.SubServers.Client.Sponge.Library.Compatibility;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColor;

View File

@ -0,0 +1,49 @@
package net.ME1312.SubServers.Client.Sponge.Library.Compatibility;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.ArgumentParseException;
import org.spongepowered.api.command.args.CommandArgs;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.CommandElement;
import org.spongepowered.api.text.Text;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Comma Separated List Argument Class
*/
public class ListArgument extends CommandElement {
/**
* Parse a Comma Separated List Argument
*
* @param key Key
*/
public ListArgument(Text key) {
super(key);
}
@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
LinkedList<String> selection = new LinkedList<String>();
for (boolean run = true; run && args.hasNext(); ) {
String current = args.next();
if (current.endsWith(",")) {
current = current.substring(0, current.length() - 1);
} else run = false;
selection.add(current.toLowerCase());
}
return selection.toArray(new String[0]);
}
@Override
public List<String> complete(CommandSource src, CommandArgs args, CommandContext context) {
return Collections.emptyList();
}
}

View File

@ -1,4 +1,4 @@
package net.ME1312.SubServers.Client.Sponge.Library.Updates;
package net.ME1312.SubServers.Client.Sponge.Library;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Config.YAMLSection;

View File

@ -1,6 +1,7 @@
package net.ME1312.SubServers.Client.Sponge.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Util;
@ -8,11 +9,9 @@ import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketAddServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDeleteServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadHostInfo;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketRemoveServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.*;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import org.spongepowered.api.service.permission.Subject;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
@ -22,6 +21,7 @@ import java.util.*;
public class Host {
HashMap<String, SubServer> servers = new HashMap<String, SubServer>();
private SubCreator creator;
private List<RemotePlayer> players = null;
ObjectMap<String> raw;
long timestamp;
@ -41,6 +41,7 @@ public class Host {
private void load(ObjectMap<String> raw) {
this.raw = raw;
this.players = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
servers.clear();
@ -55,7 +56,7 @@ public class Host {
*/
public void refresh() {
String name = getName();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(name, data -> load(data.getMap(name))));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(Collections.singletonList(name), data -> load(data.getMap(name))));
}
/**
@ -77,6 +78,29 @@ public class Host {
}
}
/**
* Determine if an <i>object</i> can perform some action on this host using possible permissions
*
* @param object Object to check against
* @param permissions Permissions to check (use <b>%</b> as a placeholder for the host name)
* @return Permission Check Result
*/
public boolean permits(Subject object, String... permissions) {
if (Util.isNull(object)) throw new NullPointerException();
boolean permitted = false;
for (int p = 0; !permitted && p < permissions.length; p++) {
String perm = permissions[p];
if (perm != null) {
// Check all proxies & individual proxies permission
permitted = object.hasPermission(perm.replace("%", "*"))
|| object.hasPermission(perm.replace("%", this.getName().toLowerCase()));
}
}
return permitted;
}
/**
* Is this Host Available?
*
@ -135,6 +159,54 @@ public class Host {
return raw.getRawString("display");
}
/**
* Get players on servers provided by this host across all known proxies
*
* @return Remote Player Collection
*/
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) {
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
}
return players;
}
/**
* Get the players on servers provided by this host across all known proxies
*
* @param callback Remote Player Collection
*/
public void getGlobalPlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(players);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>();
for (SubServer server : getSubServers().values()) for (NamedContainer<String, UUID> player : server.getGlobalPlayers()) ids.add(player.get());
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) {
players.add(new RemotePlayer(data.getMap(player)));
}
this.players = players;
run.run();
}));
} else {
run.run();
}
}
/**
* Starts the Servers Specified
*
@ -346,7 +418,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void removeSubServer(String name) throws InterruptedException {
public void removeSubServer(String name) {
removeSubServer(null, name);
}
@ -356,7 +428,7 @@ public class Host {
* @param player Player Removing
* @param name SubServer Name
*/
public void removeSubServer(UUID player, String name) throws InterruptedException {
public void removeSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
removeSubServer(player, name, false, i -> {});
}
@ -366,7 +438,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void forceRemoveSubServer(String name) throws InterruptedException {
public void forceRemoveSubServer(String name) {
forceRemoveSubServer(null, name);
}
@ -387,7 +459,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void removeSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void removeSubServer(String name, Callback<Integer> response) {
removeSubServer(null, name, response);
}
@ -398,7 +470,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void removeSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void removeSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
removeSubServer(player, name, false, response);
}
@ -409,7 +481,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void forceRemoveSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void forceRemoveSubServer(String name, Callback<Integer> response) {
forceRemoveSubServer(null, name, response);
}
@ -444,7 +516,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void recycleSubServer(String name) throws InterruptedException {
public void recycleSubServer(String name) {
recycleSubServer(null, name);
}
@ -454,7 +526,7 @@ public class Host {
* @param player Player Deleting
* @param name SubServer Name
*/
public void recycleSubServer(UUID player, String name) throws InterruptedException {
public void recycleSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, false, i -> {});
}
@ -464,7 +536,7 @@ public class Host {
*
* @param name SubServer Name
*/
public void forceRecycleSubServer(String name) throws InterruptedException {
public void forceRecycleSubServer(String name) {
forceRecycleSubServer(null, name);
}
@ -474,7 +546,7 @@ public class Host {
* @param player Player Deleting
* @param name SubServer Name
*/
public void forceRecycleSubServer(UUID player, String name) throws InterruptedException {
public void forceRecycleSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, true, i -> {});
}
@ -485,7 +557,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void recycleSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void recycleSubServer(String name, Callback<Integer> response) {
recycleSubServer(null, name, response);
}
@ -496,7 +568,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void recycleSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void recycleSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, false, response);
}
@ -507,7 +579,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void forceRecycleSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void forceRecycleSubServer(String name, Callback<Integer> response) {
forceRecycleSubServer(null, name, response);
}
@ -518,7 +590,7 @@ public class Host {
* @param name SubServer Name
* @param response Response Code
*/
public void forceRecycleSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void forceRecycleSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, true, true, response);
}
@ -529,7 +601,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(String name) throws InterruptedException {
public void deleteSubServer(String name) {
deleteSubServer(null, name);
}
@ -540,7 +612,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(UUID player, String name) throws InterruptedException {
public void deleteSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, false, i -> {});
}
@ -551,7 +623,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(String name) throws InterruptedException {
public void forceDeleteSubServer(String name) {
forceDeleteSubServer(null, name);
}
@ -562,7 +634,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(UUID player, String name) throws InterruptedException {
public void forceDeleteSubServer(UUID player, String name) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, true, i -> {});
}
@ -573,7 +645,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void deleteSubServer(String name, Callback<Integer> response) {
deleteSubServer(null, name, response);
}
@ -584,7 +656,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void deleteSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void deleteSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, false, response);
}
@ -595,7 +667,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(String name, Callback<Integer> response) throws InterruptedException {
public void forceDeleteSubServer(String name, Callback<Integer> response) {
forceDeleteSubServer(null, name, response);
}
@ -606,7 +678,7 @@ public class Host {
* @param name SubServer Name
* @return Success Status
*/
public void forceDeleteSubServer(UUID player, String name, Callback<Integer> response) throws InterruptedException {
public void forceDeleteSubServer(UUID player, String name, Callback<Integer> response) {
if (Util.isNull(name)) throw new NullPointerException();
deleteSubServer(player, name, false, true, response);
}

View File

@ -1,20 +1,25 @@
package net.ME1312.SubServers.Client.Sponge.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadProxyInfo;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import org.spongepowered.api.service.permission.Subject;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
public class Proxy {
ObjectMap<String> raw;
private List<RemotePlayer> players = null;
long timestamp;
/**
@ -33,6 +38,7 @@ public class Proxy {
private void load(ObjectMap<String> raw) {
this.raw = raw;
this.players = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
}
@ -41,7 +47,7 @@ public class Proxy {
*/
public void refresh() {
String name = getName();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(name, data -> load(data.getMap(name))));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(Collections.singletonList(name), data -> load(data.getMap(name))));
}
/**
@ -59,6 +65,29 @@ public class Proxy {
return channels.toArray(new SubDataSender[0]);
}
/**
* Determine if an <i>object</i> can perform some action on this proxy using possible permissions
*
* @param object Object to check against
* @param permissions Permissions to check (use <b>%</b> as a placeholder for the proxy name)
* @return Permission Check Result
*/
public boolean permits(Subject object, String... permissions) {
if (Util.isNull(object)) throw new NullPointerException();
boolean permitted = false;
for (int p = 0; !permitted && p < permissions.length; p++) {
String perm = permissions[p];
if (perm != null) {
// Check all proxies & individual proxies permission
permitted = object.hasPermission(perm.replace("%", "*"))
|| object.hasPermission(perm.replace("%", this.getName().toLowerCase()));
}
}
return permitted;
}
/**
* Get the Name of this Proxy
*
@ -78,7 +107,7 @@ public class Proxy {
}
/**
* Test if the proxy is connected to RedisBungee's server
* Determine if the proxy is connected to RedisBungee's server
*
* @return Redis Status
*/
@ -86,19 +115,63 @@ public class Proxy {
return raw.getBoolean("redis");
}
/**
* Determine if the proxy is the Master Proxy
*
* @return Master Proxy Status
*/
public boolean isMaster() {
return raw.getBoolean("master");
}
/**
* Get the players on this proxy (via RedisBungee)
*
* @return Player Collection
* @return Remote Player Collection
*/
public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) {
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getMap(id).getRawString("name"), UUID.fromString(id)));
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
}
return players;
}
/**
* Get the players on this proxy (via RedisBungee)
*
* @param callback Remote Player Collection
*/
public void getPlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(players);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>();
for (String id : raw.getMap("players").getKeys()) ids.add(UUID.fromString(id));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) {
players.add(new RemotePlayer(data.getMap(player)));
}
this.players = players;
run.run();
}));
} else {
run.run();
}
}
/**
* Get the Signature of this Object
*

View File

@ -0,0 +1,169 @@
package net.ME1312.SubServers.Client.Sponge.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.util.Calendar;
import java.util.Collections;
import java.util.UUID;
public class RemotePlayer {
ObjectMap<String> raw;
private Proxy proxy = null;
private Server server = null;
long timestamp;
/**
* Create an API representation of a Remote Player
*
* @param raw Raw representation of the Remote Player
*/
public RemotePlayer(ObjectMap<String> raw) {
load(raw);
}
@Override
public boolean equals(Object obj) {
return obj instanceof RemotePlayer && getUniqueId().equals(((RemotePlayer) obj).getUniqueId());
}
void load(ObjectMap<String> raw) {
this.raw = raw;
this.proxy = null;
this.server = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
}
/**
* Download a new copy of the data from SubData
*/
public void refresh() {
UUID id = getUniqueId();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> load(data.getMap(id.toString()))));
}
/**
* Get this connection's UUID, if set.
*
* @return the UUID
*/
public UUID getUniqueId() {
return raw.getUUID("id");
}
/**
* Get the unique name of this player.
*
* @return the players username
*/
public String getName() {
return raw.getRawString("name");
}
/**
* Gets the remote address of this connection.
*
* @return the remote address
*/
public InetAddress getAddress() {
return Util.getDespiteException(() -> InetAddress.getByName(raw.getRawString("address")), null);
}
/**
* Gets the proxy this player is connected to.
*
* @return the proxy this player is connected to
*/
public String getProxy() {
return raw.getRawString("proxy");
}
/**
* Gets the proxy this player is connected to.
*
* @param callback the proxy this player is connected to
*/
public void getProxy(Callback<Proxy> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(proxy);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (proxy == null || !proxy.getName().equalsIgnoreCase(raw.getRawString("proxy"))) {
SubAPI.getInstance().getProxy(raw.getRawString("proxy"), proxy -> {
this.proxy = proxy;
run.run();
});
} else {
run.run();
}
}
/**
* Gets the server this player is connected to.
*
* @return the server this player is connected to
*/
public String getServer() {
return raw.getRawString("server");
}
/**
* Gets the server this player is connected to.
*
* @param callback the server this player is connected to
*/
public void getServer(Callback<Server> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(server);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (server == null || !server.getName().equalsIgnoreCase(raw.getRawString("server"))) {
SubAPI.getInstance().getServer(raw.getRawString("server"), server -> {
this.server = server;
run.run();
});
} else {
run.run();
}
}
/**
* Get the Timestamp for when the data was last refreshed
*
* @return Data Timestamp
*/
public long getTimestamp() {
return timestamp;
}
/**
* Get the raw representation of the Server
*
* @return Raw Server
*/
public ObjectMap<String> getRaw() {
return raw.clone();
}
}

View File

@ -1,19 +1,25 @@
package net.ME1312.SubServers.Client.Sponge.Network.API;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadPlayerInfo;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadServerInfo;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import org.spongepowered.api.service.permission.Subject;
import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.util.*;
public class Server {
ObjectMap<String> raw;
private List<RemotePlayer> players = null;
long timestamp;
/**
@ -32,6 +38,7 @@ public class Server {
void load(ObjectMap<String> raw) {
this.raw = raw;
this.players = null;
this.timestamp = Calendar.getInstance().getTime().getTime();
}
@ -40,7 +47,7 @@ public class Server {
*/
public void refresh() {
String name = getName();
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(name, data -> load(data.getMap(name))));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(Collections.singletonList(name), data -> load(data.getMap(name))));
}
/**
@ -58,6 +65,44 @@ public class Server {
return channels.toArray(new SubDataSender[0]);
}
/**
* Determine if an <i>object</i> can perform some action on this server using possible permissions
*
* @param object Object to check against
* @param permissions Permissions to check (use <b>%</b> as a placeholder for the server name)
* @return Permission Check Result
*/
public boolean permits(Subject object, String... permissions) {
if (Util.isNull(object)) throw new NullPointerException();
boolean permitted = false;
for (int p = 0; !permitted && p < permissions.length; p++) {
String perm = permissions[p];
if (perm != null) {
// Check all servers & individual servers permission
permitted = object.hasPermission(perm.replace("%", "*"))
|| object.hasPermission(perm.replace("%", this.getName().toLowerCase()));
// Check all hosts & individual hosts permission
if (this instanceof SubServer) {
permitted = permitted || object.hasPermission(perm.replace("%", "::*"))
|| object.hasPermission(perm.replace("%", "::" + ((SubServer) this).getHost().toLowerCase()));
}
// Check all groups & individual groups permission
List<String> groups = this.getGroups();
if (groups.size() > 0) {
permitted = permitted || object.hasPermission(perm.replace("%", ":*"));
for (int g = 0; !permitted && g < groups.size(); g++) {
permitted = object.hasPermission(perm.replace("%", ":" + groups.get(g).toLowerCase()));
}
}
}
}
return permitted;
}
/**
* Get the Name of this Server
*
@ -94,18 +139,53 @@ public class Server {
}
/**
* Get the players on this server
* Get players on this server across all known proxies
*
* @return Player Collection
* @return Remote Player Collection
*/
public Collection<NamedContainer<String, UUID>> getPlayers() {
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : raw.getMap("players").getKeys()) {
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getMap(id).getRawString("name"), UUID.fromString(id)));
players.add(new NamedContainer<String, UUID>(raw.getMap("players").getRawString(id), UUID.fromString(id)));
}
return players;
}
/**
* Get players on this server across all known proxies
*
* @param callback Remote Player Collection
*/
public void getGlobalPlayers(Callback<Collection<RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(players);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
if (players == null) {
LinkedList<UUID> ids = new LinkedList<UUID>();
for (String id : raw.getMap("players").getKeys()) ids.add(UUID.fromString(id));
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(ids, data -> {
LinkedList<RemotePlayer> players = new LinkedList<RemotePlayer>();
for (String player : data.getKeys()) {
players.add(new RemotePlayer(data.getMap(player)));
}
this.players = players;
run.run();
}));
} else {
run.run();
}
}
/**
* If the server is hidden from players
*

View File

@ -4,10 +4,7 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketCommandServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketEditServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketStartServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketStopServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.*;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import java.lang.reflect.InvocationTargetException;
@ -18,6 +15,7 @@ import java.util.UUID;
public class SubServer extends Server {
private List<SubServer> incompatibilities = null;
private List<SubServer> currentIncompatibilities = null;
private Host host = null;
/**
@ -65,6 +63,7 @@ public class SubServer extends Server {
public void refresh() {
host = null;
incompatibilities = null;
currentIncompatibilities = null;
super.refresh();
}
@ -649,16 +648,17 @@ public class SubServer extends Server {
};
if (incompatibilities == null) {
LinkedList<String> incompatableNames = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible-list")) incompatableNames.add(subserver.toLowerCase());
SubAPI.getInstance().getSubServers(subservers -> {
LinkedList<String> incompatible = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible-list")) incompatible.add(subserver.toLowerCase());
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(incompatible, data -> {
LinkedList<SubServer> incompatibilities = new LinkedList<SubServer>();
for (SubServer subserver : subservers.values())
if (incompatableNames.contains(subserver.getName().toLowerCase()))
incompatibilities.add(subserver);
for (String server : data.getKeys()) {
if (data.getMap(server).getRawString("type", "Server").equals("SubServer")) incompatibilities.add(new SubServer(data.getMap(server)));
}
this.incompatibilities = incompatibilities;
run.run();
});
}));
} else {
run.run();
}
@ -679,16 +679,33 @@ public class SubServer extends Server {
* @param callback Current Incompatibility List
*/
public void getCurrentIncompatibilities(Callback<List<SubServer>> callback) {
getIncompatibilities(incompatibilities -> {
LinkedList<String> incompatableNames = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible")) incompatableNames.add(subserver.toLowerCase());
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
Runnable run = () -> {
try {
callback.run(currentIncompatibilities);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
};
LinkedList<SubServer> current = new LinkedList<SubServer>();
for (SubServer subserver : incompatibilities)
if (incompatableNames.contains(subserver.getName().toLowerCase()))
current.add(subserver);
callback.run(current);
});
if (currentIncompatibilities == null) {
LinkedList<String> incompatible = new LinkedList<String>();
for (String subserver : raw.getRawStringList("incompatible")) incompatible.add(subserver.toLowerCase());
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(incompatible, data -> {
LinkedList<SubServer> incompatibilities = new LinkedList<SubServer>();
for (String server : data.getKeys()) {
if (data.getMap(server).getRawString("type", "Server").equals("SubServer")) incompatibilities.add(new SubServer(data.getMap(server)));
}
this.currentIncompatibilities = incompatibilities;
run.run();
}));
} else {
run.run();
}
}
/**

View File

@ -8,6 +8,7 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private String group;
private List<String> groups;
private UUID tracker;
/**
@ -27,13 +28,13 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
/**
* New PacketDownloadGroupInfo (Out)
*
* @param group Group name (or null for all)
* @param groups Group names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadGroupInfo(String group, Callback<ObjectMap<String>>... callback) {
public PacketDownloadGroupInfo(List<String> groups, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.group = group;
this.groups = groups;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -42,7 +43,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
if (groups != null) json.set(0x0001, groups);
return json;
}

View File

@ -8,6 +8,7 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private String group;
private List<String> hosts;
private UUID tracker;
/**
@ -27,13 +28,13 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
/**
* New PacketDownloadHostInfo (Out)
*
* @param group Host name (or null for all)
* @param hosts Host names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadHostInfo(String group, Callback<ObjectMap<String>>... callback) {
public PacketDownloadHostInfo(List<String> hosts, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.group = group;
this.hosts = hosts;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -42,7 +43,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
if (hosts != null) json.set(0x0001, hosts);
return json;
}

View File

@ -1,10 +1,9 @@
package net.ME1312.SubServers.Client.Sponge.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;

View File

@ -7,25 +7,46 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.*;
/**
* Download Player List Packet
* Download Player Info Packet
*/
public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
public class PacketDownloadPlayerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private Collection<String> names;
private Collection<UUID> ids;
private UUID tracker;
/**
* New PacketDownloadPlayerList
* New PacketDownloadPlayerInfo (In)
*/
public PacketDownloadPlayerInfo() {}
/**
* New PacketDownloadPlayerInfo (Out)
*
* @param players Player Names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadPlayerList(Callback<ObjectMap<String>>... callback) {
public PacketDownloadPlayerInfo(Collection<String> players, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.names = players;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
/**
* New PacketDownloadPlayerInfo (Out)
*
* @param players Player IDs (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadPlayerInfo(List<UUID> players, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.ids = players;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -34,6 +55,8 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (names != null) json.set(0x0001, names);
if (ids != null) json.set(0x0002, ids);
return json;
}

View File

@ -2,13 +2,13 @@ package net.ME1312.SubServers.Client.Sponge.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,8 +16,8 @@ import java.util.UUID;
* Download Proxy Info Packet
*/
public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, NamedContainer<Boolean, Callback<ObjectMap<String>>[]>> callbacks = new HashMap<UUID, NamedContainer<Boolean, Callback<ObjectMap<String>>[]>>();
private String proxy;
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private List<String> proxies;
private UUID tracker;
/**
@ -28,33 +28,34 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
/**
* New PacketDownloadProxyInfo (Out)
*
* @param proxy Proxy name (or null for all)
* @param proxies Proxies name (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadProxyInfo(String proxy, Callback<ObjectMap<String>>... callback) {
public PacketDownloadProxyInfo(List<String> proxies, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.proxy = proxy;
this.proxies = proxies;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, new NamedContainer<>(proxy != null && proxy.length() <= 0, callback));
callbacks.put(tracker, callback);
}
@Override
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (proxy != null) json.set(0x0001, proxy);
if (proxies != null) json.set(0x0001, proxies);
return json;
}
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) {
boolean mode = callbacks.get(data.getUUID(0x0000)).name();
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000)).get()) {
if (mode) {
callback.run((data.contains(0x0002))?new ObjectMap<String>((Map<String, ?>) data.getObject(0x0002)):null);
} else callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) {
ObjectMap<String> map = new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001));
ObjectMap<String> master = (data.contains(0x0002))?new ObjectMap<String>((Map<String, ?>) data.getObject(0x0002)):null;
if (master != null) map.set(master.getString("name"), master);
callback.run(map);
}
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -8,6 +8,7 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@ -16,7 +17,7 @@ import java.util.UUID;
*/
public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<ObjectMap<String>>[]> callbacks = new HashMap<UUID, Callback<ObjectMap<String>>[]>();
private String server;
private List<String> servers;
private UUID tracker;
/**
@ -27,13 +28,13 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
/**
* New PacketDownloadServerInfo (Out)
*
* @param server Server name (or null for all)
* @param servers Server names (or null for all)
* @param callback Callbacks
*/
@SafeVarargs
public PacketDownloadServerInfo(String server, Callback<ObjectMap<String>>... callback) {
public PacketDownloadServerInfo(List<String> servers, Callback<ObjectMap<String>>... callback) {
if (Util.isNull((Object) callback)) throw new NullPointerException();
this.server = server;
this.servers = servers;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@ -42,7 +43,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (server != null) json.set(0x0001, server);
if (servers != null) json.set(0x0001, servers);
return json;
}

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Client.Sponge.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataSender;

View File

@ -44,7 +44,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
if (plugin.api.getName() != null) json.set(0x0000, plugin.api.getName());
if (plugin.game.getServer().getBoundAddress().isPresent()) json.set(0x0001, plugin.game.getServer().getBoundAddress().get());
if (plugin.game.getServer().getBoundAddress().isPresent()) json.set(0x0001, plugin.game.getServer().getBoundAddress().get().getPort());
json.set(0x0002, channel);
return json;
}
@ -54,10 +54,8 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) {
Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
}
if (data.contains(0x0000)) Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -1,7 +1,8 @@
package net.ME1312.SubServers.Client.Sponge.Network;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.SubDataClient;
@ -35,7 +36,7 @@ public class SubProtocol extends SubDataProtocol {
SubPlugin plugin = SubAPI.getInstance().getInternals();
instance.setName("SubServers 2");
instance.addVersion(new Version("2.14a+"));
instance.addVersion(new Version("2.16a+"));
// 00-0F: Object Link Packets
@ -50,7 +51,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0013, PacketDownloadHostInfo.class);
instance.registerPacket(0x0014, PacketDownloadGroupInfo.class);
instance.registerPacket(0x0015, PacketDownloadServerInfo.class);
instance.registerPacket(0x0016, PacketDownloadPlayerList.class);
instance.registerPacket(0x0016, PacketDownloadPlayerInfo.class);
instance.registerPacket(0x0017, PacketCheckPermission.class);
instance.registerPacket(0x0018, PacketCheckPermissionResponse.class);
@ -60,7 +61,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0013, new PacketDownloadHostInfo());
instance.registerPacket(0x0014, new PacketDownloadGroupInfo());
instance.registerPacket(0x0015, new PacketDownloadServerInfo());
instance.registerPacket(0x0016, new PacketDownloadPlayerList());
instance.registerPacket(0x0016, new PacketDownloadPlayerInfo());
instance.registerPacket(0x0017, new PacketCheckPermission());
instance.registerPacket(0x0018, new PacketCheckPermissionResponse());
@ -141,7 +142,7 @@ public class SubProtocol extends SubDataProtocol {
}
@Override
protected SubDataClient sub(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port) throws IOException {
protected SubDataClient sub(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port, ObjectMap<?> login) throws IOException {
SubPlugin plugin = SubAPI.getInstance().getInternals();
HashMap<Integer, SubDataClient> map = Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("subdata"), plugin), null);
@ -149,7 +150,7 @@ public class SubProtocol extends SubDataProtocol {
while (map.keySet().contains(channel)) channel++;
final int fc = channel;
SubDataClient subdata = super.open(scheduler, getLogger(fc), address, port);
SubDataClient subdata = super.open(scheduler, getLogger(fc), address, port, login);
map.put(fc, subdata);
subdata.sendPacket(new PacketLinkServer(plugin, fc));
subdata.on.closed(client -> map.remove(fc));
@ -172,8 +173,6 @@ public class SubProtocol extends SubDataProtocol {
Sponge.getEventManager().post(event);
if (Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("running"), plugin), true)) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
log.info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
} else map.put(0, null);
});

View File

@ -1,16 +1,14 @@
package net.ME1312.SubServers.Client.Sponge;
import net.ME1312.SubData.Client.DataClient;
import net.ME1312.SubData.Client.DataProtocol;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Sponge.Graphic.UIHandler;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Sponge.Network.API.Host;
import net.ME1312.SubServers.Client.Sponge.Network.API.Proxy;
import net.ME1312.SubServers.Client.Sponge.Network.API.Server;
import net.ME1312.SubServers.Client.Sponge.Network.API.SubServer;
import net.ME1312.SubServers.Client.Sponge.Network.API.*;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.*;
import org.spongepowered.api.Platform;
import org.spongepowered.api.Sponge;
@ -29,7 +27,7 @@ public final class SubAPI {
private static SubAPI api;
String name;
protected SubAPI(SubPlugin plugin) {
SubAPI(SubPlugin plugin) {
this.plugin = plugin;
GAME_VERSION = getGameVersion();
api = this;
@ -106,7 +104,7 @@ public final class SubAPI {
public void getHost(String name, Callback<Host> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(name, data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadHostInfo(Collections.singletonList(name), data -> {
Host host = null;
if (data.getKeys().size() > 0) {
host = new Host(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
@ -176,14 +174,14 @@ public final class SubAPI {
* @param name Group name
* @param callback a Server Group
*/
public void getGroup(String name, Callback<List<Server>> callback) {
public void getGroup(String name, Callback<NamedContainer<String, List<Server>>> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadGroupInfo(name, data -> {
List<Server> servers = null;
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadGroupInfo(Collections.singletonList(name), data -> {
NamedContainer<String, List<Server>> group = null;
if (data.getKeys().size() > 0) {
String key = new LinkedList<String>(data.getKeys()).getFirst();
servers = new ArrayList<Server>();
List<Server> servers = new ArrayList<Server>();
for (String server : data.getMap(key).getKeys()) {
if (data.getMap(key).getMap(server).getRawString("type", "Server").equals("SubServer")) {
servers.add(new SubServer(data.getMap(key).getMap(server)));
@ -191,10 +189,11 @@ public final class SubAPI {
servers.add(new Server(data.getMap(key).getMap(server)));
}
}
group = new NamedContainer<>(key, servers);
}
try {
callback.run(servers);
callback.run(group);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
@ -240,7 +239,7 @@ public final class SubAPI {
public void getServer(String name, Callback<Server> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(name, data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadServerInfo(Collections.singletonList(name), data -> {
Server server = null;
if (data.getKeys().size() > 0) {
String key = new LinkedList<String>(data.getKeys()).getFirst();
@ -489,7 +488,7 @@ public final class SubAPI {
public void getProxy(String name, Callback<Proxy> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(name, data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(Collections.singletonList(name), data -> {
Proxy proxy = null;
if (data.getKeys().size() > 0) {
proxy = new Proxy(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
@ -513,10 +512,10 @@ public final class SubAPI {
public void getMasterProxy(Callback<Proxy> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo("", data -> {
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadProxyInfo(Collections.emptyList(), data -> {
Proxy proxy = null;
if (data != null) {
proxy = new Proxy(data);
if (data.getKeys().size() > 0) {
proxy = new Proxy(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
}
try {
@ -532,16 +531,15 @@ public final class SubAPI {
/**
* Get players on this network across all known proxies
*
* @param callback Player Collection
* @param callback Remote Player Collection
*/
@SuppressWarnings("unchecked")
public void getGlobalPlayers(Callback<Collection<NamedContainer<String, UUID>>> callback) {
public void getGlobalPlayers(Callback<Map<UUID, RemotePlayer>> callback) {
if (Util.isNull(callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerList(data -> {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
for (String id : data.getKeys()) {
players.add(new NamedContainer<String, UUID>(data.getMap(id).getRawString("name"), UUID.fromString(id)));
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo((List<UUID>) null, data -> {
TreeMap<UUID, RemotePlayer> players = new TreeMap<UUID, RemotePlayer>();
for (String player : data.getKeys()) {
players.put(UUID.fromString(player), new RemotePlayer(data.getMap(player)));
}
try {
@ -555,9 +553,59 @@ public final class SubAPI {
}
/**
* Gets the SubData Network Manager
* Get a player on this network by searching across all known proxies
*
* @return SubData Network Manager
* @param name Player name
* @param callback Remote Player
*/
public void getGlobalPlayer(String name, Callback<RemotePlayer> callback) {
if (Util.isNull(name, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(name), data -> {
RemotePlayer player = null;
if (data.getKeys().size() > 0) {
player = new RemotePlayer(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
}
try {
callback.run(player);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
}));
}
/**
* Get a player on this network by searching across all known proxies
*
* @param id Player UUID
* @param callback Remote Player
*/
public void getGlobalPlayer(UUID id, Callback<RemotePlayer> callback) {
if (Util.isNull(id, callback)) throw new NullPointerException();
StackTraceElement[] origin = new Exception().getStackTrace();
((SubDataClient) plugin.api.getSubDataNetwork()[0]).sendPacket(new PacketDownloadPlayerInfo(Collections.singletonList(id), data -> {
RemotePlayer player = null;
if (data.getKeys().size() > 0) {
player = new RemotePlayer(data.getMap(new LinkedList<String>(data.getKeys()).getFirst()));
}
try {
callback.run(player);
} catch (Throwable e) {
Throwable ew = new InvocationTargetException(e);
ew.setStackTrace(origin);
ew.printStackTrace();
}
}));
}
/**
* Gets the SubData Network Connections
*
* @return SubData Network Connections
*/
public DataClient[] getSubDataNetwork() {
LinkedList<Integer> keys = new LinkedList<Integer>(plugin.subdata.keySet());
@ -567,6 +615,15 @@ public final class SubAPI {
return channels.toArray(new DataClient[0]);
}
/**
* Gets the SubData Network Protocol
*
* @return SubData Network Protocol
*/
public DataProtocol getSubDataProtocol() {
return plugin.subprotocol;
}
/**
* Gets the current SubServers Lang Channels
*

View File

@ -4,28 +4,32 @@ import com.google.gson.Gson;
import com.google.inject.Inject;
import net.ME1312.SubData.Client.DataClient;
import net.ME1312.SubData.Client.Encryption.AES;
import net.ME1312.SubData.Client.Encryption.DHE;
import net.ME1312.SubData.Client.Encryption.RSA;
import net.ME1312.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.Library.DisconnectReason;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Client.Sponge.Graphic.UIHandler;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubServers.Client.Sponge.Library.Metrics;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Container.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Client.Sponge.Library.Updates.ConfigUpdater;
import net.ME1312.SubServers.Client.Sponge.Library.ConfigUpdater;
import net.ME1312.SubServers.Client.Sponge.Network.SubProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.Game;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.config.ConfigDir;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameInitializationEvent;
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
import org.spongepowered.api.event.game.state.GameStoppingEvent;
import org.spongepowered.api.network.ChannelBinding;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginContainer;
@ -42,7 +46,7 @@ import java.util.concurrent.TimeUnit;
/**
* SubServers Client Plugin Class
*/
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.15.2a", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
@Plugin(id = "subservers-client-sponge", name = "SubServers-Client-Sponge", authors = "ME1312", version = "2.16a", url = "https://github.com/ME1312/SubServers-2", description = "Take control of the server manager — from your servers")
public final class SubPlugin {
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
NamedContainer<Long, Map<String, Map<String, String>>> lang = null;
@ -100,6 +104,10 @@ public final class SubPlugin {
running = true;
subprotocol = SubProtocol.get();
subprotocol.registerCipher("DHE", DHE.get(128));
subprotocol.registerCipher("DHE-128", DHE.get(128));
subprotocol.registerCipher("DHE-192", DHE.get(192));
subprotocol.registerCipher("DHE-256", DHE.get(256));
reload(false);
if (!config.get().getMap("Settings").getBoolean("API-Only-Mode", false)) {
@ -153,7 +161,9 @@ public final class SubPlugin {
subprotocol.unregisterCipher("AES-192");
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", null);
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", System.getenv("name"));
Logger log = LoggerFactory.getLogger("SubData");
if (config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() > 0) {
@ -197,6 +207,7 @@ public final class SubPlugin {
if (disconnect == null || (this.reconnect && reconnect > 0 && disconnect.name() != DisconnectReason.PROTOCOL_MISMATCH && disconnect.name() != DisconnectReason.ENCRYPTION_MISMATCH)) {
long reset = resetDate;
Logger log = LoggerFactory.getLogger("SubData");
if (disconnect != null) log.info("Attempting reconnect in " + reconnect + " seconds");
Sponge.getScheduler().createTaskBuilder().async().execute(new Runnable() {
@Override
public void run() {
@ -219,6 +230,19 @@ public final class SubPlugin {
}
}
/**
* Send a message to the BungeeCord Plugin Messaging Channel
*
* @param player Player that will send
* @param message Message contents
*/
public void pmc(Player player, String... message) {
ChannelBinding.RawDataChannel channel = game.getChannelRegistrar().getOrCreateRaw(this, "BungeeCord");
channel.sendTo(player, buf -> {
for (String m : message) buf.writeUTF(m);
});
}
/**
* Disable Plugin
*/

View File

@ -1,4 +1,4 @@
name: SubServers-Console
main: net.ME1312.SubServers.Console.ConsolePlugin
version: 2.15a
version: 2.16a
author: ME1312

View File

@ -775,10 +775,10 @@ public final class ConsoleWindow implements SubLogFilter {
}
private class TextFieldPopup extends JPanel {
protected LinkedList<String> commands = new LinkedList<String>();
protected Boolean history = false;
protected int hpos = -1;
protected String hcache = "";
LinkedList<String> commands = new LinkedList<String>();
Boolean history = false;
int hpos = -1;
String hcache = "";
public TextFieldPopup(JTextComponent field, boolean command) {
JPopupMenu menu = new JPopupMenu();

View File

@ -1,6 +1,6 @@
package net.ME1312.SubServers.Console.Library;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Container.Container;
import org.fusesource.jansi.AnsiOutputStream;
import java.io.IOException;

View File

@ -50,7 +50,7 @@ if [[ $__RETURN -eq 0 ]]; then
rm -Rf "$0"
exit 0
else
echo ERROR: Failed downloading Sponge. Is MinecraftForge.net down?
echo ERROR: Failed downloading Sponge. Is SpongePowered.org down?
if [[ -f "mods/Sponge.old.jar.x" ]]; then
if [[ -f "mods/Sponge.jar" ]]; then
rm -Rf mods/Sponge.jar

View File

@ -1,126 +1,8 @@
# 1.0
#
# # If you need help with the configuration or have any questions related to Sponge,
# # join us at the IRC or drop by our forums and leave a post.
#
# # IRC: #sponge @ irc.esper.net ( http://webchat.esper.net/?channel=sponge )
# # Forums: https://forums.spongepowered.org/
#
# 0.0
#
sponge {
block-tracking {
# If enabled, adds player tracking support for block positions. Note: This should only be disabled if you do not care who caused a block to change.
enabled=true
}
bungeecord {
# If enabled, allows BungeeCord to forward IP address, UUID, and Game Profile to this server
ip-forwarding=true
}
commands {}
debug {
# Dump chunks in the event of a deadlock
dump-chunks-on-deadlock=false
# Dump the heap in the event of a deadlock
dump-heap-on-deadlock=false
# Dump the server thread on deadlock warning
dump-threads-on-warn=false
# Enable Java's thread contention monitoring for thread dumps
thread-contention-monitoring=false
}
entity {
# Number of colliding entities in one spot before logging a warning. Set to 0 to disable
collision-warn-size=200
# Number of entities in one dimension before logging a warning. Set to 0 to disable
count-warn-size=0
# Number of ticks before a painting is respawned on clients when their art is changed
entity-painting-respawn-delay=2
# Number of ticks before the fake player entry of a human is removed from the tab list (range of 0 to 100 ticks).
human-player-list-remove-delay=10
# Controls the time in ticks for when an item despawns.
item-despawn-rate=6000
# Max size of an entity's bounding box before removing it. Set to 0 to disable
max-bounding-box-size=1000
# Square of the max speed of an entity before removing it. Set to 0 to disable
max-speed=100
}
entity-activation-range {
ambient-activation-range=32
aquatic-activation-range=32
creature-activation-range=32
minecraft {
creature {
entityhorse=true
pig=true
sheep=true
}
enabled=true
misc {
item=true
minecartchest=true
}
monster {
guardian=true
}
}
misc-activation-range=16
monster-activation-range=32
}
general {
# Forces Chunk Loading on provide requests (speedup for mods that don't check if a chunk is loaded)
chunk-load-override=false
# Disable warning messages to server admins
disable-warnings=false
}
logging {
# Log when blocks are broken
block-break=false
# Log when blocks are modified
block-modify=false
# Log when blocks are placed
block-place=false
# Log when blocks are populated in a chunk
block-populate=false
# Log when blocks are placed by players and tracked
block-tracking=false
# Log when chunks are loaded
chunk-load=false
# Log when chunks are unloaded
chunk-unload=false
# Whether to log entity collision/count checks
entity-collision-checks=false
# Log when living entities are destroyed
entity-death=false
# Log when living entities are despawned
entity-despawn=false
# Log when living entities are spawned
entity-spawn=false
# Whether to log entity removals due to speed
entity-speed-removal=false
# Add stack traces to dev logging
log-stacktraces=false
}
modules {
bungeecord=true
entity-activation-range=true
timings=true
}
# Configuration options related to the Sql service, including connection aliases etc
sql {}
timings {
enabled=true
hidden-config-entries=[
"sponge.sql"
]
history-interval=300
history-length=3600
server-name-privacy=false
verbose=false
}
world {
# Lava behaves like vanilla water when source block is removed
flowing-lava-decay=false
# Vanilla water source behavior - is infinite
infinite-water-source=false
}
}

View File

@ -1,35 +1,10 @@
#Minecraft server properties
generator-settings=
op-permission-level=4
allow-nether=true
resource-pack-hash=
level-name=world
enable-query=false
allow-flight=false
announce-player-achievements=false
server-port=
max-world-size=29999984
level-type=DEFAULT
enable-rcon=false
level-seed=
force-gamemode=false
server-ip=
network-compression-threshold=-1
max-build-height=256
spawn-npcs=true
white-list=false
spawn-animals=true
snooper-enabled=true
server-ip=SubServers::address
server-port=SubServers::port
online-mode=false
resource-pack=
pvp=true
difficulty=1
enable-query=false
broadcast-console-to-ops=false
announce-player-achievements=false
network-compression-threshold=-1
enable-command-block=true
gamemode=0
player-idle-timeout=0
max-players=20
max-tick-time=60000
spawn-monsters=true
generate-structures=true
view-distance=10
motd=Some SubServer

View File

@ -1,35 +1,10 @@
#Minecraft server properties
generator-settings=
op-permission-level=4
allow-nether=true
resource-pack-hash=
level-name=world
enable-query=false
allow-flight=false
announce-player-achievements=false
server-port=
max-world-size=29999984
level-type=DEFAULT
enable-rcon=false
level-seed=
force-gamemode=false
server-ip=
network-compression-threshold=-1
max-build-height=256
spawn-npcs=true
white-list=false
spawn-animals=true
snooper-enabled=true
server-ip=SubServers::address
server-port=SubServers::port
online-mode=false
resource-pack=
pvp=true
difficulty=1
enable-query=false
broadcast-console-to-ops=false
announce-player-achievements=false
network-compression-threshold=-1
enable-command-block=true
gamemode=0
player-idle-timeout=0
max-players=20
max-tick-time=60000
spawn-monsters=true
generate-structures=true
view-distance=10
motd=Some SubServer

View File

@ -1,134 +1,3 @@
# This is the main configuration file for Spigot.
# As you can see, there's tons to configure. Some options may impact gameplay, so use
# with caution, and make sure you know what each option does before configuring.
# For a reference for any variable inside this file, check out the Spigot wiki at
# http://www.spigotmc.org/wiki/spigot-configuration/
#
# If you need help with the configuration or have any questions related to Spigot,
# join us at the IRC or drop by our forums and leave a post.
#
# IRC: #spigot @ irc.spi.gt ( http://www.spigotmc.org/pages/irc/ )
# Forums: http://www.spigotmc.org/
config-version: 8
config-version: 4
settings:
debug: false
save-user-cache-on-stop-only: false
bungeecord: true
late-bind: false
sample-count: 12
player-shuffle: 0
filter-creative-items: true
user-cache-size: 1000
int-cache-limit: 1024
moved-wrongly-threshold: 0.0625
moved-too-quickly-threshold: 100.0
timeout-time: 60
restart-on-crash: false
restart-script: ./start.sh
netty-threads: 4
attribute:
maxHealth:
max: 2048.0
movementSpeed:
max: 2048.0
attackDamage:
max: 2048.0
commands:
tab-complete: 0
log: true
spam-exclusions:
- /skill
silent-commandblock-console: true
replace-commands:
- setblock
- summon
- testforblock
- tellraw
messages:
whitelist: You are not whitelisted on this server!
unknown-command: Unknown command. Type "/help" for help.
server-full: The server is full!
outdated-client: Outdated client! Please use {0}
outdated-server: Outdated server! I'm still on {0}
restart: Server is restarting
stats:
disable-saving: false
forced-stats: {}
world-settings:
default:
verbose: true
wither-spawn-sound-radius: 0
view-distance: 10
item-despawn-rate: 6000
merge-radius:
item: 2.5
exp: 3.0
arrow-despawn-rate: 1200
enable-zombie-pigmen-portal-spawns: true
zombie-aggressive-towards-villager: true
hanging-tick-frequency: 100
max-bulk-chunks: 10
max-entity-collisions: 8
random-light-updates: false
save-structure-info: true
mob-spawn-range: 4
anti-xray:
enabled: true
engine-mode: 1
hide-blocks:
- 14
- 15
- 16
- 21
- 48
- 49
- 54
- 56
- 73
- 74
- 82
- 129
- 130
replace-blocks:
- 1
- 5
dragon-death-sound-radius: 0
seed-village: 10387312
seed-feature: 14357617
hunger:
walk-exhaustion: 0.2
sprint-exhaustion: 0.8
combat-exhaustion: 0.3
regen-exhaustion: 3.0
max-tnt-per-tick: 100
max-tick-time:
tile: 50
entity: 50
entity-activation-range:
animals: 32
monsters: 32
misc: 16
entity-tracking-range:
players: 48
animals: 48
monsters: 48
misc: 32
other: 64
ticks-per:
hopper-transfer: 8
hopper-check: 8
hopper-amount: 1
growth:
cactus-modifier: 100
cane-modifier: 100
melon-modifier: 100
mushroom-modifier: 100
pumpkin-modifier: 100
sapling-modifier: 100
wheat-modifier: 100
netherwart-modifier: 100
nerf-spawner-mobs: false
chunks-per-tick: 650
clear-tick-list: false

View File

@ -9,4 +9,4 @@ Template:
Can-Update: true
Executable: 'bash build.sh'
Settings:
Executable: 'java -Xmx1024M -jar Paper.jar'
Executable: 'java -Xmx1024M -Dterminal.jline=false -jar Paper.jar nogui'

View File

@ -1,35 +1,10 @@
#Minecraft server properties
generator-settings=
op-permission-level=4
allow-nether=true
resource-pack-hash=
level-name=world
enable-query=false
allow-flight=false
announce-player-achievements=false
server-port=
max-world-size=29999984
level-type=DEFAULT
enable-rcon=false
level-seed=
force-gamemode=false
server-ip=
network-compression-threshold=-1
max-build-height=256
spawn-npcs=true
white-list=false
spawn-animals=true
snooper-enabled=true
server-ip=SubServers::address
server-port=SubServers::port
online-mode=false
resource-pack=
pvp=true
difficulty=1
enable-query=false
broadcast-console-to-ops=false
announce-player-achievements=false
network-compression-threshold=-1
enable-command-block=true
gamemode=0
player-idle-timeout=0
max-players=20
max-tick-time=60000
spawn-monsters=true
generate-structures=true
view-distance=10
motd=Some SubServer

View File

@ -1,134 +1,3 @@
# This is the main configuration file for Spigot.
# As you can see, there's tons to configure. Some options may impact gameplay, so use
# with caution, and make sure you know what each option does before configuring.
# For a reference for any variable inside this file, check out the Spigot wiki at
# http://www.spigotmc.org/wiki/spigot-configuration/
#
# If you need help with the configuration or have any questions related to Spigot,
# join us at the IRC or drop by our forums and leave a post.
#
# IRC: #spigot @ irc.spi.gt ( http://www.spigotmc.org/pages/irc/ )
# Forums: http://www.spigotmc.org/
config-version: 8
config-version: 4
settings:
debug: false
save-user-cache-on-stop-only: false
bungeecord: true
late-bind: false
sample-count: 12
player-shuffle: 0
filter-creative-items: true
user-cache-size: 1000
int-cache-limit: 1024
moved-wrongly-threshold: 0.0625
moved-too-quickly-threshold: 100.0
timeout-time: 60
restart-on-crash: false
restart-script: ./start.sh
netty-threads: 4
attribute:
maxHealth:
max: 2048.0
movementSpeed:
max: 2048.0
attackDamage:
max: 2048.0
commands:
tab-complete: 0
log: true
spam-exclusions:
- /skill
silent-commandblock-console: true
replace-commands:
- setblock
- summon
- testforblock
- tellraw
messages:
whitelist: You are not whitelisted on this server!
unknown-command: Unknown command. Type "/help" for help.
server-full: The server is full!
outdated-client: Outdated client! Please use {0}
outdated-server: Outdated server! I'm still on {0}
restart: Server is restarting
stats:
disable-saving: false
forced-stats: {}
world-settings:
default:
verbose: true
wither-spawn-sound-radius: 0
view-distance: 10
item-despawn-rate: 6000
merge-radius:
item: 2.5
exp: 3.0
arrow-despawn-rate: 1200
enable-zombie-pigmen-portal-spawns: true
zombie-aggressive-towards-villager: true
hanging-tick-frequency: 100
max-bulk-chunks: 10
max-entity-collisions: 8
random-light-updates: false
save-structure-info: true
mob-spawn-range: 4
anti-xray:
enabled: true
engine-mode: 1
hide-blocks:
- 14
- 15
- 16
- 21
- 48
- 49
- 54
- 56
- 73
- 74
- 82
- 129
- 130
replace-blocks:
- 1
- 5
dragon-death-sound-radius: 0
seed-village: 10387312
seed-feature: 14357617
hunger:
walk-exhaustion: 0.2
sprint-exhaustion: 0.8
combat-exhaustion: 0.3
regen-exhaustion: 3.0
max-tnt-per-tick: 100
max-tick-time:
tile: 50
entity: 50
entity-activation-range:
animals: 32
monsters: 32
misc: 16
entity-tracking-range:
players: 48
animals: 48
monsters: 48
misc: 32
other: 64
ticks-per:
hopper-transfer: 8
hopper-check: 8
hopper-amount: 1
growth:
cactus-modifier: 100
cane-modifier: 100
melon-modifier: 100
mushroom-modifier: 100
pumpkin-modifier: 100
sapling-modifier: 100
wheat-modifier: 100
netherwart-modifier: 100
nerf-spawner-mobs: false
chunks-per-tick: 650
clear-tick-list: false

View File

@ -27,7 +27,7 @@ if [[ $__RETURN -eq 0 ]]; then
rm -Rf "$0"
exit 0
else
echo ERROR: Failed downloading Sponge. Is MinecraftForge.net down?
echo ERROR: Failed downloading Sponge. Is SpongePowered.org down?
if [[ -f "Sponge.old.jar.x" ]]; then
if [[ -f "Sponge.jar" ]]; then
rm -Rf Sponge.jar

View File

@ -1,126 +1,8 @@
# 1.0
#
# # If you need help with the configuration or have any questions related to Sponge,
# # join us at the IRC or drop by our forums and leave a post.
#
# # IRC: #sponge @ irc.esper.net ( http://webchat.esper.net/?channel=sponge )
# # Forums: https://forums.spongepowered.org/
#
# 0.0
#
sponge {
block-tracking {
# If enabled, adds player tracking support for block positions. Note: This should only be disabled if you do not care who caused a block to change.
enabled=true
}
bungeecord {
# If enabled, allows BungeeCord to forward IP address, UUID, and Game Profile to this server
ip-forwarding=true
}
commands {}
debug {
# Dump chunks in the event of a deadlock
dump-chunks-on-deadlock=false
# Dump the heap in the event of a deadlock
dump-heap-on-deadlock=false
# Dump the server thread on deadlock warning
dump-threads-on-warn=false
# Enable Java's thread contention monitoring for thread dumps
thread-contention-monitoring=false
}
entity {
# Number of colliding entities in one spot before logging a warning. Set to 0 to disable
collision-warn-size=200
# Number of entities in one dimension before logging a warning. Set to 0 to disable
count-warn-size=0
# Number of ticks before a painting is respawned on clients when their art is changed
entity-painting-respawn-delay=2
# Number of ticks before the fake player entry of a human is removed from the tab list (range of 0 to 100 ticks).
human-player-list-remove-delay=10
# Controls the time in ticks for when an item despawns.
item-despawn-rate=6000
# Max size of an entity's bounding box before removing it. Set to 0 to disable
max-bounding-box-size=1000
# Square of the max speed of an entity before removing it. Set to 0 to disable
max-speed=100
}
entity-activation-range {
ambient-activation-range=32
aquatic-activation-range=32
creature-activation-range=32
minecraft {
creature {
entityhorse=true
pig=true
sheep=true
}
enabled=true
misc {
item=true
minecartchest=true
}
monster {
guardian=true
}
}
misc-activation-range=16
monster-activation-range=32
}
general {
# Forces Chunk Loading on provide requests (speedup for mods that don't check if a chunk is loaded)
chunk-load-override=false
# Disable warning messages to server admins
disable-warnings=false
}
logging {
# Log when blocks are broken
block-break=false
# Log when blocks are modified
block-modify=false
# Log when blocks are placed
block-place=false
# Log when blocks are populated in a chunk
block-populate=false
# Log when blocks are placed by players and tracked
block-tracking=false
# Log when chunks are loaded
chunk-load=false
# Log when chunks are unloaded
chunk-unload=false
# Whether to log entity collision/count checks
entity-collision-checks=false
# Log when living entities are destroyed
entity-death=false
# Log when living entities are despawned
entity-despawn=false
# Log when living entities are spawned
entity-spawn=false
# Whether to log entity removals due to speed
entity-speed-removal=false
# Add stack traces to dev logging
log-stacktraces=false
}
modules {
bungeecord=true
entity-activation-range=true
timings=true
}
# Configuration options related to the Sql service, including connection aliases etc
sql {}
timings {
enabled=true
hidden-config-entries=[
"sponge.sql"
]
history-interval=300
history-length=3600
server-name-privacy=false
verbose=false
}
world {
# Lava behaves like vanilla water when source block is removed
flowing-lava-decay=false
# Vanilla water source behavior - is infinite
infinite-water-source=false
}
}

Some files were not shown because too many files have changed in this diff Show More