From e9b2517188f432ef9a68a1931e46f75a75860603 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 24 Nov 2015 21:55:55 +0100 Subject: [PATCH] enhance the removespeed feature --- src/main/java/fr/xephi/authme/AntiBot.java | 25 +++++++++---------- .../authme/listener/AuthMePlayerListener.java | 8 +++--- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/fr/xephi/authme/AntiBot.java b/src/main/java/fr/xephi/authme/AntiBot.java index 16b0ff23f..dc681c25e 100644 --- a/src/main/java/fr/xephi/authme/AntiBot.java +++ b/src/main/java/fr/xephi/authme/AntiBot.java @@ -16,7 +16,7 @@ public class AntiBot { private static final AuthMe plugin = AuthMe.getInstance(); private static final Messages messages = plugin.getMessages(); private static final List antibotPlayers = new ArrayList<>(); - private static AntiBotStatus antiBotStatus = AntiBotStatus.DISARMED; + private static AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED; public static void setupAntiBotService() { if (!Settings.enableAntiBot) { @@ -25,19 +25,19 @@ public class AntiBot { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - antiBotStatus = AntiBotStatus.ARMED; + antiBotStatus = AntiBotStatus.ENABLED; } }, 2400); } public static void overrideAntiBotStatus(boolean activated) { - if (antiBotStatus == AntiBotStatus.DISARMED || antiBotStatus == AntiBotStatus.DELAYED) { + if (antiBotStatus == AntiBotStatus.DISABLED) { return; } if (activated) { - antiBotStatus = AntiBotStatus.ACTIVATED; + antiBotStatus = AntiBotStatus.INACTION; } else { - antiBotStatus = AntiBotStatus.ARMED; + antiBotStatus = AntiBotStatus.ENABLED; } } @@ -46,7 +46,7 @@ public class AntiBot { } public static void activateAntiBot() { - antiBotStatus = AntiBotStatus.ACTIVATED; + antiBotStatus = AntiBotStatus.INACTION; for (String s : messages.send("antibot_auto_enabled")) { Bukkit.broadcastMessage(s); } @@ -54,8 +54,8 @@ public class AntiBot { Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { - if (antiBotStatus == AntiBotStatus.ACTIVATED) { - antiBotStatus = AntiBotStatus.ARMED; + if (antiBotStatus == AntiBotStatus.INACTION) { + antiBotStatus = AntiBotStatus.ENABLED; antibotPlayers.clear(); for (String s : messages.send("antibot_auto_disabled")) Bukkit.broadcastMessage(s.replace("%m", "" + Settings.antiBotDuration)); @@ -70,7 +70,7 @@ public class AntiBot { * @param player Player */ public static void checkAntiBot(final Player player) { - if (antiBotStatus == AntiBotStatus.ACTIVATED || antiBotStatus == AntiBotStatus.DISARMED) { + if (antiBotStatus == AntiBotStatus.INACTION || antiBotStatus == AntiBotStatus.DISABLED) { return; } if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassantibot")) { @@ -91,10 +91,9 @@ public class AntiBot { } public enum AntiBotStatus { - ARMED, - DISARMED, - DELAYED, - ACTIVATED + ENABLED, + DISABLED, + INACTION } } diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 4a5e705a5..e2852359e 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -183,10 +183,12 @@ public class AuthMePlayerListener implements Listener { } if (!Settings.isMovementAllowed) { - if (event.getFrom().distance(event.getTo()) > 0) { - event.setTo(event.getFrom()); - return; + event.setTo(event.getFrom()); + if(Settings.isRemoveSpeedEnabled) { + player.setFlySpeed(0.0f); + player.setWalkSpeed(0.0f); } + return; } if (Settings.noTeleport) {