diff --git a/plugin.yml b/plugin.yml index 3421d039..8533f4de 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ name: NoCheat author: Evenprime main: cc.co.evenprime.bukkit.nocheat.NoCheat -version: 2.08a +version: 2.08b commands: nocheat: diff --git a/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java b/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java index c2d91785..551038b2 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java +++ b/src/cc/co/evenprime/bukkit/nocheat/NoCheat.java @@ -1,6 +1,5 @@ package cc.co.evenprime.bukkit.nocheat; -import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; diff --git a/src/cc/co/evenprime/bukkit/nocheat/actions/history/ActionHistory.java b/src/cc/co/evenprime/bukkit/nocheat/actions/history/ActionHistory.java index c5fd083a..69e44330 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/actions/history/ActionHistory.java +++ b/src/cc/co/evenprime/bukkit/nocheat/actions/history/ActionHistory.java @@ -25,11 +25,11 @@ public class ActionHistory { public void addCounter(Long time) { synchronized(executionTimes) { - while(executionTimes.size() > 0 && executionTimes.getFirst() < time - monitoredTimeFrame) { + while(!executionTimes.isEmpty() && executionTimes.getFirst() < time - monitoredTimeFrame) { executionTimes.removeFirst(); } - executionTimes.add(time); + executionTimes.addLast(time); } } @@ -76,7 +76,7 @@ public class ActionHistory { if(entry.getCounter() > action.delay) { // Execute action? - if(entry.getLastExecution() < time - action.repeat * 1000) { + if(entry.getLastExecution() <= time - action.repeat * 1000) { // Execute action! entry.setLastExecution(time); return true; diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/ChatCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/ChatCheck.java index c09b6750..e466360f 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/chat/ChatCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/chat/ChatCheck.java @@ -39,7 +39,7 @@ public class ChatCheck { int time = plugin.getIngameSeconds(); - if(data.spamLasttime + cc.chat.spamTimeframe <= plugin.getIngameSeconds()) { + if(data.spamLasttime + cc.chat.spamTimeframe <= time) { data.spamLasttime = time; data.messageCount = 0; } diff --git a/src/cc/co/evenprime/bukkit/nocheat/events/PlayerChatEventManager.java b/src/cc/co/evenprime/bukkit/nocheat/events/PlayerChatEventManager.java index 40f6b68e..973fa7d3 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/events/PlayerChatEventManager.java +++ b/src/cc/co/evenprime/bukkit/nocheat/events/PlayerChatEventManager.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerListener; import org.bukkit.plugin.PluginManager; @@ -39,6 +40,7 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag PluginManager pm = Bukkit.getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_CHAT, this, Priority.Lowest, plugin); + pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this, Priority.Lowest, plugin); } @Override @@ -67,6 +69,10 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag } } + + public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + onPlayerChat(event); + } @Override public List getActiveChecks(ConfigurationCache cc) {