diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java index 3669cd7e..a7b98915 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/ChatConfig.java @@ -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); diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java index fec2d64e..3a99949f 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/LetterEngine.java @@ -63,29 +63,34 @@ public class LetterEngine { final Map result = new HashMap(); // Global processors. - for (final WordProcessor processor : processors){ - try{ - result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatGlobalWeight); - } - catch( final Exception e){ - Bukkit.getLogger().warning("[NoCheatPlus] globalchat: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage()); - e.printStackTrace(); - continue; + if (cc.globalChatGlobalCheck){ + for (final WordProcessor processor : processors){ + try{ + result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatGlobalWeight); + } + catch( final Exception e){ + Bukkit.getLogger().warning("[NoCheatPlus] globalchat: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage()); + e.printStackTrace(); + continue; + } } } // Per player processors. - final EnginePlayerData engineData = dataMap.get(playerName, cc); - for (final WordProcessor processor : engineData.processors){ - try{ - result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatPlayerWeight); - } - catch( final Exception e){ - Bukkit.getLogger().warning("[NoCheatPlus] globalchat: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage()); - e.printStackTrace(); - continue; + if (cc.globalChatPlayerCheck){ + final EnginePlayerData engineData = dataMap.get(playerName, cc); + for (final WordProcessor processor : engineData.processors){ + try{ + result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatPlayerWeight); + } + catch( final Exception e){ + Bukkit.getLogger().warning("[NoCheatPlus] globalchat: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage()); + e.printStackTrace(); + continue; + } } } + return result; } diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/DigestedWords.java b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/DigestedWords.java index 8cab7c77..dd4ef4f6 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/DigestedWords.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/DigestedWords.java @@ -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 chars){ diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/SimilarWordsBKL.java b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/SimilarWordsBKL.java index aa66714d..0a91216e 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/SimilarWordsBKL.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/SimilarWordsBKL.java @@ -56,6 +56,7 @@ public class SimilarWordsBKL extends DigestedWords { public void clear() { super.clear(); tree.clear(); + added = 0; } @Override diff --git a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/WordPrefixes.java b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/WordPrefixes.java index 392dcf9b..6529b963 100644 --- a/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/WordPrefixes.java +++ b/src/fr/neatmonster/nocheatplus/checks/chat/analysis/engine/processors/WordPrefixes.java @@ -58,6 +58,7 @@ public class WordPrefixes extends DigestedWords{ public void clear() { super.clear(); tree.clear(); + added = 0; } protected float getScore(final List chars, final long ts) { diff --git a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java index a7ef84e5..3b78f905 100644 --- a/src/fr/neatmonster/nocheatplus/config/ConfPaths.java +++ b/src/fr/neatmonster/nocheatplus/config/ConfPaths.java @@ -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";