differentiate commands/chat, modified defaults

This commit is contained in:
Evenprime 2012-01-31 16:50:15 +01:00
parent c83bbd999b
commit 22a82b8beb
5 changed files with 32 additions and 24 deletions

View File

@ -17,6 +17,7 @@ public class ChatConfig implements ConfigItem {
public final ActionList spamActions;
public final boolean colorCheck;
public final ActionList colorActions;
public final int commandLimit;
public ChatConfig(NoCheatConfiguration data) {
@ -24,6 +25,7 @@ public class ChatConfig implements ConfigItem {
spamWhitelist = splitWhitelist(data.getString(ConfPaths.CHAT_SPAM_WHITELIST));
spamTimeframe = data.getInt(ConfPaths.CHAT_SPAM_TIMEFRAME);
spamLimit = data.getInt(ConfPaths.CHAT_SPAM_LIMIT);
commandLimit = data.getInt(ConfPaths.CHAT_SPAM_COMMANDLIMIT);
spamActions = data.getActionList(ConfPaths.CHAT_SPAM_ACTIONS);
colorCheck = data.getBoolean(ConfPaths.CHAT_COLOR_CHECK);
colorActions = data.getActionList(ConfPaths.CHAT_COLOR_ACTIONS);

View File

@ -8,16 +8,17 @@ import cc.co.evenprime.bukkit.nocheat.DataItem;
*/
public class ChatData implements DataItem {
public int spamVL;
public int spamTotalVL;
public int spamFailed;
public int colorVL;
public int colorTotalVL;
public int colorFailed;
public int spamVL;
public int spamTotalVL;
public int spamFailed;
public int colorVL;
public int colorTotalVL;
public int colorFailed;
public int messageCount = 0;
public long spamLastTime = 0;
public String message = "";
public int messageCount = 0;
public int commandCount = 0;
public long spamLastTime = 0;
public String message = "";
@Override
public void collectData(Map<String, Object> map) {

View File

@ -1,7 +1,6 @@
package cc.co.evenprime.bukkit.nocheat.checks.chat;
import java.util.Locale;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
@ -29,17 +28,22 @@ public class SpamCheck extends ChatCheck {
if(data.spamLastTime + cc.spamTimeframe <= time) {
data.spamLastTime = time;
data.messageCount = 0;
data.commandCount = 0;
}
// Security check, if the system time changes
else if(data.spamLastTime > time) {
data.spamLastTime = Integer.MIN_VALUE;
}
data.messageCount++;
if(data.message.startsWith("/"))
data.commandCount++;
else
data.messageCount++;
if(data.messageCount > cc.spamLimit) {
if(data.messageCount > cc.spamLimit || data.commandCount > cc.commandLimit) {
data.spamVL = data.messageCount - cc.spamLimit;
data.spamVL = Math.max(0, data.messageCount - cc.spamLimit);
data.spamVL += Math.max(0, data.commandCount - cc.commandLimit);
data.spamTotalVL++;
data.spamFailed++;

View File

@ -82,7 +82,8 @@ public abstract class ConfPaths {
public final static String CHAT_SPAM_CHECK = CHAT_SPAM + "active";
public final static String CHAT_SPAM_WHITELIST = CHAT_SPAM + "whitelist";
public final static String CHAT_SPAM_TIMEFRAME = CHAT_SPAM + "timeframe";
public final static String CHAT_SPAM_LIMIT = CHAT_SPAM + "limit";
public final static String CHAT_SPAM_LIMIT = CHAT_SPAM + "messagelimit";
public final static String CHAT_SPAM_COMMANDLIMIT = CHAT_SPAM + "commandlimit";
public final static String CHAT_SPAM_ACTIONS = CHAT_SPAM + "actions";
private final static String FIGHT = CHECKS + "fight.";

View File

@ -1,6 +1,5 @@
package cc.co.evenprime.bukkit.nocheat.config;
/**
* These are the default settings for NoCheat. They will be used
* in addition to/in replacement of configurations given in the
@ -54,37 +53,38 @@ public class DefaultConfiguration extends NoCheatConfiguration {
set(ConfPaths.BLOCKBREAK_DIRECTION_CHECK, true);
set(ConfPaths.BLOCKBREAK_DIRECTION_PRECISION, 50);
set(ConfPaths.BLOCKBREAK_DIRECTION_PENALTYTIME, 300);
set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, "cancel vl>10 log:bbdirection:0:5:cif cancel");
set(ConfPaths.BLOCKBREAK_DIRECTION_ACTIONS, "cancel vl>10 log:bbdirection:0:5:if cancel");
set(ConfPaths.BLOCKBREAK_NOSWING_CHECK, true);
set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, "log:bbnoswing:0:2:cif cancel");
set(ConfPaths.BLOCKBREAK_NOSWING_ACTIONS, "log:bbnoswing:0:2:if cancel");
/*** BLOCKPLACE ***/
set(ConfPaths.BLOCKPLACE_REACH_CHECK, true);
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, "cancel vl>5 log:bpreach:0:2:cif cancel");
set(ConfPaths.BLOCKPLACE_REACH_ACTIONS, "cancel vl>5 log:bpreach:0:2:if cancel");
set(ConfPaths.BLOCKPLACE_DIRECTION_CHECK, true);
set(ConfPaths.BLOCKPLACE_DIRECTION_PRECISION, 75);
set(ConfPaths.BLOCKPLACE_DIRECTION_PENALTYTIME, 100);
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, "cancel vl>10 log:bpdirection:0:3:cif cancel");
set(ConfPaths.BLOCKPLACE_DIRECTION_ACTIONS, "cancel vl>10 log:bpdirection:0:3:if cancel");
/*** CHAT ***/
set(ConfPaths.CHAT_COLOR_CHECK, true);
set(ConfPaths.CHAT_COLOR_ACTIONS, "log:color:0:1:cif cancel");
set(ConfPaths.CHAT_COLOR_ACTIONS, "log:color:0:1:if cancel");
set(ConfPaths.CHAT_SPAM_CHECK, true);
set(ConfPaths.CHAT_SPAM_WHITELIST, "");
set(ConfPaths.CHAT_SPAM_TIMEFRAME, 5);
set(ConfPaths.CHAT_SPAM_LIMIT, 5);
set(ConfPaths.CHAT_SPAM_ACTIONS, "log:spam:0:5:cif cancel vl>50 log:spam:0:5:cif cancel cmd:kick");
set(ConfPaths.CHAT_SPAM_TIMEFRAME, 3);
set(ConfPaths.CHAT_SPAM_LIMIT, 3);
set(ConfPaths.CHAT_SPAM_COMMANDLIMIT, 12);
set(ConfPaths.CHAT_SPAM_ACTIONS, "log:spam:0:3:if cancel vl>30 log:spam:0:3:cif cancel cmd:kick");
/*** FIGHT ***/
set(ConfPaths.FIGHT_DIRECTION_CHECK, true);
set(ConfPaths.FIGHT_DIRECTION_PRECISION, 75);
set(ConfPaths.FIGHT_DIRECTION_PENALTYTIME, 500);
set(ConfPaths.FIGHT_DIRECTION_ACTIONS, "cancel vl>5 log:fdirection:3:5:f cancel vl>20 log:fdirection:0:5:cf cancel vl>50 log:fdirection:0:5:cif cancel");
set(ConfPaths.FIGHT_DIRECTION_ACTIONS, "cancel vl>5 log:fdirection:3:5:f cancel vl>20 log:fdirection:0:5:if cancel vl>50 log:fdirection:0:5:cif cancel");
set(ConfPaths.FIGHT_NOSWING_CHECK, true);
set(ConfPaths.FIGHT_NOSWING_ACTIONS, "log:fnoswing:0:5:cif cancel");