diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/External/ExternalSubServer.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/External/ExternalSubServer.java index 751a46dc..600ff657 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/External/ExternalSubServer.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/External/ExternalSubServer.java @@ -35,6 +35,7 @@ public class ExternalSubServer extends SubServerContainer { private boolean restart; private boolean temporary; private boolean running; + private boolean lock; /** * Creates an External SubServer @@ -68,13 +69,16 @@ public ExternalSubServer(ExternalHost host, String name, boolean enabled, int po this.running = false; this.temporary = false; + this.lock = false; } @Override public boolean start(UUID player) { - if (isEnabled() && !running && getCurrentIncompatibilities().size() == 0) { + if (!lock && isEnabled() && !running && getCurrentIncompatibilities().size() == 0) { + lock = true; SubStartEvent event = new SubStartEvent(player, this); host.plugin.getPluginManager().callEvent(event); + lock = false; if (!event.isCancelled()) { System.out.println("SubServers > Now starting " + getName()); running = true; diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubServer.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubServer.java index 04104bbc..9f810335 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubServer.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubServer.java @@ -42,6 +42,7 @@ public class InternalSubServer extends SubServerContainer { private boolean restart; private boolean allowrestart; private boolean temporary; + private boolean lock; /** * Creates an Internal SubServer @@ -57,12 +58,11 @@ public class InternalSubServer extends SubServerContainer { * @param stopcmd Stop Command * @param hidden Hidden Status * @param restricted Restricted Status - * @param temporary Temporary Status * @throws InvalidServerException */ - public InternalSubServer(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted, boolean temporary) throws InvalidServerException { + public InternalSubServer(InternalHost host, String name, boolean enabled, int port, String motd, boolean log, String directory, Executable executable, String stopcmd, boolean hidden, boolean restricted) throws InvalidServerException { super(host, name, port, motd, hidden, restricted); - if (Util.isNull(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted, temporary)) throw new NullPointerException(); + if (Util.isNull(host, name, enabled, port, motd, log, directory, executable, stopcmd, hidden, restricted)) throw new NullPointerException(); this.host = host; this.enabled = enabled; this.editable = false; @@ -115,7 +115,8 @@ public InternalSubServer(InternalHost host, String name, boolean enabled, int po e.printStackTrace(); } } - this.temporary = temporary && start(); + this.temporary = false; + this.lock = false; } private void run() { @@ -169,9 +170,11 @@ private void run() { @Override public boolean start(UUID player) { - if (isEnabled() && !(thread != null && thread.isAlive()) && getCurrentIncompatibilities().size() == 0) { + if (!lock && isEnabled() && !(thread != null && thread.isAlive()) && getCurrentIncompatibilities().size() == 0) { + lock = true; SubStartEvent event = new SubStartEvent(player, this); host.plugin.getPluginManager().callEvent(event); + lock = false; if (!event.isCancelled()) { (thread = new Thread(this::run)).start(); return true; 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 d128eb15..7808501c 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/SubDataServer.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Network/SubDataServer.java @@ -303,7 +303,7 @@ public void removeClient(String address) throws IOException { * @param handle Handle to Bind */ public static void registerPacket(PacketIn packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); HashMap> map = (pIn.keySet().contains(channel.toLowerCase()))?pIn.get(channel.toLowerCase()):new HashMap>(); List list = (map.keySet().contains(handle))?map.get(handle):new ArrayList(); if (!list.contains(packet)) { @@ -320,7 +320,7 @@ public static void registerPacket(PacketIn packet, String channel, String handle * @param packet PacketIn to unregister */ public static void unregisterPacket(String channel, PacketIn packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pIn.keySet().contains(channel.toLowerCase())) { List search = new ArrayList(); search.addAll(pIn.get(channel.toLowerCase()).keySet()); @@ -345,7 +345,7 @@ public static void unregisterPacket(String channel, PacketIn packet) { * @param handle Handle to bind */ public static void registerPacket(Class packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); pOut.put(packet, new NamedContainer(channel.toLowerCase(), handle)); } @@ -356,7 +356,7 @@ public static void registerPacket(Class packet, String chan * @param packet PacketOut to unregister */ public static void unregisterPacket(String channel, Class packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pOut.keySet().contains(packet) && pOut.get(packet).name().equalsIgnoreCase(channel)) pOut.remove(packet); } @@ -368,7 +368,7 @@ public static void unregisterPacket(String channel, Class p * @return PacketIn */ public static List getPacket(String channel, String handle) { - if (Util.isNull(handle)) throw new NullPointerException(); + if (Util.isNull(channel, handle)) throw new NullPointerException(); return new ArrayList(pIn.get(channel.toLowerCase()).get(handle)); } 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 9a7e819e..a3a39b95 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 @@ -234,7 +234,7 @@ public static Cipher getCipher(String handle) { * @param handle Handle to Bind */ public static void registerPacket(PacketIn packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); HashMap> map = (pIn.keySet().contains(channel.toLowerCase()))?pIn.get(channel.toLowerCase()):new HashMap>(); List list = (map.keySet().contains(handle))?map.get(handle):new ArrayList(); if (!list.contains(packet)) { @@ -251,7 +251,7 @@ public static void registerPacket(PacketIn packet, String channel, String handle * @param packet PacketIn to unregister */ public static void unregisterPacket(String channel, PacketIn packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pIn.keySet().contains(channel.toLowerCase())) { List search = new ArrayList(); search.addAll(pIn.get(channel.toLowerCase()).keySet()); @@ -276,7 +276,7 @@ public static void unregisterPacket(String channel, PacketIn packet) { * @param handle Handle to bind */ public static void registerPacket(Class packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); pOut.put(packet, new NamedContainer(channel.toLowerCase(), handle)); } @@ -287,7 +287,7 @@ public static void registerPacket(Class packet, String chan * @param packet PacketOut to unregister */ public static void unregisterPacket(String channel, Class packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pOut.keySet().contains(packet) && pOut.get(packet).name().equalsIgnoreCase(channel)) pOut.remove(packet); } @@ -299,7 +299,7 @@ public static void unregisterPacket(String channel, Class p * @return PacketIn */ public static List getPacket(String channel, String handle) { - if (Util.isNull(handle)) throw new NullPointerException(); + if (Util.isNull(channel, handle)) throw new NullPointerException(); return new ArrayList(pIn.get(channel.toLowerCase()).get(handle)); } diff --git a/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/Network/SubDataClient.java b/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/Network/SubDataClient.java index f959bc02..679d0494 100644 --- a/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/Network/SubDataClient.java +++ b/SubServers.Client/Sponge/src/net/ME1312/SubServers/Client/Sponge/Network/SubDataClient.java @@ -239,7 +239,7 @@ public static Cipher getCipher(String handle) { * @param handle Handle to Bind */ public static void registerPacket(PacketIn packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); HashMap> map = (pIn.keySet().contains(channel.toLowerCase()))?pIn.get(channel.toLowerCase()):new HashMap>(); List list = (map.keySet().contains(handle))?map.get(handle):new ArrayList(); if (!list.contains(packet)) { @@ -256,7 +256,7 @@ public static void registerPacket(PacketIn packet, String channel, String handle * @param packet PacketIn to unregister */ public static void unregisterPacket(String channel, PacketIn packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pIn.keySet().contains(channel.toLowerCase())) { List search = new ArrayList(); search.addAll(pIn.get(channel.toLowerCase()).keySet()); @@ -281,7 +281,7 @@ public static void unregisterPacket(String channel, PacketIn packet) { * @param handle Handle to bind */ public static void registerPacket(Class packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); pOut.put(packet, new NamedContainer(channel.toLowerCase(), handle)); } @@ -292,7 +292,7 @@ public static void registerPacket(Class packet, String chan * @param packet PacketOut to unregister */ public static void unregisterPacket(String channel, Class packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pOut.keySet().contains(packet) && pOut.get(packet).name().equalsIgnoreCase(channel)) pOut.remove(packet); } @@ -304,7 +304,7 @@ public static void unregisterPacket(String channel, Class p * @return PacketIn */ public static List getPacket(String channel, String handle) { - if (Util.isNull(handle)) throw new NullPointerException(); + if (Util.isNull(channel, handle)) throw new NullPointerException(); return new ArrayList(pIn.get(channel.toLowerCase()).get(handle)); } 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 939477c8..d3b6dc6e 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/Network/SubDataClient.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/Network/SubDataClient.java @@ -255,7 +255,7 @@ public static Cipher getCipher(String handle) { * @param handle Handle to Bind */ public static void registerPacket(PacketIn packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); HashMap> map = (pIn.keySet().contains(channel.toLowerCase()))?pIn.get(channel.toLowerCase()):new HashMap>(); List list = (map.keySet().contains(handle))?map.get(handle):new ArrayList(); if (!list.contains(packet)) { @@ -272,7 +272,7 @@ public static void registerPacket(PacketIn packet, String channel, String handle * @param packet PacketIn to unregister */ public static void unregisterPacket(String channel, PacketIn packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pIn.keySet().contains(channel.toLowerCase())) { List search = new ArrayList(); search.addAll(pIn.get(channel.toLowerCase()).keySet()); @@ -297,7 +297,7 @@ public static void unregisterPacket(String channel, PacketIn packet) { * @param handle Handle to bind */ public static void registerPacket(Class packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); pOut.put(packet, new NamedContainer(channel.toLowerCase(), handle)); } @@ -308,7 +308,7 @@ public static void registerPacket(Class packet, String chan * @param packet PacketOut to unregister */ public static void unregisterPacket(String channel, Class packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pOut.keySet().contains(packet) && pOut.get(packet).name().equalsIgnoreCase(channel)) pOut.remove(packet); } @@ -320,7 +320,7 @@ public static void unregisterPacket(String channel, Class p * @return PacketIn */ public static List getPacket(String channel, String handle) { - if (Util.isNull(handle)) throw new NullPointerException(); + if (Util.isNull(channel, handle)) throw new NullPointerException(); return new ArrayList(pIn.get(channel.toLowerCase()).get(handle)); } diff --git a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubDataClient.java b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubDataClient.java index 097d8d9a..eb5ea77f 100644 --- a/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubDataClient.java +++ b/SubServers.Sync/src/net/ME1312/SubServers/Sync/Network/SubDataClient.java @@ -260,7 +260,7 @@ public static Cipher getCipher(String handle) { * @param handle Handle to Bind */ public static void registerPacket(PacketIn packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); HashMap> map = (pIn.keySet().contains(channel.toLowerCase()))?pIn.get(channel.toLowerCase()):new HashMap>(); List list = (map.keySet().contains(handle))?map.get(handle):new ArrayList(); if (!list.contains(packet)) { @@ -277,7 +277,7 @@ public static void registerPacket(PacketIn packet, String channel, String handle * @param packet PacketIn to unregister */ public static void unregisterPacket(String channel, PacketIn packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pIn.keySet().contains(channel.toLowerCase())) { List search = new ArrayList(); search.addAll(pIn.get(channel.toLowerCase()).keySet()); @@ -302,7 +302,7 @@ public static void unregisterPacket(String channel, PacketIn packet) { * @param handle Handle to bind */ public static void registerPacket(Class packet, String channel, String handle) { - if (Util.isNull(packet, handle)) throw new NullPointerException(); + if (Util.isNull(packet, channel, handle)) throw new NullPointerException(); pOut.put(packet, new NamedContainer(channel.toLowerCase(), handle)); } @@ -313,7 +313,7 @@ public static void registerPacket(Class packet, String chan * @param packet PacketOut to unregister */ public static void unregisterPacket(String channel, Class packet) { - if (Util.isNull(packet)) throw new NullPointerException(); + if (Util.isNull(channel, packet)) throw new NullPointerException(); if (pOut.keySet().contains(packet) && pOut.get(packet).name().equalsIgnoreCase(channel)) pOut.remove(packet); } @@ -325,7 +325,7 @@ public static void unregisterPacket(String channel, Class p * @return PacketIn */ public static List getPacket(String channel, String handle) { - if (Util.isNull(handle)) throw new NullPointerException(); + if (Util.isNull(channel, handle)) throw new NullPointerException(); return new ArrayList(pIn.get(channel.toLowerCase()).get(handle)); }