Fixed spamcheck + also count commands

This commit is contained in:
Evenprime 2011-10-02 17:07:29 +02:00
parent 75050efbbd
commit e67a1f2c0c
5 changed files with 11 additions and 6 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 2.08a
version: 2.08b
commands:
nocheat:

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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<String> getActiveChecks(ConfigurationCache cc) {