Move to antibot class
This commit is contained in:
parent
37b6a2f96f
commit
c0e8650c6f
@ -13,6 +13,7 @@ import org.bukkit.entity.Player;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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_MINUTE;
|
||||||
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
||||||
@ -26,7 +27,8 @@ public class AntiBot {
|
|||||||
private final Messages messages;
|
private final Messages messages;
|
||||||
private final PermissionsManager permissionsManager;
|
private final PermissionsManager permissionsManager;
|
||||||
private final BukkitService bukkitService;
|
private final BukkitService bukkitService;
|
||||||
private final List<String> antibotPlayers = new ArrayList<>();
|
public final CopyOnWriteArrayList<String> antibotKicked = new CopyOnWriteArrayList<String>();
|
||||||
|
private final CopyOnWriteArrayList<String> antibotPlayers = new CopyOnWriteArrayList<String>();
|
||||||
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
|
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -78,7 +80,7 @@ public class AntiBot {
|
|||||||
if (antiBotStatus == AntiBotStatus.ACTIVE) {
|
if (antiBotStatus == AntiBotStatus.ACTIVE) {
|
||||||
antiBotStatus = AntiBotStatus.LISTENING;
|
antiBotStatus = AntiBotStatus.LISTENING;
|
||||||
antibotPlayers.clear();
|
antibotPlayers.clear();
|
||||||
AuthMePlayerListener.antibotKicked.clear();
|
antibotKicked.clear();
|
||||||
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE)) {
|
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE)) {
|
||||||
bukkitService.broadcastMessage(s.replace("%m", Integer.toString(duration)));
|
bukkitService.broadcastMessage(s.replace("%m", Integer.toString(duration)));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
|
|
||||||
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||||
public static final CopyOnWriteArrayList<String> antibotKicked = new CopyOnWriteArrayList<String>();
|
|
||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
@Inject
|
@Inject
|
||||||
@ -276,7 +276,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (auth == null && antiBot.getAntiBotStatus() == AntiBotStatus.ACTIVE) {
|
if (auth == null && antiBot.getAntiBotStatus() == AntiBotStatus.ACTIVE) {
|
||||||
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_ANTIBOT));
|
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_ANTIBOT));
|
||||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||||
antibotKicked.addIfAbsent(event.getName());
|
antiBot.antibotKicked.addIfAbsent(event.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (auth == null && settings.getProperty(RestrictionSettings.KICK_NON_REGISTERED)) {
|
if (auth == null && settings.getProperty(RestrictionSettings.KICK_NON_REGISTERED)) {
|
||||||
@ -368,7 +368,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
if (antiBot.getAntiBotStatus() == AntiBotStatus.ACTIVE && !isAuthAvailable) {
|
if (antiBot.getAntiBotStatus() == AntiBotStatus.ACTIVE && !isAuthAvailable) {
|
||||||
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_ANTIBOT));
|
event.setKickMessage(m.retrieveSingle(MessageKey.KICK_ANTIBOT));
|
||||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||||
antibotKicked.addIfAbsent(player.getName());
|
antiBot.antibotKicked.addIfAbsent(player.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +413,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (antibotKicked.contains(player.getName())) {
|
if (antiBot.antibotKicked.contains(player.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (antibotKicked.contains(player.getName())) {
|
if (antiBot.antibotKicked.contains(player.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user