Add a grace period on rogue SubServer detection

Async subdata shenanigans made rogue SubServer detection a little inacurrate. Specifically in regards to the last commit.

This is the fix to that
This commit is contained in:
ME1312 2019-08-30 15:44:54 -04:00
parent 81d37b8b1e
commit bccbfb39c9
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
66 changed files with 328 additions and 348 deletions

View File

@ -18,7 +18,7 @@ import net.ME1312.SubServers.Bungee.Network.Packet.PacketExAddServer;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExDeleteServer;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExRemoveServer;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExReset;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.BungeeCord;
import java.net.InetAddress;
@ -38,7 +38,7 @@ public class ExternalHost extends Host implements ClientHandler {
private String directory;
private LinkedList<PacketObjectOut> queue;
private boolean clean;
protected SubPlugin plugin;
protected SubProxy plugin;
/**
* Creates an External Host
@ -52,7 +52,7 @@ public class ExternalHost extends Host implements ClientHandler {
* @param directory The runtime directory of your Host
* @param gitBash The Git Bash directory
*/
public ExternalHost(SubPlugin plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
public ExternalHost(SubProxy plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
super(plugin, name, enabled, ports, log, address, directory, gitBash);
this.plugin = plugin;
this.name = name;

View File

@ -3,14 +3,12 @@ package net.ME1312.SubServers.Bungee.Host;
import com.google.common.collect.Range;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.SubData.Server.DataClient;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidHostException;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.ExtraDataHandler;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.ClientHandler;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.net.InetAddress;
import java.util.*;
@ -35,12 +33,13 @@ public abstract class Host implements ExtraDataHandler {
* @param directory The runtime directory of your Host
* @param gitBash The Git Bash directory
*/
public Host(SubPlugin plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
@SuppressWarnings("deprecation")
public Host(SubProxy plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
if (name.contains(" ")) throw new InvalidHostException("Host names cannot have spaces: " + name);
if (!ports.hasLowerBound() || !ports.hasUpperBound()) throw new InvalidHostException("Port range is not bound");
if (Util.isNull(plugin, name, enabled, ports, log, address, directory, gitBash)) throw new NullPointerException();
signature = plugin.api.signAnonymousObject();
SubAPI.getInstance().getSubDataNetwork().getProtocol().whitelist(address.getHostAddress());
SubAPI.getInstance().getInternals().subprotocol.whitelist(address.getHostAddress());
}
/**

View File

@ -13,7 +13,7 @@ import net.ME1312.SubServers.Bungee.Host.SubCreator;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.io.File;
import java.io.FileWriter;
@ -31,7 +31,7 @@ public class InternalHost extends Host {
private InetAddress address;
private SubCreator creator;
private String directory;
protected SubPlugin plugin;
protected SubProxy plugin;
/**
* Creates an Internal Host
@ -45,7 +45,7 @@ public class InternalHost extends Host {
* @param directory The runtime directory of your Host
* @param gitBash The Git Bash directory
*/
public InternalHost(SubPlugin plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
public InternalHost(SubProxy plugin, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) {
super(plugin, name, enabled, ports, log, address, directory, gitBash);
if (!DRM_ALLOW) throw new IllegalStateException("SubServers' hosting capabilities have been disabled by your provider");
this.plugin = plugin;

View File

@ -6,7 +6,6 @@ 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.Map.ObjectMapValue;
import net.ME1312.SubServers.Bungee.Event.SubCreateEvent;
import net.ME1312.SubServers.Bungee.Host.*;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
@ -16,7 +15,7 @@ import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Bungee.Library.Exception.SubCreatorException;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.ChatColor;
import java.io.*;
@ -524,11 +523,11 @@ public class InternalSubCreator extends SubCreator {
if (type == ServerType.SPIGOT) {
if (!new UniversalFile(dir, "plugins").exists()) new UniversalFile(dir, "plugins").mkdirs();
if (!new UniversalFile(dir, "plugins:SubServers.Client.jar").exists())
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(dir, "plugins:SubServers.Client.jar").getPath());
Util.copyFromJar(SubProxy.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(dir, "plugins:SubServers.Client.jar").getPath());
} else if (type == ServerType.FORGE || type == ServerType.SPONGE) {
if (!new UniversalFile(dir, "mods").exists()) new UniversalFile(dir, "mods").mkdirs();
if (!new UniversalFile(dir, "mods:SubServers.Client.jar").exists())
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(dir, "mods:SubServers.Client.jar").getPath());
Util.copyFromJar(SubProxy.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(dir, "mods:SubServers.Client.jar").getPath());
}
YAMLSection config = new YAMLSection();
FileWriter writer = new FileWriter(new UniversalFile(dir, "subdata.json"), false);

View File

@ -11,7 +11,7 @@ import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.BungeeServerInfo;
import net.md_5.bungee.api.ChatColor;
@ -79,14 +79,14 @@ public class InternalSubServer extends SubServerContainer {
if (new UniversalFile(this.directory, "plugins:SubServers.Client.jar").exists()) {
try {
JarInputStream updated = new JarInputStream(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/client.jar"));
JarInputStream updated = new JarInputStream(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/client.jar"));
JarFile existing = new JarFile(new UniversalFile(this.directory, "plugins:SubServers.Client.jar"));
if (existing.getManifest().getMainAttributes().getValue("Implementation-Title") != null && existing.getManifest().getMainAttributes().getValue("Implementation-Title").startsWith("SubServers.Client") && existing.getManifest().getMainAttributes().getValue("Specification-Title") != null &&
updated.getManifest().getMainAttributes().getValue("Implementation-Title") != null && updated.getManifest().getMainAttributes().getValue("Implementation-Title").startsWith("SubServers.Client") && updated.getManifest().getMainAttributes().getValue("Specification-Title") != null) {
if (new Version(existing.getManifest().getMainAttributes().getValue("Specification-Title")).compareTo(new Version(updated.getManifest().getMainAttributes().getValue("Specification-Title"))) < 0) {
new UniversalFile(this.directory, "plugins:SubServers.Client.jar").delete();
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(this.directory, "plugins:SubServers.Client.jar").getPath());
Util.copyFromJar(SubProxy.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(this.directory, "plugins:SubServers.Client.jar").getPath());
}
}
existing.close();
@ -97,14 +97,14 @@ public class InternalSubServer extends SubServerContainer {
}
} else if (new UniversalFile(this.directory, "mods:SubServers.Client.jar").exists()) {
try {
JarInputStream updated = new JarInputStream(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/client.jar"));
JarInputStream updated = new JarInputStream(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/client.jar"));
JarFile existing = new JarFile(new UniversalFile(this.directory, "mods:SubServers.Client.jar"));
if (existing.getManifest().getMainAttributes().getValue("Implementation-Title") != null && existing.getManifest().getMainAttributes().getValue("Implementation-Title").startsWith("SubServers.Client") && existing.getManifest().getMainAttributes().getValue("Specification-Title") != null &&
updated.getManifest().getMainAttributes().getValue("Implementation-Title") != null && updated.getManifest().getMainAttributes().getValue("Implementation-Title").startsWith("SubServers.Client") && updated.getManifest().getMainAttributes().getValue("Specification-Title") != null) {
if (new Version(existing.getManifest().getMainAttributes().getValue("Specification-Title")).compareTo(new Version(updated.getManifest().getMainAttributes().getValue("Specification-Title"))) < 0) {
new UniversalFile(this.directory, "mods:SubServers.Client.jar").delete();
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(this.directory, "mods:SubServers.Client.jar").getPath());
Util.copyFromJar(SubProxy.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/client.jar", new UniversalFile(this.directory, "mods:SubServers.Client.jar").getPath());
}
}
existing.close();

View File

@ -10,7 +10,7 @@ import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.ClientHandler;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.ProxyServer;
import java.util.*;
@ -114,7 +114,7 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
*/
@SuppressWarnings({"deprecation", "unchecked"})
public boolean isRedis() {
SubPlugin plugin = SubAPI.getInstance().getInternals();
SubProxy plugin = SubAPI.getInstance().getInternals();
return plugin.redis != null && Util.getDespiteException(() -> plugin.redis("getPlayersOnProxy", new NamedContainer<>(String.class, getName())) != null, false);
}
@ -126,7 +126,7 @@ public class Proxy implements ClientHandler, ExtraDataHandler {
@SuppressWarnings({"deprecation", "unchecked"})
public Collection<NamedContainer<String, UUID>> getPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
SubPlugin plugin = SubAPI.getInstance().getInternals();
SubProxy plugin = SubAPI.getInstance().getInternals();
if (plugin.redis != null) {
try {
for (UUID player : (Set<UUID>) plugin.redis("getPlayersOnProxy", new NamedContainer<>(String.class, getName())))

View File

@ -13,7 +13,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExRunEvent;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketOutExUpdateWhitelist;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.BungeeServerInfo;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -33,12 +33,13 @@ public class ServerContainer extends BungeeServerInfo implements Server {
private boolean hidden;
private final String signature;
@SuppressWarnings("deprecation")
public ServerContainer(String name, InetSocketAddress address, String motd, boolean hidden, boolean restricted) throws InvalidServerException {
super(name, address, motd, restricted);
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().getSubDataNetwork().getProtocol().whitelist(getAddress().getAddress().getHostAddress());
SubAPI.getInstance().getInternals().subprotocol.whitelist(getAddress().getAddress().getHostAddress());
this.hidden = hidden;
subdata.put(0, null);
@ -125,7 +126,7 @@ public class ServerContainer extends BungeeServerInfo implements Server {
@Override
public Collection<NamedContainer<String, UUID>> getGlobalPlayers() {
List<NamedContainer<String, UUID>> players = new ArrayList<NamedContainer<String, UUID>>();
SubPlugin plugin = SubAPI.getInstance().getInternals();
SubProxy plugin = SubAPI.getInstance().getInternals();
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));

View File

@ -83,7 +83,7 @@ public final class Launch {
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" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("SubServers.Bungee v" + SubProxy.version.toExtendedString() + ((SubProxy.class.getPackage().getSpecificationTitle() != null)?" (" + SubProxy.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("");
} else {
boolean gb = Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").getReturnType().equals(Class.forName("net.ME1312.Galaxi.Plugin.PluginInfo")), false);
@ -121,7 +121,7 @@ public final class Launch {
System.out.println("");
}
SubPlugin plugin = new SubPlugin(System.out, patched);
SubProxy plugin = new SubProxy(System.out, patched);
net.md_5.bungee.api.ProxyServer.class.getMethod("setInstance", net.md_5.bungee.api.ProxyServer.class).invoke(null, plugin);
if (!gb) plugin.getLogger().info("Enabled " + plugin.getBungeeName() + " version " + plugin.getVersion());
plugin.start();

View File

@ -4,20 +4,20 @@ import net.ME1312.Galaxi.Event.ConsoleInputEvent;
import net.ME1312.Galaxi.Galaxi;
import net.ME1312.Galaxi.Library.Event.ListenerOrder;
import net.ME1312.Galaxi.Library.Event.Subscribe;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
/**
* Galaxi Event Listener Class
*/
public class GalaxiEventListener {
private SubPlugin plugin;
private SubProxy plugin;
/**
* Create & Register a Galaxi Event Listener
*
* @param plugin Plugin
*/
public GalaxiEventListener(SubPlugin plugin) throws Throwable {
public GalaxiEventListener(SubProxy plugin) throws Throwable {
this.plugin = plugin;
Galaxi.getInstance().getPluginManager().registerListeners(Galaxi.getInstance().getAppInfo(), this);

View File

@ -1,9 +1,7 @@
package net.ME1312.SubServers.Bungee.Library.Compatibility;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.md_5.bungee.api.ProxyServer;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.HashMap;
import java.util.logging.Handler;
@ -14,7 +12,7 @@ import java.util.logging.LogRecord;
*/
public class Logger {
private static final HashMap<String, java.util.logging.Logger> existing = new HashMap<String, java.util.logging.Logger>();
private static SubPlugin plugin;
private static SubProxy plugin;
/**
* Get a logger

View File

@ -2,8 +2,7 @@ package net.ME1312.SubServers.Bungee.Library;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
@ -55,7 +54,7 @@ public class Metrics {
private static final String URL = "https://bStats.org/submitData/bungeecord";
// The plugin
private final SubPlugin plugin;
private final SubProxy plugin;
// Is bStats enabled on this server?
private boolean enabled;
@ -69,7 +68,7 @@ public class Metrics {
// A list with all known metrics class objects including this one
private static final List<Object> knownMetricsInstances = new ArrayList<>();
public Metrics(SubPlugin plugin) {
public Metrics(SubProxy plugin) {
this.plugin = plugin;
try {

View File

@ -5,9 +5,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.ChatColor;
import java.net.InetAddress;
@ -18,7 +16,7 @@ import java.util.UUID;
* Add Server Packet
*/
public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private int status;
private UUID tracker;
@ -28,7 +26,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
*
* @param plugin SubPlugin
*/
public PacketAddServer(SubPlugin plugin) {
public PacketAddServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -7,7 +7,7 @@ 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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -16,7 +16,7 @@ import java.util.UUID;
* Server Command Packet
*/
public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -25,7 +25,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
*
* @param plugin SubPlugin
*/
public PacketCommandServer(SubPlugin plugin) {
public PacketCommandServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.UUID;
@ -14,7 +14,7 @@ import java.util.UUID;
* Create Server Packet
*/
public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -23,7 +23,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
*
* @param plugin SubPlugin
*/
public PacketCreateServer(SubPlugin plugin) {
public PacketCreateServer(SubProxy plugin) {
this.plugin = plugin;
}

View File

@ -7,8 +7,7 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -17,7 +16,7 @@ import java.util.UUID;
* Delete Server Packet
*/
public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -26,7 +25,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
*
* @param plugin SubPlugin
*/
public PacketDeleteServer(SubPlugin plugin) {
public PacketDeleteServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.UUID;
@ -14,7 +14,7 @@ import java.util.UUID;
* Download Group Info Packet
*/
public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private String group;
private UUID tracker;
@ -23,7 +23,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
*
* @param plugin SubPlugin
*/
public PacketDownloadGroupInfo(SubPlugin plugin) {
public PacketDownloadGroupInfo(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -35,7 +35,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
* @param group Group (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadGroupInfo(SubPlugin plugin, String group, UUID tracker) {
public PacketDownloadGroupInfo(SubProxy plugin, String group, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.group = group;

View File

@ -6,7 +6,7 @@ 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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.UUID;
@ -14,7 +14,7 @@ import java.util.UUID;
* Download Host Info Packet
*/
public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private String host;
private UUID tracker;
@ -23,7 +23,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
*
* @param plugin SubPlugin
*/
public PacketDownloadHostInfo(SubPlugin plugin) {
public PacketDownloadHostInfo(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -35,7 +35,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
* @param host Host (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadHostInfo(SubPlugin plugin, String host, UUID tracker) {
public PacketDownloadHostInfo(SubProxy plugin, String host, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.host = host;

View File

@ -4,7 +4,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.LinkedHashMap;
import java.util.Map;
@ -14,7 +14,7 @@ import java.util.UUID;
* Download Lang Packet
*/
public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private UUID tracker;
/**
@ -22,7 +22,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketObject
*
* @param plugin SubPlugin
*/
public PacketDownloadLang(SubPlugin plugin) {
public PacketDownloadLang(SubProxy plugin) {
this.plugin = plugin;
}
@ -32,7 +32,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketObject
* @param plugin SubPlugin
* @param tracker Receiver ID
*/
public PacketDownloadLang(SubPlugin plugin, UUID tracker) {
public PacketDownloadLang(SubProxy plugin, UUID tracker) {
this.plugin = plugin;
this.tracker = tracker;
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.config.ListenerInfo;
import java.util.LinkedList;
@ -15,7 +15,7 @@ import java.util.UUID;
* Download Proxy Info Packet
*/
public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private UUID tracker;
/**
@ -23,7 +23,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
*
* @param plugin SubPlugin
*/
public PacketDownloadPlatformInfo(SubPlugin plugin) {
public PacketDownloadPlatformInfo(SubProxy plugin) {
this.plugin = plugin;
}
@ -33,7 +33,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
* @param plugin SubPlugin
* @param tracker Receiver ID
*/
public PacketDownloadPlatformInfo(SubPlugin plugin, UUID tracker) {
public PacketDownloadPlatformInfo(SubProxy plugin, UUID tracker) {
this.plugin = plugin;
this.tracker = tracker;
}

View File

@ -6,7 +6,7 @@ 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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.UUID;
@ -15,7 +15,7 @@ import java.util.UUID;
* Download Player List Packet
*/
public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private UUID tracker;
/**
@ -23,7 +23,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
*
* @param plugin SubPlugin
*/
public PacketDownloadPlayerList(SubPlugin plugin) {
public PacketDownloadPlayerList(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -34,7 +34,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
* @param plugin SubPlugin
* @param tracker Receiver ID
*/
public PacketDownloadPlayerList(SubPlugin plugin, UUID tracker) {
public PacketDownloadPlayerList(SubProxy plugin, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.tracker = tracker;

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.UUID;
@ -14,7 +14,7 @@ import java.util.UUID;
* Download Proxy Info Packet
*/
public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private String proxy;
private UUID tracker;
@ -23,7 +23,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
*
* @param plugin SubPlugin
*/
public PacketDownloadProxyInfo(SubPlugin plugin) {
public PacketDownloadProxyInfo(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -35,7 +35,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
* @param proxy Proxy (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadProxyInfo(SubPlugin plugin, String proxy, UUID tracker) {
public PacketDownloadProxyInfo(SubProxy plugin, String proxy, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.proxy = proxy;

View File

@ -6,7 +6,7 @@ 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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.UUID;
@ -14,7 +14,7 @@ import java.util.UUID;
* Download Server Info Packet
*/
public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private String server;
private UUID tracker;
@ -23,7 +23,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
*
* @param plugin SubPlugin
*/
public PacketDownloadServerInfo(SubPlugin plugin) {
public PacketDownloadServerInfo(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -35,7 +35,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
* @param server Server (or null for all)
* @param tracker Receiver ID
*/
public PacketDownloadServerInfo(SubPlugin plugin, String server, UUID tracker) {
public PacketDownloadServerInfo(SubProxy plugin, String server, UUID tracker) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.server = server;

View File

@ -7,8 +7,7 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -17,7 +16,7 @@ import java.util.UUID;
* Edit Server Packet
*/
public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private int status;
private UUID tracker;
@ -27,7 +26,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
*
* @param plugin SubPlugin
*/
public PacketEditServer(SubPlugin plugin) {
public PacketEditServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -3,33 +3,29 @@ package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.SubServers.Bungee.Host.External.ExternalHost;
import net.ME1312.SubServers.Bungee.Host.SubCreator;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubData.Server.Protocol.PacketIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubPlugin;
import org.msgpack.value.ValueFactory;
import java.io.*;
import net.ME1312.SubServers.Bungee.SubProxy;
/**
* External Host Configuration Packet
*/
public class PacketExConfigureHost implements PacketIn, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private ExternalHost host;
/**
* New PacketExConfigureHost (In)
*/
public PacketExConfigureHost(SubPlugin plugin) {
public PacketExConfigureHost(SubProxy plugin) {
this.plugin = plugin;
}
/**
* New PacketExConfigureHost (Out)
*/
public PacketExConfigureHost(SubPlugin plugin, ExternalHost host) {
public PacketExConfigureHost(SubProxy plugin, ExternalHost host) {
this.plugin = plugin;
this.host = host;
}

View File

@ -7,7 +7,7 @@ import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubData.Server.Protocol.PacketIn;
import net.ME1312.SubData.Server.Protocol.PacketStreamOut;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.io.*;
@ -15,20 +15,20 @@ import java.io.*;
* External Host Template Download Packet
*/
public class PacketExDownloadTemplates implements PacketIn, PacketStreamOut {
private SubPlugin plugin;
private SubProxy plugin;
private ExternalHost host;
/**
* New PacketExDownloadTemplates (In)
*/
public PacketExDownloadTemplates(SubPlugin plugin) {
public PacketExDownloadTemplates(SubProxy plugin) {
this.plugin = plugin;
}
/**
* New PacketExDownloadTemplates (Out)
*/
public PacketExDownloadTemplates(SubPlugin plugin, ExternalHost host) {
public PacketExDownloadTemplates(SubProxy plugin, ExternalHost host) {
this.plugin = plugin;
this.host = host;
}

View File

@ -5,19 +5,17 @@ import net.ME1312.SubServers.Bungee.Host.External.ExternalSubServer;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Arrays;
import java.util.UUID;
/**
* Edit External Server Packet
*/
public class PacketExEditServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private SubServer server;
private UpdateType type;
private Object[] args;
@ -55,7 +53,7 @@ public class PacketExEditServer implements PacketObjectIn<Integer>, PacketObject
* New PacketExEditServer (In)
* @param plugin SubPlugin
*/
public PacketExEditServer(SubPlugin plugin) {
public PacketExEditServer(SubProxy plugin) {
this.plugin = plugin;
}

View File

@ -4,7 +4,7 @@ import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.External.ExternalHost;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketIn;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.lang.reflect.InvocationTargetException;
@ -12,12 +12,12 @@ import java.lang.reflect.InvocationTargetException;
* External Host Queue Request Packet
*/
public class PacketInExRequestQueue implements PacketIn {
private SubPlugin plugin;
private SubProxy plugin;
/**
* New PacketInExRequestQueue
*/
public PacketInExRequestQueue(SubPlugin plugin) {
public PacketInExRequestQueue(SubProxy plugin) {
this.plugin = plugin;
}

View File

@ -3,20 +3,20 @@ package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
/**
* Reload Packet
*/
public class PacketInReload implements PacketObjectIn<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
/**
* New PacketInReload
*
* @param plugin Plugin
*/
public PacketInReload(SubPlugin plugin) {
public PacketInReload(SubProxy plugin) {
this.plugin = plugin;
}

View File

@ -6,12 +6,10 @@ import net.ME1312.SubServers.Bungee.Host.External.ExternalHost;
import net.ME1312.SubServers.Bungee.Host.Host;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.ClientHandler;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.Host.ServerContainer;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.HashMap;
import java.util.Map;
@ -20,7 +18,7 @@ import java.util.Map;
* Link External Host Packet
*/
public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private String message;
@ -29,7 +27,7 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
*
* @param plugin SubPlugin
*/
public PacketLinkExHost(SubPlugin plugin) {
public PacketLinkExHost(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -5,13 +5,11 @@ import net.ME1312.SubServers.Bungee.Event.SubAddProxyEvent;
import net.ME1312.SubServers.Bungee.Host.Proxy;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
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.ServerContainer;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.HashMap;
import java.util.Map;
@ -20,7 +18,7 @@ import java.util.Map;
* Link Proxy Packet
*/
public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private String message;
private String name;
@ -30,7 +28,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
*
* @param plugin SubPlugin
*/
public PacketLinkProxy(SubPlugin plugin) {
public PacketLinkProxy(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -1,6 +1,6 @@
package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.SubData.Server.DataClient;
import net.ME1312.SubData.Server.Library.DisconnectReason;
import net.ME1312.SubData.Server.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Event.SubStartedEvent;
@ -13,18 +13,21 @@ 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.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.SubPlugin;
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.concurrent.TimeUnit;
/**
* Link Server Packet
*/
public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private String message;
private String name;
@ -40,7 +43,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
*
* @param plugin SubPlugin
*/
public PacketLinkServer(SubPlugin plugin) {
public PacketLinkServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -105,16 +108,34 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
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+")":""));
if (server instanceof SubServer && !((SubServer) server).isRunning()) {
Logger.get("SubServers").info("Sending shutdown signal to rogue SubServer: " + server.getName());
client.sendPacket(new PacketOutExReset("Rogue SubServer Detected"));
} 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));
SubStartedEvent event = new SubStartedEvent((SubServer) server);
ProxyServer.getInstance().getPluginManager().callEvent(event);
Runnable register = () -> {
if (server instanceof SubServer && !((SubServer) server).isRunning()) {
if (((SubServer) server).getHost().isAvailable()) {
Logger.get("SubServers").info("Sending shutdown signal to rogue SubServer: " + server.getName());
client.sendPacket(new PacketOutExReset("Rogue SubServer Detected"));
} else {
// Drop connection if host is unavailable for rogue checking (try again later)
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));
SubStartedEvent event = new SubStartedEvent((SubServer) server);
ProxyServer.getInstance().getPluginManager().callEvent(event);
}
client.sendPacket(new PacketLinkServer(server.getName(), 0, null));
}
client.sendPacket(new PacketLinkServer(server.getName(), 0, null));
};
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();
}
setReady(client, true);
} else {

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubServers.Bungee.Library.SubEvent;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
@ -17,7 +17,7 @@ import java.util.List;
* Event Send Packet
*/
public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private ObjectMap<String> args;
private String type;
@ -26,7 +26,7 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
*
* @param plugin
*/
public PacketOutExRunEvent(SubPlugin plugin) {
public PacketOutExRunEvent(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -61,12 +61,14 @@ public class PacketOutExRunEvent implements Listener, PacketObjectOut<Integer> {
}
private void broadcast(Object self, PacketOutExRunEvent packet) {
List<SubDataClient> clients = new LinkedList<SubDataClient>();
clients.addAll(plugin.subdata.getClients().values());
for (SubDataClient client : clients) {
if (client.getHandler() == null || client.getHandler() != self) { // Don't send events about yourself to yourself
if (client.getHandler() == null || client.getHandler().getSubData()[0] == client) { // Don't send events over subchannels
client.sendPacket(packet);
if (plugin.subdata != null) {
List<SubDataClient> clients = new LinkedList<SubDataClient>();
clients.addAll(plugin.subdata.getClients().values());
for (SubDataClient client : clients) {
if (client.getHandler() == null || client.getHandler() != self) { // Don't send events about yourself to yourself
if (client.getHandler() == null || client.getHandler().getSubData()[0] == client) { // Don't send events over subchannels
client.sendPacket(packet);
}
}
}
}

View File

@ -8,7 +8,7 @@ import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -17,7 +17,7 @@ import java.util.UUID;
* Remove Server Packet
*/
public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -26,7 +26,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
*
* @param plugin SubPlugin
*/
public PacketRemoveServer(SubPlugin plugin) {
public PacketRemoveServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -7,7 +7,7 @@ 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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -16,7 +16,7 @@ import java.util.UUID;
* Restart Server Packet
*/
public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -25,7 +25,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
*
* @param plugin SubPlugin
*/
public PacketRestartServer(SubPlugin plugin) {
public PacketRestartServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -7,7 +7,7 @@ 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.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -16,7 +16,7 @@ import java.util.UUID;
* Start Server Packet
*/
public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private String extra;
private UUID tracker;
@ -26,7 +26,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
*
* @param plugin SubPlugin
*/
public PacketStartServer(SubPlugin plugin) {
public PacketStartServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -7,7 +7,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -16,7 +16,7 @@ import java.util.UUID;
* Stop Server Packet
*/
public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -25,7 +25,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
*
* @param plugin SubPlugin
*/
public PacketStopServer(SubPlugin plugin) {
public PacketStopServer(SubProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}

View File

@ -6,9 +6,8 @@ import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.Host.SubCreator;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.util.Map;
import java.util.UUID;
@ -17,7 +16,7 @@ import java.util.UUID;
* Update Server Packet
*/
public class PacketUpdateServer implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private SubProxy plugin;
private int response;
private UUID tracker;
@ -26,7 +25,7 @@ public class PacketUpdateServer implements PacketObjectIn<Integer>, PacketObject
*
* @param plugin SubPlugin
*/
public PacketUpdateServer(SubPlugin plugin) {
public PacketUpdateServer(SubProxy plugin) {
this.plugin = plugin;
}

View File

@ -9,7 +9,7 @@ import net.ME1312.SubServers.Bungee.Event.SubNetworkDisconnectEvent;
import net.ME1312.SubServers.Bungee.Event.SubNetworkLoginEvent;
import net.ME1312.SubServers.Bungee.Network.Packet.*;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import java.io.IOException;
import java.net.InetAddress;
@ -25,7 +25,7 @@ public class SubProtocol extends SubDataProtocol {
if (instance == null) {
instance = new SubProtocol();
log = net.ME1312.SubServers.Bungee.Library.Compatibility.Logger.get("SubData");
SubPlugin plugin = SubAPI.getInstance().getInternals();
SubProxy plugin = SubAPI.getInstance().getInternals();
plugin.getPluginManager().registerListener(null, new PacketOutExRunEvent(plugin));
instance.setName("SubServers 2");
@ -129,7 +129,7 @@ public class SubProtocol extends SubDataProtocol {
@Override
public SubDataServer open(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port, String cipher) throws IOException {
SubDataServer subdata = super.open(scheduler, logger, address, port, cipher);
SubPlugin plugin = SubAPI.getInstance().getInternals();
SubProxy plugin = SubAPI.getInstance().getInternals();
subdata.on.closed(server -> plugin.subdata = null);
subdata.on.connect(client -> {

View File

@ -30,10 +30,10 @@ public final class SubAPI {
LinkedList<Runnable> disableListeners = new LinkedList<Runnable>();
private static HashMap<String, Object> knownSignatures = new HashMap<String, Object>();
boolean ready = false;
private final SubPlugin plugin;
private final SubProxy plugin;
private static SubAPI api;
protected SubAPI(SubPlugin plugin) {
protected SubAPI(SubProxy plugin) {
this.plugin = plugin;
GAME_VERSION = getGameVersion();
api = this;
@ -55,7 +55,7 @@ public final class SubAPI {
* @return SubPlugin Internals
*/
@Deprecated
public SubPlugin getInternals() {
public SubProxy getInternals() {
return plugin;
}
@ -218,7 +218,7 @@ public final class SubAPI {
*/
public Host addHost(UUID player, Class<? extends Host> driver, String name, boolean enabled, Range<Integer> ports, boolean log, InetAddress address, String directory, String gitBash) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
if (Util.isNull(driver, name, enabled, ports, log, address, directory, gitBash)) throw new NullPointerException();
Host host = driver.getConstructor(SubPlugin.class, String.class, boolean.class, Range.class, boolean.class, InetAddress.class, String.class, String.class).newInstance(plugin, name, enabled, ports, log, address, directory, gitBash);
Host host = driver.getConstructor(SubProxy.class, String.class, boolean.class, Range.class, boolean.class, InetAddress.class, String.class, String.class).newInstance(plugin, name, enabled, ports, log, address, directory, gitBash);
return addHost(player, host)?host:null;
}
@ -664,7 +664,7 @@ public final class SubAPI {
* @return SubServers Build Signature (or null if unsigned)
*/
public Version getWrapperBuild() {
return (SubPlugin.class.getPackage().getSpecificationTitle() != null)?new Version(SubPlugin.class.getPackage().getSpecificationTitle()):null;
return (SubProxy.class.getPackage().getSpecificationTitle() != null)?new Version(SubProxy.class.getPackage().getSpecificationTitle()):null;
}
/**

View File

@ -39,10 +39,10 @@ import static net.ME1312.SubServers.Bungee.Library.Compatibility.GalaxiCommand.*
@SuppressWarnings("deprecation")
public final class SubCommand extends CommandX {
static HashMap<UUID, HashMap<ServerInfo, NamedContainer<Long, Boolean>>> players = new HashMap<UUID, HashMap<ServerInfo, NamedContainer<Long, Boolean>>>();
private SubPlugin plugin;
private SubProxy plugin;
private String label;
protected static NamedContainer<SubCommand, CommandX> newInstance(SubPlugin plugin, String command) {
protected static NamedContainer<SubCommand, CommandX> newInstance(SubProxy plugin, String command) {
NamedContainer<SubCommand, CommandX> cmd = new NamedContainer<>(new SubCommand(plugin, command), null);
CommandX now = cmd.name();
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
@ -52,7 +52,7 @@ public final class SubCommand extends CommandX {
return cmd;
}
private SubCommand(SubPlugin plugin, String command) {
private SubCommand(SubProxy plugin, String command) {
super(command);
this.plugin = plugin;
this.label = '/' + command;
@ -118,7 +118,7 @@ public final class SubCommand extends CommandX {
if (galaxi != null)
Util.isException(() -> sender.sendMessage(" GalaxiEngine v" + galaxi.toExtendedString() + ((galaxibuild != null)?" (" + galaxibuild + ')':"") + ','));
sender.sendMessage(" " + plugin.getBungeeName() + ((plugin.isGalaxi)?" v":" ") + ((bungee != null)?bungee:plugin.getVersion()) + ((bungeebuild != null)?" (" + bungeebuild + ')':"") + ((plugin.isPatched)?" [Patched]":"") + ',');
sender.sendMessage(" SubServers.Bungee v" + SubPlugin.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
sender.sendMessage(" SubServers.Bungee v" + SubProxy.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
sender.sendMessage("");
new Thread(() -> {
try {
@ -976,8 +976,8 @@ public final class SubCommand extends CommandX {
* BungeeCord /server
*/
public static final class BungeeServer extends CommandX {
private SubPlugin plugin;
private BungeeServer(SubPlugin plugin, String command) {
private SubProxy plugin;
private BungeeServer(SubProxy plugin, String command) {
super(command, "bungeecord.command.server");
this.plugin = plugin;
@ -992,7 +992,7 @@ public final class SubCommand extends CommandX {
);
}
protected static NamedContainer<BungeeServer, CommandX> newInstance(SubPlugin plugin, String command) {
protected static NamedContainer<BungeeServer, CommandX> newInstance(SubProxy plugin, String command) {
NamedContainer<BungeeServer, CommandX> cmd = new NamedContainer<>(new BungeeServer(plugin, command), null);
CommandX now = cmd.name();
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
@ -1079,8 +1079,8 @@ public final class SubCommand extends CommandX {
* BungeeCord /glist
*/
public static final class BungeeList extends Command {
private SubPlugin plugin;
protected BungeeList(SubPlugin plugin, String command) {
private SubProxy plugin;
protected BungeeList(SubProxy plugin, String command) {
super(command, "bungeecord.command.list");
this.plugin = plugin;

View File

@ -7,7 +7,6 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Plugin.PluginInfo;
import net.ME1312.SubData.Server.*;
import net.ME1312.SubData.Server.Encryption.AES;
import net.ME1312.SubData.Server.Encryption.RSA;
@ -49,14 +48,12 @@ import java.nio.file.Files;
import java.security.SecureRandom;
import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
/**
* Main Plugin Class
*/
public final class SubPlugin extends BungeeCord implements Listener {
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>>();
public final HashMap<String, Proxy> proxies = new HashMap<String, Proxy>();
@ -87,7 +84,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
private static BigInteger lastSignature = BigInteger.valueOf(-1);
@SuppressWarnings("unchecked")
protected SubPlugin(PrintStream out, boolean isPatched) throws Exception {
protected 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),
@ -99,7 +96,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
this.out = out;
if (!(new UniversalFile(dir, "config.yml").exists())) {
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/bungee.yml", new UniversalFile(dir, "config.yml").getPath());
Util.copyFromJar(SubProxy.class.getClassLoader(), "net/ME1312/SubServers/Bungee/Library/Files/bungee.yml", new UniversalFile(dir, "config.yml").getPath());
YAMLConfig tmp = new YAMLConfig(new UniversalFile("config.yml"));
tmp.get().set("stats", UUID.randomUUID().toString());
tmp.save();
@ -122,36 +119,36 @@ public final class SubPlugin extends BungeeCord implements Listener {
if (!(new UniversalFile(dir, "Templates").exists())) {
new UniversalFile(dir, "Templates").mkdirs();
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/vanilla.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/vanilla.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Created ./SubServers/Templates/Vanilla");
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/spigot.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/spigot.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Created ./SubServers/Templates/Spigot");
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/forge.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/forge.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Created ./SubServers/Templates/Forge");
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/sponge.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/sponge.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Created ./SubServers/Templates/Sponge");
} else {
if (new UniversalFile(dir, "Templates:Vanilla:template.yml").exists() && ((new YAMLConfig(new UniversalFile(dir, "Templates:Vanilla:template.yml"))).get().getVersion("Version", new Version(0))).compareTo(new Version("2.14.2a+")) != 0) {
Files.move(new UniversalFile(dir, "Templates:Vanilla").toPath(), new UniversalFile(dir, "Templates:Vanilla.old" + Math.round(Math.random() * 100000) + ".x").toPath());
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/vanilla.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/vanilla.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Updated ./SubServers/Templates/Vanilla");
}
if (new UniversalFile(dir, "Templates:Spigot:template.yml").exists() && ((new YAMLConfig(new UniversalFile(dir, "Templates:Spigot:template.yml"))).get().getVersion("Version", new Version(0))).compareTo(new Version("2.14.2a+")) != 0) {
Files.move(new UniversalFile(dir, "Templates:Spigot").toPath(), new UniversalFile(dir, "Templates:Spigot.old" + Math.round(Math.random() * 100000) + ".x").toPath());
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/spigot.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/spigot.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Updated ./SubServers/Templates/Spigot");
}
if (new UniversalFile(dir, "Templates:Forge:template.yml").exists() && ((new YAMLConfig(new UniversalFile(dir, "Templates:Forge:template.yml"))).get().getVersion("Version", new Version(0))).compareTo(new Version("2.14.2a+")) != 0) {
Files.move(new UniversalFile(dir, "Templates:Forge").toPath(), new UniversalFile(dir, "Templates:Forge.old" + Math.round(Math.random() * 100000) + ".x").toPath());
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/forge.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/forge.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Updated ./SubServers/Templates/Forge");
}
if (new UniversalFile(dir, "Templates:Sponge:template.yml").exists() && ((new YAMLConfig(new UniversalFile(dir, "Templates:Sponge:template.yml"))).get().getVersion("Version", new Version(0))).compareTo(new Version("2.14.2a+")) != 0) {
Files.move(new UniversalFile(dir, "Templates:Sponge").toPath(), new UniversalFile(dir, "Templates:Sponge.old" + Math.round(Math.random() * 100000) + ".x").toPath());
Util.unzip(SubPlugin.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/sponge.zip"), new UniversalFile(dir, "Templates"));
Util.unzip(SubProxy.class.getResourceAsStream("/net/ME1312/SubServers/Bungee/Library/Files/Templates/sponge.zip"), new UniversalFile(dir, "Templates"));
Logger.get("SubServers").info("Updated ./SubServers/Templates/Sponge");
}
}
@ -228,7 +225,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
subprotocol = SubProtocol.get();
Logger.get("SubServers").info("Loading BungeeCord Libraries...");
if (isGalaxi) Util.reflect(net.ME1312.SubServers.Bungee.Library.Compatibility.GalaxiEventListener.class.getConstructor(SubPlugin.class), this);
if (isGalaxi) Util.reflect(net.ME1312.SubServers.Bungee.Library.Compatibility.GalaxiEventListener.class.getConstructor(SubProxy.class), this);
}
/**
@ -283,63 +280,13 @@ public final class SubPlugin extends BungeeCord implements Listener {
for (String key : lang.get().getMap("Lang").getKeys())
api.setLang("SubServers", key, ChatColor.translateAlternateColorCodes('&', lang.get().getMap("Lang").getString(key)));
if (subdata == null || // SubData Server must be reset
if (subdata != null && ( // SubData Server must be reset
!config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").equals(prevconfig.getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391")) ||
!config.get().getMap("Settings").getMap("SubData").getRawString("Encryption", "NONE").equals(prevconfig.getMap("Settings").getMap("SubData").getRawString("Encryption", "NONE"))
) {
if (subdata != null) {
subdata.close();
Util.isException(subdata::waitFor);
}
subprotocol.unregisterCipher("AES");
subprotocol.unregisterCipher("AES-128");
subprotocol.unregisterCipher("AES-192");
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
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];
new SecureRandom().nextBytes(bytes);
String random = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
if (random.length() > bytes.length) random = random.substring(0, bytes.length);
config.get().getMap("Settings").getMap("SubData").set("Password", random);
config.save();
}
subprotocol.registerCipher("AES", new AES(128, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
subprotocol.registerCipher("AES-128", new AES(128, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
subprotocol.registerCipher("AES-192", new AES(192, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
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");
} 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;
if (!(new UniversalFile("SubServers:Cache").exists())) new UniversalFile("SubServers:Cache").mkdirs();
subprotocol.registerCipher("RSA", new RSA(length, new UniversalFile("SubServers:Cache:private.rsa.key"), new UniversalFile("SubServers:subdata.rsa.key")));
cipher = "RSA" + cipher.substring(ciphers[0].length());
Logger.get("SubData").info("Encrypting SubData with RSA:");
Logger.get("SubData").info("Copy your subdata.rsa.key to clients to allow them to connect");
} catch (Exception e) {
e.printStackTrace();
}
}
Logger.get("SubData").info("");
subdata = subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]), cipher);
} // Add new entries to Allowed-Connections
for (String s : config.get().getMap("Settings").getMap("SubData").getStringList("Allowed-Connections", new ArrayList<String>())) {
try {
subdata.whitelist(s);
} catch (Exception e) {
e.printStackTrace();
}
)) {
subdata.close();
Util.isException(subdata::waitFor);
subdata = null;
}
int proxies = 1;
if (redis != null) {
@ -565,6 +512,58 @@ public final class SubPlugin extends BungeeCord implements Listener {
api.ready = true;
legServers.clear();
// Initialize SubData
if (subdata == null) {
subprotocol.unregisterCipher("AES");
subprotocol.unregisterCipher("AES-128");
subprotocol.unregisterCipher("AES-192");
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
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];
new SecureRandom().nextBytes(bytes);
String random = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
if (random.length() > bytes.length) random = random.substring(0, bytes.length);
config.get().getMap("Settings").getMap("SubData").set("Password", random);
config.save();
}
subprotocol.registerCipher("AES", new AES(128, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
subprotocol.registerCipher("AES-128", new AES(128, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
subprotocol.registerCipher("AES-192", new AES(192, config.get().getMap("Settings").getMap("SubData").getRawString("Password")));
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");
} 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;
if (!(new UniversalFile("SubServers:Cache").exists())) new UniversalFile("SubServers:Cache").mkdirs();
subprotocol.registerCipher("RSA", new RSA(length, new UniversalFile("SubServers:Cache:private.rsa.key"), new UniversalFile("SubServers:subdata.rsa.key")));
cipher = "RSA" + cipher.substring(ciphers[0].length());
Logger.get("SubData").info("Encrypting SubData with RSA:");
Logger.get("SubData").info("Copy your subdata.rsa.key to clients to allow them to connect");
} catch (Exception e) {
e.printStackTrace();
}
}
Logger.get("SubData").info("");
subdata = subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]), cipher);
} // Add new entries to Allowed-Connections
for (String s : config.get().getMap("Settings").getMap("SubData").getStringList("Allowed-Connections", new ArrayList<String>())) {
try {
subdata.whitelist(s);
} catch (Exception e) {
e.printStackTrace();
}
}
int plugins = 0;
List<Runnable> listeners = (status)?api.reloadListeners:api.enableListeners;
if (listeners.size() > 0) {
@ -659,7 +658,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
/**
* Reset all changes made by startListeners
*
* @see SubPlugin#startListeners()
* @see SubProxy#startListeners()
*/
@Override
public void stopListeners() {

View File

@ -8,7 +8,7 @@ import net.ME1312.SubServers.Bungee.Host.SubCreator;
import net.ME1312.SubServers.Bungee.Host.SubServer;
import net.ME1312.Galaxi.Library.Config.YAMLConfig;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin;
import net.ME1312.SubServers.Bungee.SubProxy;
import net.ME1312.SubServers.Console.Library.Metrics;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
@ -134,7 +134,7 @@ public final class ConsolePlugin extends Plugin implements Listener {
}
@Override
public SubPlugin getProxy() {
return (SubPlugin) super.getProxy();
public SubProxy getProxy() {
return (SubProxy) super.getProxy();
}
}

View File

@ -17,8 +17,8 @@ import net.ME1312.Galaxi.Plugin.PluginInfo;
import net.ME1312.SubData.Client.Encryption.AES;
import net.ME1312.SubData.Client.Encryption.RSA;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.Executable.SubCreator;
import net.ME1312.SubServers.Host.Executable.SubLogger;
import net.ME1312.SubServers.Host.Executable.SubCreatorImpl;
import net.ME1312.SubServers.Host.Executable.SubLoggerImpl;
import net.ME1312.SubServers.Host.Executable.SubServerImpl;
import net.ME1312.SubServers.Host.Library.*;
import net.ME1312.SubServers.Host.Library.Updates.ConfigUpdater;
@ -41,9 +41,9 @@ import java.util.jar.Manifest;
public final class ExHost {
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
NamedContainer<Long, Map<String, Map<String, String>>> lang = null;
public HashMap<String, SubCreator.ServerTemplate> templates = new HashMap<String, SubCreator.ServerTemplate>();
public HashMap<String, SubCreatorImpl.ServerTemplate> templates = new HashMap<String, SubCreatorImpl.ServerTemplate>();
public HashMap<String, SubServerImpl> servers = new HashMap<String, SubServerImpl>();
public SubCreator creator;
public SubCreatorImpl creator;
public Logger log;
public PluginInfo info;
@ -186,13 +186,13 @@ public final class ExHost {
}
}
Util.reflect(SubLogger.class.getDeclaredField("logn"), null, config.get().getMap("Settings").getBoolean("Network-Log", true));
Util.reflect(SubLogger.class.getDeclaredField("logc"), null, config.get().getMap("Settings").getBoolean("Console-Log", true));
Util.reflect(SubLoggerImpl.class.getDeclaredField("logn"), null, config.get().getMap("Settings").getBoolean("Network-Log", true));
Util.reflect(SubLoggerImpl.class.getDeclaredField("logc"), null, config.get().getMap("Settings").getBoolean("Console-Log", true));
engine.getPluginManager().loadPlugins(new UniversalFile(engine.getRuntimeDirectory(), "Plugins"));
running = true;
creator = new SubCreator(this);
creator = new SubCreatorImpl(this);
subprotocol = SubProtocol.get();
loadDefaults();
reload(false);

View File

@ -8,13 +8,13 @@ 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.Host.ExHost;
import net.ME1312.SubServers.Host.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Host.Library.Exception.InvalidTemplateException;
import net.ME1312.SubServers.Host.Library.Exception.SubCreatorException;
import net.ME1312.SubServers.Host.Network.API.SubCreator.ServerType;
import net.ME1312.SubServers.Host.Network.Packet.PacketExCreateServer;
import net.ME1312.SubServers.Host.Network.Packet.PacketOutExLogMessage;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import org.json.JSONObject;
@ -27,7 +27,7 @@ import java.util.*;
/**
* Internal SubCreator Class
*/
public class SubCreator {
public class SubCreatorImpl {
private ExHost host;
private TreeMap<String, CreatorTask> thread;
@ -204,7 +204,7 @@ public class SubCreator {
private final File dir;
private final UUID address;
private final UUID tracker;
private final SubLogger log;
private final SubLoggerImpl log;
private Process process;
private CreatorTask(String name, ServerTemplate template, Version version, int port, String dir, UUID address, UUID tracker) {
@ -215,7 +215,7 @@ public class SubCreator {
this.version = version;
this.port = port;
this.dir = new File(host.host.getRawString("Directory"), dir);
this.log = new SubLogger(null, this, name + File.separator + ((update == null)?"Creator":"Updater"), address, new Container<Boolean>(true), null);
this.log = new SubLoggerImpl(null, this, name + File.separator + ((update == null)?"Creator":"Updater"), address, new Container<Boolean>(true), null);
this.address = address;
this.tracker = tracker;
}
@ -372,7 +372,7 @@ public class SubCreator {
log.logger.info.println("Couldn't build the server jar. Check the SubCreator logs for more detail.");
((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0]).sendPacket(new PacketExCreateServer(-1, "Couldn't build the server jar. Check the SubCreator logs for more detail.", tracker));
}
SubCreator.this.thread.remove(name.toLowerCase());
SubCreatorImpl.this.thread.remove(name.toLowerCase());
}
}
@ -381,7 +381,7 @@ public class SubCreator {
*
* @param host SubServers.Host
*/
public SubCreator(ExHost host) {
public SubCreatorImpl(ExHost host) {
if (Util.isNull(host)) throw new NullPointerException();
this.host = host;
this.thread = new TreeMap<>();
@ -428,8 +428,8 @@ public class SubCreator {
}
}
public List<SubLogger> getLoggers() {
List<SubLogger> loggers = new ArrayList<SubLogger>();
public List<SubLoggerImpl> getLoggers() {
List<SubLoggerImpl> loggers = new ArrayList<SubLoggerImpl>();
HashMap<String, CreatorTask> temp = new HashMap<String, CreatorTask>();
temp.putAll(thread);
for (String i : temp.keySet()) {
@ -438,7 +438,7 @@ public class SubCreator {
return loggers;
}
public SubLogger getLogger(String name) {
public SubLoggerImpl getLogger(String name) {
return this.thread.get(name).log;
}

View File

@ -1,8 +1,6 @@
package net.ME1312.SubServers.Host.Executable;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Callback.ReturnCallback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Container;
import net.ME1312.Galaxi.Library.Log.LogStream;
import net.ME1312.Galaxi.Library.Log.Logger;
@ -13,7 +11,6 @@ import net.ME1312.SubData.Client.Library.DisconnectReason;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.Library.TextColor;
import net.ME1312.SubServers.Host.Network.API.Host;
import net.ME1312.SubServers.Host.Network.Packet.PacketOutExLogMessage;
import net.ME1312.SubServers.Host.SubAPI;
@ -26,7 +23,7 @@ import java.util.regex.Pattern;
/**
* Internal Process Logger Class
*/
public class SubLogger {
public class SubLoggerImpl {
protected Process process;
private Object handle;
protected final Logger logger;
@ -52,7 +49,7 @@ public class SubLogger {
* @param log Console Logging Status
* @param file File to log to (or null for disabled)
*/
protected SubLogger(Process process, Object user, String name, UUID address, Container<Boolean> log, File file) {
protected SubLoggerImpl(Process process, Object user, String name, UUID address, Container<Boolean> log, File file) {
this.process = process;
this.handle = user;
this.logger = new Logger(name);
@ -83,16 +80,17 @@ public class SubLogger {
channel.on.closed(new Callback<NamedContainer<DisconnectReason, DataClient>>() {
@Override
public void run(NamedContainer<DisconnectReason, DataClient> client) {
if (started && SubLogger.this.process != null && process == SubLogger.this.process && process.isAlive()) {
if (started && SubLoggerImpl.this.process != null && process == SubLoggerImpl.this.process && process.isAlive()) {
int reconnect = host.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30);
if (Util.getDespiteException(() -> Util.reflect(ExHost.class.getDeclaredField("reconnect"), host), false) && reconnect > 0
&& client.name() != DisconnectReason.PROTOCOL_MISMATCH && client.name() != DisconnectReason.ENCRYPTION_MISMATCH) {
Timer timer = new Timer(SubAPI.getInstance().getAppInfo().getName() + "::Log_Reconnect_Handler");
Callback<NamedContainer<DisconnectReason, DataClient>> run = this;
reconnect++;
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (!started || SubLogger.this.process == null || process != SubLogger.this.process || !process.isAlive()) {
if (!started || SubLoggerImpl.this.process == null || process != SubLoggerImpl.this.process || !process.isAlive()) {
timer.cancel();
} else try {
channel = (SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0].newChannel();

View File

@ -5,9 +5,9 @@ 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.Host.ExHost;
import net.ME1312.SubServers.Host.Library.Exception.InvalidServerException;
import net.ME1312.SubServers.Host.Network.Packet.PacketExEditServer;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import java.io.*;
@ -29,7 +29,7 @@ public class SubServerImpl {
private File directory;
private String executable;
private Process process;
private SubLogger logger;
private SubLoggerImpl logger;
private Thread thread;
private BufferedWriter command;
private LinkedList<String> queue;
@ -59,7 +59,7 @@ public class SubServerImpl {
this.directory = new File(host.host.getRawString("Directory"), directory);
this.executable = executable;
this.process = null;
this.logger = new SubLogger(null, this, name, null, this.log, null);
this.logger = new SubLoggerImpl(null, this, name, null, this.log, null);
this.thread = null;
this.command = null;
this.queue = new LinkedList<String>();
@ -278,7 +278,7 @@ public class SubServerImpl {
/**
* Get Process Logger
*/
public SubLogger getLogger() {
public SubLoggerImpl getLogger() {
return logger;
}

View File

@ -25,7 +25,7 @@ public final class Launch {
System.out.println(">> https://github.com/ME1312/GalaxiEngine/releases");
System.exit(1);
} else {
net.ME1312.SubServers.Host.ExHost.main(args);
ExHost.main(args);
}
}
}

View File

@ -4,7 +4,6 @@ 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.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.ExHost;

View File

@ -4,12 +4,10 @@ import net.ME1312.Galaxi.Engine.GalaxiEngine;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.Executable.SubCreator;
import net.ME1312.SubServers.Host.Executable.SubCreatorImpl;
import net.ME1312.SubServers.Host.ExHost;
import java.util.Map;
@ -38,7 +36,7 @@ public class PacketExConfigureHost implements PacketObjectIn<Integer>, PacketOut
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
host.host = new ObjectMap<>((Map<String, ?>) data.getObject(0x0000));
for (SubCreator.ServerTemplate template : host.templates.values()) {
for (SubCreatorImpl.ServerTemplate template : host.templates.values()) {
Util.deleteDirectory(template.getDirectory());
}
host.templates.clear();
@ -49,7 +47,7 @@ public class PacketExConfigureHost implements PacketObjectIn<Integer>, PacketOut
for (String name : templates.getKeys()) {
try {
UniversalFile dir = new UniversalFile(templatedir, name);
SubCreator.ServerTemplate template = new SubCreator.ServerTemplate(name, templates.getMap(name).getBoolean("enabled"), templates.getMap(name).getRawString("icon"), dir,
SubCreatorImpl.ServerTemplate template = new SubCreatorImpl.ServerTemplate(name, templates.getMap(name).getBoolean("enabled"), templates.getMap(name).getRawString("icon"), dir,
templates.getMap(name).getMap("build").clone(), templates.getMap(name).getMap("settings").clone());
host.templates.put(name.toLowerCase(), template);
if (!templates.getMap(name).getRawString("display").equals(name)) template.setDisplayName(templates.getMap(name).getRawString("display"));

View File

@ -1,7 +1,6 @@
package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Engine.GalaxiEngine;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketOut;

View File

@ -5,7 +5,7 @@ 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.SubDataClient;
import net.ME1312.SubServers.Host.Executable.SubLogger;
import net.ME1312.SubServers.Host.Executable.SubLoggerImpl;
import net.ME1312.SubServers.Host.Executable.SubServerImpl;
import net.ME1312.SubServers.Host.ExHost;
@ -101,7 +101,7 @@ public class PacketExEditServer implements PacketObjectIn<Integer>, PacketObject
server.setLogging(data.getList(0x0002).get(0).asBoolean());
break;
case 6:
Util.reflect(SubLogger.class.getDeclaredField("address"), server.getLogger(), data.getList(0x0002).get(0).asUUID());
Util.reflect(SubLoggerImpl.class.getDeclaredField("address"), server.getLogger(), data.getList(0x0002).get(0).asUUID());
break;
case 7:
server.setStopCommand(data.getList(0x0002).get(0).asRawString());

View File

@ -3,7 +3,6 @@ package net.ME1312.SubServers.Host.Network.Packet;
import com.dosse.upnp.UPnP;
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.SubDataClient;

View File

@ -5,9 +5,6 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.ExHost;
import java.util.ArrayList;
import java.util.List;
/**
* Reset Packet
*/

View File

@ -3,17 +3,13 @@ package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Engine.GalaxiEngine;
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.Library.DebugUtil;
import net.ME1312.SubData.Client.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.logging.Logger;
/**

View File

@ -3,7 +3,6 @@ package net.ME1312.SubServers.Host;
import net.ME1312.Galaxi.Engine.GalaxiEngine;
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.Container;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;

View File

@ -43,7 +43,7 @@ import java.util.concurrent.TimeUnit;
/**
* Main Plugin Class
*/
public final class SubPlugin extends BungeeCord implements Listener {
public final class ExProxy extends BungeeCord implements Listener {
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
NamedContainer<Long, Map<String, Map<String, String>>> lang = null;
public final Map<String, ServerImpl> servers = new TreeMap<String, ServerImpl>();
@ -63,7 +63,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
private boolean reconnect = false;
private boolean posted = false;
protected SubPlugin(PrintStream out, boolean isPatched) throws Exception {
protected ExProxy(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),
@ -75,7 +75,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
this.out = out;
if (!(new UniversalFile(dir, "config.yml").exists())) {
Util.copyFromJar(SubPlugin.class.getClassLoader(), "net/ME1312/SubServers/Sync/Library/Files/bungee.yml", new UniversalFile(dir, "config.yml").getPath());
Util.copyFromJar(ExProxy.class.getClassLoader(), "net/ME1312/SubServers/Sync/Library/Files/bungee.yml", new UniversalFile(dir, "config.yml").getPath());
YAMLConfig tmp = new YAMLConfig(new UniversalFile("config.yml"));
tmp.get().set("stats", UUID.randomUUID().toString());
tmp.save();
@ -252,7 +252,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
/**
* Reset all changes made by startListeners
*
* @see SubPlugin#startListeners()
* @see ExProxy#startListeners()
*/
@Override
public void stopListeners() {

View File

@ -83,7 +83,7 @@ public final class Launch {
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.Sync v" + SubPlugin.version.toExtendedString() + ((SubPlugin.class.getPackage().getSpecificationTitle() != null)?" (" + SubPlugin.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("SubServers.Sync v" + ExProxy.version.toExtendedString() + ((ExProxy.class.getPackage().getSpecificationTitle() != null)?" (" + ExProxy.class.getPackage().getSpecificationTitle() + ')':""));
System.out.println("");
} else {
boolean gb = Util.getDespiteException(() -> Class.forName("net.md_5.bungee.util.GalaxiBungeeInfo").getMethod("get").getReturnType().equals(Class.forName("net.ME1312.Galaxi.Plugin.PluginInfo")), false);
@ -121,7 +121,7 @@ public final class Launch {
System.out.println("");
}
SubPlugin plugin = new SubPlugin(System.out, patched);
ExProxy plugin = new ExProxy(System.out, patched);
net.md_5.bungee.api.ProxyServer.class.getMethod("setInstance", net.md_5.bungee.api.ProxyServer.class).invoke(null, plugin);
if (!gb) plugin.getLogger().info("Enabled " + plugin.getBungeeName() + " version " + plugin.getVersion());
plugin.start();

View File

@ -1,9 +1,8 @@
package net.ME1312.SubServers.Sync.Library.Compatibility;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubServers.Sync.ExProxy;
import net.ME1312.SubServers.Sync.SubAPI;
import net.ME1312.SubServers.Sync.SubPlugin;
import net.md_5.bungee.api.ProxyServer;
import java.util.HashMap;
import java.util.logging.Handler;
@ -14,7 +13,7 @@ import java.util.logging.LogRecord;
*/
public class Logger {
private static final HashMap<String, java.util.logging.Logger> existing = new HashMap<String, java.util.logging.Logger>();
private static SubPlugin plugin;
private static ExProxy plugin;
/**
* Get a logger
@ -25,7 +24,7 @@ public class Logger {
@SuppressWarnings("deprecation")
public static java.util.logging.Logger get(String prefix) {
if (!existing.keySet().contains(prefix)) {
SubPlugin plugin = SubAPI.getInstance().getInternals();
ExProxy plugin = SubAPI.getInstance().getInternals();
java.util.logging.Logger log;
if (plugin.isGalaxi) {

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Sync.Library;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import net.ME1312.SubServers.Sync.SubPlugin;
import net.ME1312.SubServers.Sync.ExProxy;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
import net.md_5.bungee.config.YamlConfiguration;
@ -13,10 +13,8 @@ import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.GZIPOutputStream;
/**
@ -47,7 +45,7 @@ public class Metrics {
private static final String URL = "https://bStats.org/submitData/bungeecord";
// The plugin
private final SubPlugin plugin;
private final ExProxy plugin;
// Is bStats enabled on this server?
private boolean enabled;
@ -61,7 +59,7 @@ public class Metrics {
// A list with all known metrics class objects including this one
private static final List<Object> knownMetricsInstances = new ArrayList<>();
public Metrics(SubPlugin plugin) {
public Metrics(ExProxy plugin) {
this.plugin = plugin;
try {

View File

@ -6,8 +6,8 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Sync.ExProxy;
import net.ME1312.SubServers.Sync.Library.Compatibility.Logger;
import net.ME1312.SubServers.Sync.SubPlugin;
import java.util.Calendar;
@ -15,14 +15,14 @@ import java.util.Calendar;
* Download Lang Packet
*/
public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
private SubPlugin plugin;
private ExProxy plugin;
/**
* New PacketDownloadLang (In)
*
* @param plugin SubServers.Client
*/
public PacketDownloadLang(SubPlugin plugin) {
public PacketDownloadLang(ExProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -35,7 +35,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
try {
Util.reflect(SubPlugin.class.getDeclaredField("lang"), plugin, new NamedContainer<>(Calendar.getInstance().getTime().getTime(), data.getObject(0x0001)));
Util.reflect(ExProxy.class.getDeclaredField("lang"), plugin, new NamedContainer<>(Calendar.getInstance().getTime().getTime(), data.getObject(0x0001)));
Logger.get("SubData").info("Lang Settings Downloaded");
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();

View File

@ -3,10 +3,9 @@ package net.ME1312.SubServers.Sync.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.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Sync.SubPlugin;
import net.ME1312.SubServers.Sync.ExProxy;
import net.ME1312.SubServers.Sync.Event.*;
import net.md_5.bungee.api.ProxyServer;
@ -24,7 +23,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
/**
* New PacketInExRunEvent
*/
public PacketInExRunEvent(SubPlugin plugin) {
public PacketInExRunEvent(ExProxy plugin) {
callback("SubAddHostEvent", new Callback<ObjectMap<String>>() {
@Override
public void run(ObjectMap<String> data) {

View File

@ -3,18 +3,18 @@ package net.ME1312.SubServers.Sync.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Sync.SubPlugin;
import net.ME1312.SubServers.Sync.ExProxy;
/**
* Update External Whitelist Packet
*/
public class PacketInExUpdateWhitelist implements PacketObjectIn<Integer> {
private SubPlugin plugin;
private ExProxy plugin;
/**
* New PacketInExUpdateWhitelist
*/
public PacketInExUpdateWhitelist(SubPlugin plugin) {
public PacketInExUpdateWhitelist(ExProxy plugin) {
this.plugin = plugin;
}

View File

@ -6,15 +6,15 @@ import net.ME1312.SubData.Client.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubServers.Sync.ExProxy;
import net.ME1312.SubServers.Sync.Library.Compatibility.Logger;
import net.ME1312.SubServers.Sync.SubAPI;
import net.ME1312.SubServers.Sync.SubPlugin;
/**
* Link Proxy Packet
*/
public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private SubPlugin plugin;
private ExProxy plugin;
private int channel;
/**
@ -22,7 +22,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
*
* @param plugin SubServers.Client
*/
public PacketLinkProxy(SubPlugin plugin) {
public PacketLinkProxy(ExProxy plugin) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
}
@ -32,7 +32,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
* @param plugin SubServers.Client
* @param channel Channel ID
*/
public PacketLinkProxy(SubPlugin plugin, int channel) {
public PacketLinkProxy(ExProxy plugin, int channel) {
if (Util.isNull(plugin)) throw new NullPointerException();
this.plugin = plugin;
this.channel = channel;

View File

@ -9,11 +9,10 @@ import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Sync.Event.SubNetworkConnectEvent;
import net.ME1312.SubServers.Sync.Event.SubNetworkDisconnectEvent;
import net.ME1312.SubServers.Sync.ExProxy;
import net.ME1312.SubServers.Sync.Network.API.Server;
import net.ME1312.SubServers.Sync.Network.Packet.*;
import net.ME1312.SubServers.Sync.SubAPI;
import net.ME1312.SubServers.Sync.SubPlugin;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ListenerInfo;
import net.md_5.bungee.conf.Configuration;
@ -25,8 +24,6 @@ import java.util.LinkedList;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
public class SubProtocol extends SubDataProtocol {
@ -37,7 +34,7 @@ public class SubProtocol extends SubDataProtocol {
public static SubProtocol get() {
if (instance == null) {
instance = new SubProtocol();
SubPlugin plugin = SubAPI.getInstance().getInternals();
ExProxy plugin = SubAPI.getInstance().getInternals();
instance.setName("SubServers 2");
instance.addVersion(new Version("2.14a+"));
@ -111,8 +108,8 @@ public class SubProtocol extends SubDataProtocol {
@Override
protected SubDataClient sub(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port) throws IOException {
SubPlugin plugin = SubAPI.getInstance().getInternals();
HashMap<Integer, SubDataClient> map = Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("subdata"), plugin), null);
ExProxy plugin = SubAPI.getInstance().getInternals();
HashMap<Integer, SubDataClient> map = Util.getDespiteException(() -> Util.reflect(ExProxy.class.getDeclaredField("subdata"), plugin), null);
int channel = 1;
while (map.keySet().contains(channel)) channel++;
@ -129,9 +126,9 @@ public class SubProtocol extends SubDataProtocol {
@SuppressWarnings("deprecation")
@Override
public SubDataClient open(Callback<Runnable> scheduler, Logger logger, InetAddress address, int port) throws IOException {
SubPlugin plugin = SubAPI.getInstance().getInternals();
ExProxy plugin = SubAPI.getInstance().getInternals();
SubDataClient subdata = super.open(scheduler, logger, address, port);
HashMap<Integer, SubDataClient> map = Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("subdata"), plugin), null);
HashMap<Integer, SubDataClient> map = Util.getDespiteException(() -> Util.reflect(ExProxy.class.getDeclaredField("subdata"), plugin), null);
subdata.sendPacket(new PacketLinkProxy(plugin, 0));
subdata.sendPacket(new PacketDownloadLang());
@ -169,7 +166,7 @@ public class SubProtocol extends SubDataProtocol {
map.put(0, null);
int reconnect = plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30);
if (Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("reconnect"), plugin), false) && reconnect > 0
if (Util.getDespiteException(() -> Util.reflect(ExProxy.class.getDeclaredField("reconnect"), plugin), false) && reconnect > 0
&& client.name() != DisconnectReason.PROTOCOL_MISMATCH && client.name() != DisconnectReason.ENCRYPTION_MISMATCH) {
net.ME1312.SubServers.Sync.Library.Compatibility.Logger.get("SubData").info("Attempting reconnect in " + reconnect + " seconds");
Timer timer = new Timer("SubServers.Sync::SubData_Reconnect_Handler");
@ -177,7 +174,7 @@ public class SubProtocol extends SubDataProtocol {
@Override
public void run() {
try {
Util.reflect(SubPlugin.class.getDeclaredMethod("connect"), plugin);
Util.reflect(ExProxy.class.getDeclaredMethod("connect"), plugin);
timer.cancel();
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof IOException) {

View File

@ -5,7 +5,6 @@ import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataClient;
import net.ME1312.SubServers.Sync.Library.*;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubServers.Sync.Network.API.Host;
import net.ME1312.SubServers.Sync.Network.API.Proxy;
@ -25,11 +24,11 @@ import java.util.*;
public final class SubAPI {
LinkedList<Runnable> enableListeners = new LinkedList<Runnable>();
LinkedList<Runnable> disableListeners = new LinkedList<Runnable>();
private final SubPlugin plugin;
private final ExProxy plugin;
private static SubAPI api;
String name;
protected SubAPI(SubPlugin plugin) {
protected SubAPI(ExProxy plugin) {
this.plugin = plugin;
GAME_VERSION = getGameVersion();
api = this;
@ -51,7 +50,7 @@ public final class SubAPI {
* @return SubPlugin Internals
*/
@Deprecated
public SubPlugin getInternals() {
public ExProxy getInternals() {
return plugin;
}
@ -636,7 +635,7 @@ public final class SubAPI {
* @return SubServers Build Signature (or null if unsigned)
*/
public Version getWrapperBuild() {
return (SubPlugin.class.getPackage().getSpecificationTitle() != null)?new Version(SubPlugin.class.getPackage().getSpecificationTitle()):null;
return (ExProxy.class.getPackage().getSpecificationTitle() != null)?new Version(ExProxy.class.getPackage().getSpecificationTitle()):null;
}
/**

View File

@ -41,10 +41,10 @@ public final class SubCommand extends CommandX {
private TreeMap<String, List<String>> hostCache = new TreeMap<String, List<String>>();
private LinkedList<String> groupCache = new LinkedList<String>();
private long cacheDate = 0;
private SubPlugin plugin;
private ExProxy plugin;
private String label;
protected static NamedContainer<SubCommand, CommandX> newInstance(SubPlugin plugin, String command) {
protected static NamedContainer<SubCommand, CommandX> newInstance(ExProxy plugin, String command) {
NamedContainer<SubCommand, CommandX> cmd = new NamedContainer<>(new SubCommand(plugin, command), null);
CommandX now = cmd.name();
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
@ -54,7 +54,7 @@ public final class SubCommand extends CommandX {
return cmd;
}
private SubCommand(SubPlugin plugin, String command) {
private SubCommand(ExProxy plugin, String command) {
super(command);
this.plugin = plugin;
this.label = '/' + command;
@ -119,7 +119,7 @@ public final class SubCommand extends CommandX {
if (galaxi != null)
Util.isException(() -> sender.sendMessage("GalaxiEngine v" + galaxi.toExtendedString() + ((galaxibuild != null)?" (" + galaxibuild + ')':"") + ','));
sender.sendMessage(" " + plugin.getBungeeName() + ((plugin.isGalaxi)?" v":" ") + ((bungee != null)?bungee:plugin.getVersion()) + ((bungeebuild != null)?" (" + bungeebuild + ')':"") + ((plugin.isPatched)?" [Patched]":"") + ',');
sender.sendMessage(" SubServers.Sync v" + SubPlugin.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
sender.sendMessage(" SubServers.Sync v" + ExProxy.version.toExtendedString() + ((plugin.api.getWrapperBuild() != null)?" (" + plugin.api.getWrapperBuild() + ')':""));
sender.sendMessage("");
new Thread(() -> {
try {
@ -948,8 +948,8 @@ public final class SubCommand extends CommandX {
*/
@SuppressWarnings("unchecked")
public static final class BungeeServer extends CommandX {
private SubPlugin plugin;
private BungeeServer(SubPlugin plugin, String command) {
private ExProxy plugin;
private BungeeServer(ExProxy plugin, String command) {
super(command, "bungeecord.command.server");
this.plugin = plugin;
@ -964,7 +964,7 @@ public final class SubCommand extends CommandX {
);
}
protected static NamedContainer<BungeeServer, CommandX> newInstance(SubPlugin plugin, String command) {
protected static NamedContainer<BungeeServer, CommandX> newInstance(ExProxy plugin, String command) {
NamedContainer<BungeeServer, CommandX> cmd = new NamedContainer<>(new BungeeServer(plugin, command), null);
CommandX now = cmd.name();
//if (plugin.api.getGameVersion()[plugin.api.getGameVersion().length - 1].compareTo(new Version("1.13")) >= 0) { // TODO Future Command Validator API?
@ -1052,8 +1052,8 @@ public final class SubCommand extends CommandX {
*/
@SuppressWarnings("unchecked")
public static final class BungeeList extends Command {
private SubPlugin plugin;
protected BungeeList(SubPlugin plugin, String command) {
private ExProxy plugin;
protected BungeeList(ExProxy plugin, String command) {
super(command, "bungeecord.command.list");
this.plugin = plugin;