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:
asofold 2012-09-08 14:15:56 +02:00
parent 128836be65
commit fa8f1cc4cb
6 changed files with 31 additions and 17 deletions

View File

@ -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);

View File

@ -63,29 +63,34 @@ public class LetterEngine {
final Map<String, Float> result = new HashMap<String, Float>();
// 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;
}

View File

@ -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){

View File

@ -56,6 +56,7 @@ public class SimilarWordsBKL extends DigestedWords {
public void clear() {
super.clear();
tree.clear();
added = 0;
}
@Override

View File

@ -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) {

View File

@ -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";