From c0e8650c6ff840f678e15b0a863c6fcbdb4329b1 Mon Sep 17 00:00:00 2001 From: Xephi Date: Mon, 23 May 2016 10:10:01 +0200 Subject: [PATCH] Move to antibot class --- src/main/java/fr/xephi/authme/AntiBot.java | 6 ++++-- .../fr/xephi/authme/listener/AuthMePlayerListener.java | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/fr/xephi/authme/AntiBot.java b/src/main/java/fr/xephi/authme/AntiBot.java index 22c9feab6..5670e90e9 100644 --- a/src/main/java/fr/xephi/authme/AntiBot.java +++ b/src/main/java/fr/xephi/authme/AntiBot.java @@ -13,6 +13,7 @@ import org.bukkit.entity.Player; import javax.inject.Inject; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE; import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND; @@ -26,7 +27,8 @@ public class AntiBot { private final Messages messages; private final PermissionsManager permissionsManager; private final BukkitService bukkitService; - private final List antibotPlayers = new ArrayList<>(); + public final CopyOnWriteArrayList antibotKicked = new CopyOnWriteArrayList(); + private final CopyOnWriteArrayList antibotPlayers = new CopyOnWriteArrayList(); private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED; @Inject @@ -78,7 +80,7 @@ public class AntiBot { if (antiBotStatus == AntiBotStatus.ACTIVE) { antiBotStatus = AntiBotStatus.LISTENING; antibotPlayers.clear(); - AuthMePlayerListener.antibotKicked.clear(); + antibotKicked.clear(); for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE)) { bukkitService.broadcastMessage(s.replace("%m", Integer.toString(duration))); } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 333b7a770..ed3d89127 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -76,7 +76,7 @@ public class AuthMePlayerListener implements Listener { public static final ConcurrentHashMap joinMessage = new ConcurrentHashMap<>(); public static final ConcurrentHashMap causeByAuthMe = new ConcurrentHashMap<>(); - public static final CopyOnWriteArrayList antibotKicked = new CopyOnWriteArrayList(); + @Inject private AuthMe plugin; @Inject @@ -276,7 +276,7 @@ public class AuthMePlayerListener implements Listener { if (auth == null && antiBot.getAntiBotStatus() == AntiBotStatus.ACTIVE) { event.setKickMessage(m.retrieveSingle(MessageKey.KICK_ANTIBOT)); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); - antibotKicked.addIfAbsent(event.getName()); + antiBot.antibotKicked.addIfAbsent(event.getName()); return; } if (auth == null && settings.getProperty(RestrictionSettings.KICK_NON_REGISTERED)) { @@ -368,7 +368,7 @@ public class AuthMePlayerListener implements Listener { if (antiBot.getAntiBotStatus() == AntiBotStatus.ACTIVE && !isAuthAvailable) { event.setKickMessage(m.retrieveSingle(MessageKey.KICK_ANTIBOT)); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); - antibotKicked.addIfAbsent(player.getName()); + antiBot.antibotKicked.addIfAbsent(player.getName()); return; } @@ -413,7 +413,7 @@ public class AuthMePlayerListener implements Listener { event.setQuitMessage(null); } - if (antibotKicked.contains(player.getName())) { + if (antiBot.antibotKicked.contains(player.getName())) { return; } @@ -434,7 +434,7 @@ public class AuthMePlayerListener implements Listener { return; } - if (antibotKicked.contains(player.getName())) { + if (antiBot.antibotKicked.contains(player.getName())) { return; }