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
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||||
version: 2.08a
|
version: 2.08b
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
nocheat:
|
nocheat:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat;
|
package cc.co.evenprime.bukkit.nocheat;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -25,11 +25,11 @@ public class ActionHistory {
|
|||||||
public void addCounter(Long time) {
|
public void addCounter(Long time) {
|
||||||
|
|
||||||
synchronized(executionTimes) {
|
synchronized(executionTimes) {
|
||||||
while(executionTimes.size() > 0 && executionTimes.getFirst() < time - monitoredTimeFrame) {
|
while(!executionTimes.isEmpty() && executionTimes.getFirst() < time - monitoredTimeFrame) {
|
||||||
executionTimes.removeFirst();
|
executionTimes.removeFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
executionTimes.add(time);
|
executionTimes.addLast(time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ public class ActionHistory {
|
|||||||
|
|
||||||
if(entry.getCounter() > action.delay) {
|
if(entry.getCounter() > action.delay) {
|
||||||
// Execute action?
|
// Execute action?
|
||||||
if(entry.getLastExecution() < time - action.repeat * 1000) {
|
if(entry.getLastExecution() <= time - action.repeat * 1000) {
|
||||||
// Execute action!
|
// Execute action!
|
||||||
entry.setLastExecution(time);
|
entry.setLastExecution(time);
|
||||||
return true;
|
return true;
|
||||||
|
@ -39,7 +39,7 @@ public class ChatCheck {
|
|||||||
|
|
||||||
int time = plugin.getIngameSeconds();
|
int time = plugin.getIngameSeconds();
|
||||||
|
|
||||||
if(data.spamLasttime + cc.chat.spamTimeframe <= plugin.getIngameSeconds()) {
|
if(data.spamLasttime + cc.chat.spamTimeframe <= time) {
|
||||||
data.spamLasttime = time;
|
data.spamLasttime = time;
|
||||||
data.messageCount = 0;
|
data.messageCount = 0;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag
|
|||||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
pm.registerEvent(Event.Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
|
pm.registerEvent(Event.Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
|
||||||
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, this, Priority.Lowest, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -67,6 +69,10 @@ public class PlayerChatEventManager extends PlayerListener implements EventManag
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
|
onPlayerChat(event);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getActiveChecks(ConfigurationCache cc) {
|
public List<String> getActiveChecks(ConfigurationCache cc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user