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 ActionList colorActions;
|
||||||
|
|
||||||
public final boolean globalChatCheck;
|
public final boolean globalChatCheck;
|
||||||
|
public final boolean globalChatGlobalCheck;
|
||||||
|
public final boolean globalChatPlayerCheck;
|
||||||
public final EnginePlayerConfig globalChatEnginePlayerConfig;
|
public final EnginePlayerConfig globalChatEnginePlayerConfig;
|
||||||
public final float globalChatFrequencyFactor;
|
public final float globalChatFrequencyFactor;
|
||||||
public final float globalChatFrequencyWeight;
|
public final float globalChatFrequencyWeight;
|
||||||
@ -149,6 +151,8 @@ public class ChatConfig implements CheckConfig {
|
|||||||
colorActions = config.getActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR);
|
colorActions = config.getActionList(ConfPaths.CHAT_COLOR_ACTIONS, Permissions.CHAT_COLOR);
|
||||||
|
|
||||||
globalChatCheck = config.getBoolean(ConfPaths.CHAT_GLOBALCHAT_CHECK);
|
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);
|
globalChatEnginePlayerConfig = new EnginePlayerConfig(config);
|
||||||
globalChatFrequencyFactor = (float) config.getDouble(ConfPaths.CHAT_GLOBALCHAT_FREQUENCY_FACTOR);
|
globalChatFrequencyFactor = (float) config.getDouble(ConfPaths.CHAT_GLOBALCHAT_FREQUENCY_FACTOR);
|
||||||
globalChatFrequencyWeight = (float) config.getDouble(ConfPaths.CHAT_GLOBALCHAT_FREQUENCY_WEIGHT);
|
globalChatFrequencyWeight = (float) config.getDouble(ConfPaths.CHAT_GLOBALCHAT_FREQUENCY_WEIGHT);
|
||||||
|
@ -63,29 +63,34 @@ public class LetterEngine {
|
|||||||
final Map<String, Float> result = new HashMap<String, Float>();
|
final Map<String, Float> result = new HashMap<String, Float>();
|
||||||
|
|
||||||
// Global processors.
|
// Global processors.
|
||||||
for (final WordProcessor processor : processors){
|
if (cc.globalChatGlobalCheck){
|
||||||
try{
|
for (final WordProcessor processor : processors){
|
||||||
result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatGlobalWeight);
|
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());
|
catch( final Exception e){
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().warning("[NoCheatPlus] globalchat: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
continue;
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per player processors.
|
// Per player processors.
|
||||||
final EnginePlayerData engineData = dataMap.get(playerName, cc);
|
if (cc.globalChatPlayerCheck){
|
||||||
for (final WordProcessor processor : engineData.processors){
|
final EnginePlayerData engineData = dataMap.get(playerName, cc);
|
||||||
try{
|
for (final WordProcessor processor : engineData.processors){
|
||||||
result.put(processor.getProcessorName(), processor.process(letterCount) * cc.globalChatPlayerWeight);
|
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());
|
catch( final Exception e){
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().warning("[NoCheatPlus] globalchat: processor("+processor.getProcessorName()+") generated an exception: " + e.getClass().getSimpleName() + ": " + e.getMessage());
|
||||||
continue;
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ public abstract class DigestedWords extends AbstractWordProcessor{
|
|||||||
letters.clear();
|
letters.clear();
|
||||||
digits.clear();
|
digits.clear();
|
||||||
other.clear();
|
other.clear();
|
||||||
|
super.clear(); // Just for completeness.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final char[] toArray(final Collection<Character> chars){
|
public static final char[] toArray(final Collection<Character> chars){
|
||||||
|
@ -56,6 +56,7 @@ public class SimilarWordsBKL extends DigestedWords {
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
tree.clear();
|
tree.clear();
|
||||||
|
added = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,6 +58,7 @@ public class WordPrefixes extends DigestedWords{
|
|||||||
public void clear() {
|
public void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
tree.clear();
|
tree.clear();
|
||||||
|
added = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float getScore(final List<Character> chars, final long ts) {
|
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.)
|
// (Some of the following paths must be public for generic config reading.)
|
||||||
// Extended global checks.
|
// Extended global checks.
|
||||||
private static final String CHAT_GLOBALCHAT_GL = CHAT_GLOBALCHAT + "global.";
|
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_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 = CHAT_GLOBALCHAT_GL + "words.";
|
||||||
public static final String CHAT_GLOBALCHAT_GL_WORDS_CHECK = CHAT_GLOBALCHAT_GL_WORDS + "active";
|
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";
|
public static final String CHAT_GLOBALCHAT_GL_SIMILARITY_CHECK = CHAT_GLOBALCHAT_GL_SIMILARITY + "active";
|
||||||
// Extended per player checks.
|
// Extended per player checks.
|
||||||
private static final String CHAT_GLOBALCHAT_PP = CHAT_GLOBALCHAT + "player.";
|
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_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 = CHAT_GLOBALCHAT_PP + "prefixes.";
|
||||||
public static final String CHAT_GLOBALCHAT_PP_PREFIXES_CHECK = CHAT_GLOBALCHAT_PP_PREFIXES + "active";
|
public static final String CHAT_GLOBALCHAT_PP_PREFIXES_CHECK = CHAT_GLOBALCHAT_PP_PREFIXES + "active";
|
||||||
|
Loading…
Reference in New Issue
Block a user