mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-02 08:40:01 +01:00
gobalchat: Add hidden active flags for global and player (works per
world config). Ensure clear calls reset the added counts.
This commit is contained in:
parent
128836be65
commit
fa8f1cc4cb
@ -71,6 +71,8 @@ public class ChatConfig implements CheckConfig {
|
||||
public final ActionList colorActions;
|
||||
|
||||
public final boolean globalChatCheck;
|
||||
public final boolean globalChatGlobalCheck;
|
||||
public final boolean globalChatPlayerCheck;
|
||||
public final EnginePlayerConfig globalChatEnginePlayerConfig;
|
||||
public final float globalChatFrequencyFactor;
|
||||
public final float globalChatFrequencyWeight;
|
||||
@ -149,6 +151,8 @@ public class ChatConfig implements CheckConfig {
|
||||
colorActions = config.getActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR);
|
||||
|
||||
globalChatCheck = config.getBoolean(ConfPaths.CHAT_GLOBALCHAT_CHECK);
|
||||
globalChatGlobalCheck = config.getBoolean(ConfPaths.CHAT_GLOBALCHAT_GL_CHECK, true);
|
||||
globalChatPlayerCheck = config.getBoolean(ConfPaths.CHAT_GLOBALCHAT_PP_CHECK, true);
|
||||
globalChatEnginePlayerConfig = new EnginePlayerConfig(config);
|
||||
globalChatFrequencyFactor = (float) config.getDouble(ConfPaths.CHAT_GLOBALCHAT_FREQUENCY_FACTOR);
|
||||
globalChatFrequencyWeight = (float) config.getDouble(ConfPaths.CHAT_GLOBALCHAT_FREQUENCY_WEIGHT);
|
||||
|
@ -63,6 +63,7 @@ public class LetterEngine {
|
||||
final Map<String, Float> result = new HashMap<String, Float>();
|
||||
|
||||
// Global processors.
|
||||
if (cc.globalChatGlobalCheck){
|
||||
for (final WordProcessor processor : processors){
|
||||
try{
|
||||
result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatGlobalWeight);
|
||||
@ -73,8 +74,10 @@ public class LetterEngine {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Per player processors.
|
||||
if (cc.globalChatPlayerCheck){
|
||||
final EnginePlayerData engineData = dataMap.get(playerName, cc);
|
||||
for (final WordProcessor processor : engineData.processors){
|
||||
try{
|
||||
@ -86,6 +89,8 @@ public class LetterEngine {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,7 @@ public abstract class DigestedWords extends AbstractWordProcessor{
|
||||
letters.clear();
|
||||
digits.clear();
|
||||
other.clear();
|
||||
super.clear(); // Just for completeness.
|
||||
}
|
||||
|
||||
public static final char[] toArray(final Collection<Character> chars){
|
||||
|
@ -56,6 +56,7 @@ public class SimilarWordsBKL extends DigestedWords {
|
||||
public void clear() {
|
||||
super.clear();
|
||||
tree.clear();
|
||||
added = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,6 +58,7 @@ public class WordPrefixes extends DigestedWords{
|
||||
public void clear() {
|
||||
super.clear();
|
||||
tree.clear();
|
||||
added = 0;
|
||||
}
|
||||
|
||||
protected float getScore(final List<Character> chars, final long ts) {
|
||||
|
@ -153,6 +153,7 @@ public abstract class ConfPaths {
|
||||
// (Some of the following paths must be public for generic config reading.)
|
||||
// Extended global checks.
|
||||
private static final String CHAT_GLOBALCHAT_GL = CHAT_GLOBALCHAT + "global.";
|
||||
public static final String CHAT_GLOBALCHAT_GL_CHECK = CHAT_GLOBALCHAT_GL + "active";
|
||||
public static final String CHAT_GLOBALCHAT_GL_WEIGHT = CHAT_GLOBALCHAT_GL + "weight";
|
||||
public static final String CHAT_GLOBALCHAT_GL_WORDS = CHAT_GLOBALCHAT_GL + "words.";
|
||||
public static final String CHAT_GLOBALCHAT_GL_WORDS_CHECK = CHAT_GLOBALCHAT_GL_WORDS + "active";
|
||||
@ -162,6 +163,7 @@ public abstract class ConfPaths {
|
||||
public static final String CHAT_GLOBALCHAT_GL_SIMILARITY_CHECK = CHAT_GLOBALCHAT_GL_SIMILARITY + "active";
|
||||
// Extended per player checks.
|
||||
private static final String CHAT_GLOBALCHAT_PP = CHAT_GLOBALCHAT + "player.";
|
||||
public static final String CHAT_GLOBALCHAT_PP_CHECK = CHAT_GLOBALCHAT_PP + "active";
|
||||
public static final String CHAT_GLOBALCHAT_PP_WEIGHT = CHAT_GLOBALCHAT_PP + "weight";
|
||||
public static final String CHAT_GLOBALCHAT_PP_PREFIXES = CHAT_GLOBALCHAT_PP + "prefixes.";
|
||||
public static final String CHAT_GLOBALCHAT_PP_PREFIXES_CHECK = CHAT_GLOBALCHAT_PP_PREFIXES + "active";
|
||||
|
Loading…
Reference in New Issue
Block a user