From 0208bde89d16f0766c077a73e20b23f21e72fe51 Mon Sep 17 00:00:00 2001 From: ryanhamshire Date: Thu, 3 Dec 2015 17:02:45 -0800 Subject: [PATCH] Fixed too-aggressive IP address re-use limiter. --- src/me/ryanhamshire/GriefPrevention/PlayerData.java | 3 +++ .../GriefPrevention/PlayerEventHandler.java | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerData.java b/src/me/ryanhamshire/GriefPrevention/PlayerData.java index 256f02f..4d47501 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerData.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerData.java @@ -146,6 +146,9 @@ public class PlayerData //profanity warning, once per play session boolean profanityWarned = false; + + //true when the player's IP address was counted against the re-use limit when he joined + boolean ipLimited = false; //whether or not this player is "in" pvp combat public boolean inPvpCombat() diff --git a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java index 2a5c1e6..6f84fa4 100644 --- a/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java +++ b/src/me/ryanhamshire/GriefPrevention/PlayerEventHandler.java @@ -862,7 +862,7 @@ class PlayerEventHandler implements Listener { String ipAddressString = ipAddress.toString(); int ipLimit = GriefPrevention.instance.config_ipLimit; - if(ipLimit > 0 && !player.hasAchievement(Achievement.MINE_WOOD)) + if(ipLimit > 0 && GriefPrevention.isNewToServer(player)) { Integer ipCount = this.ipCountHash.get(ipAddressString); if(ipCount == null) ipCount = 0; @@ -873,12 +873,13 @@ class PlayerEventHandler implements Listener GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 10L); //silence join message - event.setJoinMessage(""); + event.setJoinMessage(null); return; } else { this.ipCountHash.put(ipAddressString, ipCount + 1); + playerData.ipLimited = true; } } } @@ -990,11 +991,8 @@ class PlayerEventHandler implements Listener if(player.getHealth() > 0) player.setHealth(0); //might already be zero from above, this avoids a double death message } - //drop data about this player - this.dataStore.clearCachedPlayerData(playerID); - //reduce count of players with that player's IP address - if(GriefPrevention.instance.config_ipLimit > 0 && GriefPrevention.isNewToServer(player)) + if(GriefPrevention.instance.config_ipLimit > 0 && playerData.ipLimited) { InetAddress ipAddress = playerData.ipAddress; if(ipAddress != null) @@ -1005,6 +1003,9 @@ class PlayerEventHandler implements Listener this.ipCountHash.put(ipAddressString, count - 1); } } + + //drop data about this player + this.dataStore.clearCachedPlayerData(playerID); } //determines whether or not a login or logout notification should be silenced, depending on how many there have been in the last minute