-
-
Save Curspex/96429f5e71fe67627830 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Map<String, Integer> ips = new HashMap<String, Integer>(); | |
@EventHandler | |
public void onPlayerJoin(PlayerLoginEvent event) | |
{ | |
if (!event.getResult().equals(Result.ALLOWED)) return; | |
final String addy = event.getAddress().toString(); | |
if (ips.containsKey(addy)) | |
{ | |
if (ips.get(addy) > 4) | |
{ | |
event.setResult(Result.KICK_OTHER); | |
event.setKickMessage("Too many players from your IP are logged in!"); | |
} | |
else | |
{ | |
ips.replace(addy, ips.get(addy)+1); | |
} | |
} | |
else | |
{ | |
ips.put(addy, 1); | |
} | |
} | |
@EventHandler | |
public void onPlayerQuit(PlayerQuitEvent event) | |
{ | |
final String addy = event.getPlayer().getAddress().toString(); | |
if (ips.get(addy) == 1) | |
{ | |
ips.remove(addy); | |
} | |
else | |
{ | |
ips.replace(addy, ips.get(addy)-1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment