Add config flag to allow preventing vl reset in chat.text.

This might be temporary, the resetting could get removed completely,
or it might be fixed/altered.
This commit is contained in:
asofold 2014-05-11 22:59:37 +02:00
parent 4f224eefee
commit 0024e16112
4 changed files with 41 additions and 31 deletions

View File

@ -105,7 +105,8 @@ public class ChatConfig extends AsyncCheckConfig {
public final float textMessageNoLetter;
public final float textGlobalWeight;
public final float textPlayerWeight;
public boolean textEngineMaximum;
public final boolean textEngineMaximum;
public final boolean textAllowVLReset;
public final boolean textDebug;
public final boolean chatWarningCheck;
@ -194,6 +195,7 @@ public class ChatConfig extends AsyncCheckConfig {
textEngineMaximum = config.getBoolean(ConfPaths.CHAT_TEXT_ENGINE_MAXIMUM, true);
textDebug = config.getBoolean(ConfPaths.CHAT_TEXT_DEBUG, false);
textFreqNormActions = config.getOptimizedActionList(ConfPaths.CHAT_TEXT_FREQ_NORM_ACTIONS, Permissions.CHAT_TEXT);
textAllowVLReset = config.getBoolean(ConfPaths.CHAT_TEXT_ALLOWVLRESET);
chatWarningCheck = config.getBoolean(ConfPaths.CHAT_WARNING_CHECK);
chatWarningLevel = (float) config.getDouble(ConfPaths.CHAT_WARNING_LEVEL);

View File

@ -257,8 +257,11 @@ public class Text extends AsyncCheck implements INotifyReload{
lastCancelledTime = time;
final double added;
if (shortTermViolation) added = (shortTermAccumulated - cc.textFreqShortTermLevel)/ 3.0;
else added = (accumulated - cc.textFreqNormLevel) / 10.0;
if (shortTermViolation) {
added = (shortTermAccumulated - cc.textFreqShortTermLevel)/ 3.0;
} else {
added = (accumulated - cc.textFreqNormLevel) / 10.0;
}
data.textVL += added;
if (captcha.shouldStartCaptcha(cc, data)) {
@ -267,25 +270,28 @@ public class Text extends AsyncCheck implements INotifyReload{
}
else{
if (shortTermViolation) {
if (executeActions(player, data.textVL, added, cc.textFreqShortTermActions, isMainThread))
if (executeActions(player, data.textVL, added, cc.textFreqShortTermActions, isMainThread)) {
cancel = true;
}
}
else if (normalViolation) {
if (executeActions(player, data.textVL, added, cc.textFreqNormActions, isMainThread))
if (executeActions(player, data.textVL, added, cc.textFreqNormActions, isMainThread)) {
cancel = true;
}
}
}
}
else if (cc.chatWarningCheck && time - data.chatWarningTime > cc.chatWarningTimeout && (100f * accumulated / cc.textFreqNormLevel > cc.chatWarningLevel || 100f * shortTermAccumulated / cc.textFreqShortTermLevel > cc.chatWarningLevel)) {
NCPAPIProvider.getNoCheatPlusAPI().sendMessageOnTick(player.getName(), ColorUtil.replaceColors(cc.chatWarningMessage));
data.chatWarningTime = time;
}
else {
data.textVL *= 0.95;
if (normalScore < 2.0f * cc.textFreqNormWeight && shortTermScore < 2.0f * cc.textFreqShortTermWeight)
if (cc.textAllowVLReset && normalScore < 2.0f * cc.textFreqNormWeight && shortTermScore < 2.0f * cc.textFreqShortTermWeight) {
// Reset the VL.
// TODO: maybe elaborate on resetting conditions (after some timeout just divide by two or so?).
data.textVL = 0.0;
}
}
if (debug) {

View File

@ -244,6 +244,7 @@ public abstract class ConfPaths {
public static final String CHAT_TEXT_CHECK = CHAT_TEXT + "active";
public static final String CHAT_TEXT_DEBUG = CHAT_TEXT + "debug";
public static final String CHAT_TEXT_ENGINE_MAXIMUM = CHAT_TEXT + "maximum";
public static final String CHAT_TEXT_ALLOWVLRESET = CHAT_TEXT + "allowvlreset";
public static final String CHAT_TEXT_FREQ = CHAT_TEXT + "frequency.";
public static final String CHAT_TEXT_FREQ_NORM = CHAT_TEXT_FREQ + "normal.";
public static final String CHAT_TEXT_FREQ_NORM_FACTOR = CHAT_TEXT_FREQ_NORM + "factor";

View File

@ -168,6 +168,7 @@ public class DefaultConfig extends ConfigFile {
// Text (ordering on purpose).
set(ConfPaths.CHAT_TEXT_CHECK, true);
set(ConfPaths.CHAT_TEXT_ALLOWVLRESET, false);
set(ConfPaths.CHAT_TEXT_FREQ_NORM_MIN, 0.0);
set(ConfPaths.CHAT_TEXT_FREQ_NORM_FACTOR, 0.9D);
set(ConfPaths.CHAT_TEXT_FREQ_NORM_WEIGHT, 6);