Fixed NPE during login.

Not sure how a player could NOT have an IP address at this point?  But
logs from customers show it happens somehow.
This commit is contained in:
ryanhamshire 2015-05-07 15:22:32 -07:00
parent 1c7f132472
commit 02dee1f21e

View File

@ -689,25 +689,28 @@ class PlayerEventHandler implements Listener
//ensure we're not over the limit for this IP address //ensure we're not over the limit for this IP address
InetAddress ipAddress = playerData.ipAddress; InetAddress ipAddress = playerData.ipAddress;
String ipAddressString = ipAddress.toString(); if(ipAddress != null)
int ipLimit = GriefPrevention.instance.config_ipLimit;
if(ipLimit > 0 && !player.hasAchievement(Achievement.MINE_WOOD))
{ {
Integer ipCount = this.ipCountHash.get(ipAddressString); String ipAddressString = ipAddress.toString();
if(ipCount == null) ipCount = 0; int ipLimit = GriefPrevention.instance.config_ipLimit;
if(ipCount >= ipLimit) if(ipLimit > 0 && !player.hasAchievement(Achievement.MINE_WOOD))
{ {
//kick player Integer ipCount = this.ipCountHash.get(ipAddressString);
PlayerKickBanTask task = new PlayerKickBanTask(player, "Sorry, there are too many players logged in with your IP address.", false); if(ipCount == null) ipCount = 0;
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 10L); if(ipCount >= ipLimit)
{
//kick player
PlayerKickBanTask task = new PlayerKickBanTask(player, "Sorry, there are too many players logged in with your IP address.", false);
GriefPrevention.instance.getServer().getScheduler().scheduleSyncDelayedTask(GriefPrevention.instance, task, 10L);
//silence join message //silence join message
event.setJoinMessage(""); event.setJoinMessage("");
return; return;
} }
else else
{ {
this.ipCountHash.put(ipAddressString, ipCount + 1); this.ipCountHash.put(ipAddressString, ipCount + 1);
}
} }
} }
} }