diff --git a/.gitignore b/.gitignore index 718edfc6..5c239915 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,9 @@ crashlytics-build.properties # Hide Unfinished Project Files /Artifacts/SubServers.Test.jar +/Artifacts/SubServers.Web.jar /SubServers.Test/ +/SubServers.Web/ # Hide Others /build.ant diff --git a/Artifacts/SubServers.Bungee.jar b/Artifacts/SubServers.Bungee.jar index 2b631569..ad69517d 100644 Binary files a/Artifacts/SubServers.Bungee.jar and b/Artifacts/SubServers.Bungee.jar differ diff --git a/Artifacts/SubServers.Client.Bukkit.jar b/Artifacts/SubServers.Client.Bukkit.jar index 6837dc78..348e27ff 100644 Binary files a/Artifacts/SubServers.Client.Bukkit.jar and b/Artifacts/SubServers.Client.Bukkit.jar differ diff --git a/Artifacts/SubServers.Console.jar b/Artifacts/SubServers.Console.jar index 9a431cf0..5338d636 100644 Binary files a/Artifacts/SubServers.Console.jar and b/Artifacts/SubServers.Console.jar differ diff --git a/Artifacts/SubServers.Host.jar b/Artifacts/SubServers.Host.jar index b8e46a76..2b1b3bdb 100644 Binary files a/Artifacts/SubServers.Host.jar and b/Artifacts/SubServers.Host.jar differ diff --git a/Javadoc/SubServers.Client.Bukkit/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.html b/Javadoc/SubServers.Client.Bukkit/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.html index acef94a6..c77004aa 100644 --- a/Javadoc/SubServers.Client.Bukkit/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.html +++ b/Javadoc/SubServers.Client.Bukkit/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.html @@ -243,7 +243,7 @@ extends java.lang.Object
Parameters:
plugin - SubPlugin
-
address - Bind Address
+
address - Address
port - Port
Throws:
java.io.IOException
diff --git a/Javadoc/SubServers.Host/net/ME1312/SubServers/Host/Network/SubDataClient.html b/Javadoc/SubServers.Host/net/ME1312/SubServers/Host/Network/SubDataClient.html index db7e55d7..aca37acb 100644 --- a/Javadoc/SubServers.Host/net/ME1312/SubServers/Host/Network/SubDataClient.html +++ b/Javadoc/SubServers.Host/net/ME1312/SubServers/Host/Network/SubDataClient.html @@ -242,8 +242,8 @@ extends java.lang.Object
SubServers Client Instance
Parameters:
-
host - SubPlugin
-
address - Bind Address
+
host - SubServers.Host
+
address - Address
port - Port
Throws:
java.io.IOException
diff --git a/SubServers.Bungee/META-INF/MANIFEST.MF b/SubServers.Bungee/META-INF/MANIFEST.MF index dc1c5a0b..75924a6d 100644 --- a/SubServers.Bungee/META-INF/MANIFEST.MF +++ b/SubServers.Bungee/META-INF/MANIFEST.MF @@ -1,5 +1,5 @@ Manifest-Version: 1.0 Class-Path: BungeeCord.jar Main-Class: net.ME1312.SubServers.Bungee.Launch -Implementation-Version: 2.11.2i -Specification-Version: 0 +Implementation-Version: 2.11.2j +Specification-Version: 1 diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java index 65715d47..eb41645c 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Host.java @@ -33,6 +33,7 @@ public abstract class Host implements ExtraDataHandler { */ public Host(SubPlugin plugin, String name, Boolean enabled, InetAddress address, String directory, String gitBash) { if (name.contains(" ")) throw new InvalidHostException("Host names cannot have spaces: " + name); + if (name.equals("~")) setDisplayName("Default"); } /** diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Client.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Client.java index 6bad1c27..ec3d2d98 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Client.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Client.java @@ -27,8 +27,7 @@ public class Client { private ClientHandler handler; private PrintWriter writer; private Timer authorized; - private SubDataServer subdata; - private Client instance; + protected SubDataServer subdata; /** * Network Client @@ -42,13 +41,12 @@ public class Client { socket = client; writer = new PrintWriter(client.getOutputStream(), true); address = new InetSocketAddress(client.getInetAddress(), client.getPort()); - instance = this; authorized = new Timer("__subdata_auth_" + client.getRemoteSocketAddress().toString()); authorized.schedule(new TimerTask() { @Override public void run() { if (!socket.isClosed()) try { - subdata.removeClient(instance); + subdata.removeClient(Client.this); } catch (IOException e) { e.printStackTrace(); } @@ -66,32 +64,17 @@ public class Client { BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); String input; while ((input = in.readLine()) != null) { - try { - JSONObject json = new JSONObject(input); - for (PacketIn packet : SubDataServer.decodePacket(json)) { - if (authorized == null || packet instanceof PacketAuthorization) { - try { - packet.execute(instance, (json.keySet().contains("c")) ? json.getJSONObject("c") : null); - } catch (Throwable e) { - new InvocationTargetException(e, "Exception while executing PacketIn").printStackTrace(); - } - } else sendPacket(new PacketAuthorization(-1, "Unauthorized")); - } - } catch (IllegalPacketException e) { - e.printStackTrace(); - } catch (JSONException e) { - new IllegalPacketException("Unknown Packet Format: " + input).printStackTrace(); - } + recievePacket(input); } try { - subdata.removeClient(instance); + subdata.removeClient(Client.this); } catch (IOException e1) { e1.printStackTrace(); } } catch (Exception e) { if (!(e instanceof SocketException)) e.printStackTrace(); try { - subdata.removeClient(instance); + subdata.removeClient(Client.this); } catch (IOException e1) { e1.printStackTrace(); } @@ -110,6 +93,25 @@ public class Client { authorized = null; } + protected void recievePacket(String raw) { + try { + JSONObject json = new JSONObject(raw); + for (PacketIn packet : SubDataServer.decodePacket(json)) { + if (authorized == null || packet instanceof PacketAuthorization) { + try { + packet.execute(Client.this, (json.keySet().contains("c")) ? json.getJSONObject("c") : null); + } catch (Throwable e) { + new InvocationTargetException(e, "Exception while executing PacketIn").printStackTrace(); + } + } else sendPacket(new PacketAuthorization(-1, "Unauthorized")); + } + } catch (IllegalPacketException e) { + e.printStackTrace(); + } catch (JSONException e) { + new IllegalPacketException("Unknown Packet Format: " + raw).printStackTrace(); + } + } + /** * Send Packet to Client * diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadProxyInfo.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadProxyInfo.java new file mode 100644 index 00000000..e4336489 --- /dev/null +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadProxyInfo.java @@ -0,0 +1,76 @@ +package net.ME1312.SubServers.Bungee.Network.Packet; + +import net.ME1312.SubServers.Bungee.Library.Version.Version; +import net.ME1312.SubServers.Bungee.Network.Client; +import net.ME1312.SubServers.Bungee.Network.PacketIn; +import net.ME1312.SubServers.Bungee.Network.PacketOut; +import net.ME1312.SubServers.Bungee.SubPlugin; +import org.json.JSONObject; + +/** + * Download Proxy Info Packet + */ +public class PacketDownloadProxyInfo implements PacketIn, PacketOut { + private SubPlugin plugin; + private String id; + + /** + * New PacketDownloadProxyInfo (In) + * + * @param plugin SubPlugin + */ + public PacketDownloadProxyInfo(SubPlugin plugin) { + this.plugin = plugin; + } + + /** + * New PacketDownloadProxyInfo (Out) + * + * @param plugin SubPlugin + * @param id Receiver ID + */ + public PacketDownloadProxyInfo(SubPlugin plugin, String id) { + this.plugin = plugin; + this.id = id; + } + + @Override + public JSONObject generate() { + JSONObject json = new JSONObject(); + if (id != null) json.put("id", id); + JSONObject subservers = new JSONObject(); + subservers.put("version", plugin.version.toString()); + if (plugin.bversion != null) subservers.put("beta", plugin.bversion.toString()); + subservers.put("hosts", plugin.api.getHosts().size()); + subservers.put("subservers", plugin.api.getSubServers().size()); + json.put("subservers", subservers); + JSONObject bungee = new JSONObject(); + bungee.put("version", plugin.api.getProxyVersion()); + bungee.put("servers", plugin.api.getServers().size()); + json.put("bungee", bungee); + JSONObject minecraft = new JSONObject(); + minecraft.put("version", plugin.api.getGameVersion()); + minecraft.put("players", plugin.getPlayers().size()); + json.put("minecraft", minecraft); + JSONObject system = new JSONObject(); + JSONObject os = new JSONObject(); + os.put("name", System.getProperty("os.name")); + os.put("version", System.getProperty("os.version")); + system.put("os", os); + JSONObject java = new JSONObject(); + java.put("version", System.getProperty("java.version")); + system.put("java", java); + json.put("system", system); + return json; + } + + @Override + public void execute(Client client, JSONObject data) { + client.sendPacket(new PacketDownloadProxyInfo(plugin, (data != null && data.keySet().contains("id"))?data.getString("id"):null)); + } + + @Override + public Version getVersion() { + return new Version("2.11.0a"); + } +} diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadServerInfo.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadServerInfo.java index 9725045f..32cae955 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadServerInfo.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketDownloadServerInfo.java @@ -37,7 +37,7 @@ public class PacketDownloadServerInfo implements PacketIn, PacketOut { * @param id Receiver ID */ public PacketDownloadServerInfo(SubPlugin plugin, Server server, String id) { - if (Util.isNull(plugin, server)) throw new NullPointerException(); + if (Util.isNull(plugin)) throw new NullPointerException(); this.plugin = plugin; this.server = server; this.id = id; diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketOutRunEvent.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketOutRunEvent.java index b574ce67..d6077be7 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketOutRunEvent.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/Packet/PacketOutRunEvent.java @@ -65,105 +65,72 @@ public class PacketOutRunEvent implements Listener, PacketOut { @EventHandler(priority = EventPriority.HIGHEST) public void event(SubAddServerEvent event) { if (!event.isCancelled()) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); - args.put("host", ((event.getHost() == null)?null:event.getHost())); - args.put("server", event.getServer().getName()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); + args.put("host", ((event.getHost() == null)?null:event.getHost())); + args.put("server", event.getServer().getName()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); } } @EventHandler(priority = EventPriority.HIGHEST) public void event(SubCreateEvent event) { if (!event.isCancelled()) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); - args.put("host", event.getHost().getName()); - args.put("name", event.getName()); - args.put("type", event.getType().toString()); - args.put("version", event.getVersion().toString()); - args.put("port", event.getPort()); - args.put("memory", event.getMemory()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); + args.put("host", event.getHost().getName()); + args.put("name", event.getName()); + args.put("type", event.getType().toString()); + args.put("version", event.getVersion().toString()); + args.put("port", event.getPort()); + args.put("memory", event.getMemory()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); } } @EventHandler(priority = EventPriority.HIGHEST) public void event(SubSendCommandEvent event) { if (!event.isCancelled()) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); - args.put("server", event.getServer().getName()); - args.put("command", event.getCommand()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); + args.put("server", event.getServer().getName()); + args.put("command", event.getCommand()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); } } @EventHandler(priority = EventPriority.HIGHEST) public void event(SubStartEvent event) { if (!event.isCancelled()) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); - args.put("server", event.getServer().getName()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); + args.put("server", event.getServer().getName()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); } } @EventHandler(priority = EventPriority.HIGHEST) public void event(SubStopEvent event) { if (!event.isCancelled()) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); - args.put("server", event.getServer().getName()); - args.put("force", event.isForced()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); + args.put("server", event.getServer().getName()); + args.put("force", event.isForced()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); + } } @EventHandler(priority = EventPriority.HIGHEST) public void event(SubStoppedEvent event) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("server", event.getServer().getName()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("server", event.getServer().getName()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); + } @EventHandler(priority = EventPriority.HIGHEST) public void event(SubRemoveServerEvent event) { if (!event.isCancelled()) { - List list = new ArrayList(); - list.addAll(plugin.api.getServers().values()); - for (Host host : plugin.api.getHosts().values()) if (host instanceof ClientHandler) list.add((ClientHandler) host); - for (ClientHandler client : list) { - JSONObject args = new JSONObject(); - args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); - args.put("host", ((event.getHost() == null)?null:event.getHost())); - args.put("server", event.getServer().getName()); - if (client.getSubDataClient() != null) client.getSubDataClient().sendPacket(new PacketOutRunEvent(event.getClass(), args)); - } + JSONObject args = new JSONObject(); + args.put("player", ((event.getPlayer() == null)?null:event.getPlayer().toString())); + args.put("host", ((event.getHost() == null)?null:event.getHost())); + args.put("server", event.getServer().getName()); + plugin.subdata.broadcastPacket(new PacketOutRunEvent(event.getClass(), args)); } } } \ No newline at end of file diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/SubDataServer.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/SubDataServer.java index a2273347..1866bf7f 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/SubDataServer.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/SubDataServer.java @@ -7,12 +7,15 @@ import net.ME1312.SubServers.Bungee.Network.Packet.*; import net.ME1312.SubServers.Bungee.SubPlugin; import org.json.JSONObject; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.net.*; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; +import java.util.regex.Pattern; /** * SubDataServer Class @@ -68,6 +71,7 @@ public final class SubDataServer { registerPacket(new PacketDownloadHostInfo(plugin), "SubDownloadHostInfo"); registerPacket(new PacketDownloadLang(plugin), "SubDownloadLang"); registerPacket(new PacketDownloadPlayerList(plugin), "SubDownloadPlayerList"); + registerPacket(new PacketDownloadProxyInfo(plugin), "SubDownloadProxyInfo"); registerPacket(new PacketDownloadServerInfo(plugin), "SubDownloadServerInfo"); registerPacket(new PacketDownloadServerList(plugin), "SubDownloadServerList"); registerPacket(new PacketExAddServer(), "SubExAddServer"); @@ -91,6 +95,7 @@ public final class SubDataServer { registerPacket(PacketDownloadHostInfo.class, "SubDownloadHostInfo"); registerPacket(PacketDownloadLang.class, "SubDownloadLang"); registerPacket(PacketDownloadPlayerList.class, "SubDownloadPlayerList"); + registerPacket(PacketDownloadProxyInfo.class, "SubDownloadProxyInfo"); registerPacket(PacketDownloadServerInfo.class, "SubDownloadServerInfo"); registerPacket(PacketDownloadServerList.class, "SubDownloadServerList"); registerPacket(PacketExAddServer.class, "SubExAddServer"); @@ -131,7 +136,7 @@ public final class SubDataServer { clients.put(client.getAddress(), client); return client; } else { - System.out.println("SubData > " + socket.getInetAddress().toString() + ":" + socket.getPort() + " attempted to connect, but isn't whitelisted"); + System.out.println("SubData > " + socket.getInetAddress().toString() + " attempted to connect, but isn't white-listed"); socket.close(); return null; } diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java index 9bb461c8..c965938e 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/SubPlugin.java @@ -173,7 +173,7 @@ public final class SubPlugin extends BungeeCord { lang = new YAMLConfig(new UniversalFile(dir, "SubServers:lang.yml")); subdata = new SubDataServer(this, Integer.parseInt(config.get().getSection("Settings").getSection("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]), 10, (config.get().getSection("Settings").getSection("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?null:InetAddress.getByName(config.get().getSection("Settings").getSection("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0])); - System.out.println("SubServers > SubData Listening on /" + config.get().getSection("Settings").getSection("SubData").getRawString("Address", "127.0.0.1:4391")); + System.out.println("SubServers > SubData Direct Listening on /" + config.get().getSection("Settings").getSection("SubData").getRawString("Address", "127.0.0.1:4391")); loop(); int hosts = 0; diff --git a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.java b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.java index ce87f1dc..b6b4fe2b 100644 --- a/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.java +++ b/SubServers.Client/Bukkit/src/net/ME1312/SubServers/Client/Bukkit/Network/SubDataClient.java @@ -39,7 +39,7 @@ public final class SubDataClient { * SubServers Client Instance * * @param plugin SubPlugin - * @param address Bind Address + * @param address Address * @param port Port * @throws IOException */ @@ -275,7 +275,7 @@ public final class SubDataClient { Bukkit.getLogger().info("SubServers > The SubData Connection was closed"); if (reconnect) { Bukkit.getLogger().info("SubServers > Attempting to reconnect in 10 seconds"); - Bukkit.getScheduler().runTaskLater(plugin, new Runnable() { + Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { @Override public void run() { try { diff --git a/SubServers.Client/Bukkit/src/plugin.yml b/SubServers.Client/Bukkit/src/plugin.yml index 66f901b9..750ff379 100644 --- a/SubServers.Client/Bukkit/src/plugin.yml +++ b/SubServers.Client/Bukkit/src/plugin.yml @@ -1,4 +1,4 @@ -name: 'SubServers' +name: 'SubServers-Client-Bukkit' main: 'net.ME1312.SubServers.Client.Bukkit.SubPlugin' version: '2.11.2e' authors: [ME1312] diff --git a/SubServers.Console/src/net/ME1312/SubServers/Console/ConsolePlugin.java b/SubServers.Console/src/net/ME1312/SubServers/Console/ConsolePlugin.java index 3d922827..a36aaa81 100644 --- a/SubServers.Console/src/net/ME1312/SubServers/Console/ConsolePlugin.java +++ b/SubServers.Console/src/net/ME1312/SubServers/Console/ConsolePlugin.java @@ -7,6 +7,7 @@ import net.ME1312.SubServers.Bungee.Host.Host; import net.ME1312.SubServers.Bungee.Host.SubCreator; import net.ME1312.SubServers.Bungee.Host.SubServer; import net.ME1312.SubServers.Bungee.Library.Config.YAMLConfig; +import net.ME1312.SubServers.Bungee.SubAPI; import net.ME1312.SubServers.Bungee.SubPlugin; import net.md_5.bungee.api.plugin.Listener; import net.md_5.bungee.api.plugin.Plugin; @@ -26,6 +27,10 @@ public final class ConsolePlugin extends Plugin implements Listener { @Override public void onEnable() { + SubAPI.getInstance().addListener(this::enable, this::disable); + } + + public void enable() { try {this. getDataFolder().mkdirs(); config = new YAMLConfig(new File(getDataFolder(), "config.yml")); @@ -102,8 +107,7 @@ public final class ConsolePlugin extends Plugin implements Listener { } } - @Override - public void onDisable() { + public void disable() { for (ConsoleWindow window : sCurrent.values()) { window.destroy(); } diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/Library/Log/SystemLogger.java b/SubServers.Host/src/net/ME1312/SubServers/Host/Library/Log/SystemLogger.java index 8fa959de..639af0fe 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/Library/Log/SystemLogger.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/Library/Log/SystemLogger.java @@ -1,23 +1,24 @@ package net.ME1312.SubServers.Host.Library.Log; +import net.ME1312.SubServers.Host.Library.NamedContainer; + import java.io.File; import java.io.IOException; import java.io.OutputStream; -import java.util.HashMap; /** * System.out and System.err Override Class */ public final class SystemLogger extends OutputStream { - private HashMap stream = new HashMap(); - private boolean level; + private NamedContainer last = new NamedContainer("", null); + private boolean error; private File dir; protected SystemLogger(boolean level, File dir) throws IOException { if (!new File(dir, SystemLogger.class.getCanonicalName().replace(".", File.separator) + ".class").exists()) { throw new IOException("Invalid directory for logging:" + dir.getPath()); } - this.level = level; + this.error = level; this.dir = dir; } @@ -32,11 +33,11 @@ public final class SystemLogger extends OutputStream { } i++; } - if (!stream.keySet().contains(origin)) stream.put(origin, new Logger(origin)); - if (level) { - stream.get(origin).error.print((char) c); + if (!last.name().equals(origin)) last = new NamedContainer(origin, new Logger(origin)); + if (error) { + last.get().error.print((char) c); } else { - stream.get(origin).info.print((char) c); + last.get().info.print((char) c); } } } diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/Network/SubDataClient.java b/SubServers.Host/src/net/ME1312/SubServers/Host/Network/SubDataClient.java index 171b5ef3..7e5ce1bc 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/Network/SubDataClient.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/Network/SubDataClient.java @@ -38,8 +38,8 @@ public final class SubDataClient { /** * SubServers Client Instance * - * @param host SubPlugin - * @param address Bind Address + * @param host SubServers.Host + * @param address Address * @param port Port * @throws IOException */