AntiBot - make public field private

This commit is contained in:
ljacqu
2016-06-26 09:25:52 +02:00
parent df060ff29c
commit d72d6ddf5a
4 changed files with 71 additions and 4 deletions
+22 -1
View File
@@ -24,7 +24,7 @@ public class AntiBot {
private final Messages messages;
private final PermissionsManager permissionsManager;
private final BukkitService bukkitService;
public final CopyOnWriteArrayList<String> antibotKicked = new CopyOnWriteArrayList<String>();
private final CopyOnWriteArrayList<String> antibotKicked = new CopyOnWriteArrayList<String>();
private final CopyOnWriteArrayList<String> antibotPlayers = new CopyOnWriteArrayList<String>();
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
@@ -112,6 +112,27 @@ public class AntiBot {
}, 15 * TICKS_PER_SECOND);
}
/**
* Returns whether the player was kicked because of activated antibot. The list is reset
* when antibot is deactivated.
*
* @param name the name to check
* @return true if the given name has been kicked because of Antibot
*/
public boolean wasPlayerKicked(String name) {
return antibotKicked.contains(name.toLowerCase());
}
/**
* Adds a name to the list of players kicked by antibot. Should only be used when a player
* is determined to be kicked because of failed antibot verification.
*
* @param name the name to add
*/
public void addPlayerKick(String name) {
antibotKicked.addIfAbsent(name.toLowerCase());
}
public enum AntiBotStatus {
LISTENING,
DISABLED,
@@ -239,7 +239,7 @@ public class AuthMePlayerListener implements Listener {
event.setQuitMessage(null);
}
if (antiBot.antibotKicked.contains(player.getName())) {
if (antiBot.wasPlayerKicked(player.getName())) {
return;
}
@@ -250,7 +250,7 @@ public class AuthMePlayerListener implements Listener {
public void onPlayerKick(PlayerKickEvent event) {
Player player = event.getPlayer();
if (!antiBot.antibotKicked.contains(player.getName())) {
if (!antiBot.wasPlayerKicked(player.getName())) {
management.performQuit(player, true);
}
}
@@ -68,7 +68,7 @@ class OnJoinVerifier implements Reloadable {
*/
public void checkAntibot(String playerName, boolean isAuthAvailable) throws FailedVerificationException {
if (antiBot.getAntiBotStatus() == AntiBot.AntiBotStatus.ACTIVE && !isAuthAvailable) {
antiBot.antibotKicked.addIfAbsent(playerName);
antiBot.addPlayerKick(playerName);
throw new FailedVerificationException(MessageKey.KICK_ANTIBOT);
}
}