diff --git a/EaglerMOTD.jar b/EaglerMOTD.jar index cb424ee..1171299 100644 Binary files a/EaglerMOTD.jar and b/EaglerMOTD.jar differ diff --git a/src/net/lax1dude/eaglercraft/eaglermotd/EaglerMOTD.java b/src/net/lax1dude/eaglercraft/eaglermotd/EaglerMOTD.java index 5284cd9..17d919a 100644 --- a/src/net/lax1dude/eaglercraft/eaglermotd/EaglerMOTD.java +++ b/src/net/lax1dude/eaglercraft/eaglermotd/EaglerMOTD.java @@ -340,10 +340,12 @@ public class EaglerMOTD extends Plugin implements Listener { public void onMOTD(WebsocketMOTDEvent evt) { MOTDConnection con = new MOTDConnection(evt.getListener(), evt.getMOTD()); if(con.execute()) { - synchronized(motdConnections) { - while(motdConnections.size() >= max_total_sockets) { - MOTDConnection c = motdConnections.remove(0); - c.close(); + if(max_total_sockets > 0) { + synchronized(motdConnections) { + while(motdConnections.size() >= max_total_sockets) { + MOTDConnection c = motdConnections.remove(motdConnections.size() - 1); + c.close(); + } } } InetAddress addr = con.motd.getRemoteAddress(); @@ -356,22 +358,24 @@ public class EaglerMOTD extends Plugin implements Listener { } if(flag) { synchronized(motdConnections) { - motdConnections.add(con); + motdConnections.add(0, con); } }else { if(allow_banned_ips || !BanList.checkIpBanned(addr).isBanned()) { synchronized(motdConnections) { - int i = 0; - int c = 0; - while(i < motdConnections.size()) { - if(motdConnections.get(i).motd.getRemoteAddress().equals(addr)) { - ++c; - if(c >= max_sockets_per_ip) { - motdConnections.remove(i).close(); - --i; + if(max_sockets_per_ip > 0) { + int i = 0; + int c = 0; + while(i < motdConnections.size()) { + if(motdConnections.get(i).motd.getRemoteAddress().equals(addr)) { + ++c; + if(c >= max_sockets_per_ip) { + motdConnections.remove(i).close(); + --i; + } } + ++i; } - ++i; } motdConnections.add(0, con); } diff --git a/src/plugin.yml b/src/plugin.yml index efe4338..1e350aa 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,4 +1,4 @@ name: EaglerMOTD main: net.lax1dude.eaglercraft.eaglermotd.EaglerMOTD -version: 1.0 +version: 1.0.2 author: LAX1DUDE \ No newline at end of file