mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-28 11:28:11 +01:00
Fixed spamcheck + also count commands
This commit is contained in:
parent
75050efbbd
commit
e67a1f2c0c
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 2.08a
|
||||
version: 2.08b
|
||||
|
||||
commands:
|
||||
nocheat:
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
@ -68,6 +70,10 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag
|
||||
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
onPlayerChat(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||
LinkedList<String> s = new LinkedList<String>();
|
||||
|
Loading…
Reference in New Issue
Block a user