diff options
author | md_5 <md_5@bigpond.com> | 2012-03-12 10:39:36 +1100 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-03-12 10:39:36 +1100 |
commit | 78f4820876f42f7b50bf88f64afd45bee939e4e4 (patch) | |
tree | 317cd3bcc63fc9e86a6efbcb5e13a50ed9efbaaf /EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/chat/ChatCheck.java | |
parent | 26409058467e9f34aa65a08df3c68a58129d22ba (diff) | |
download | Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar.gz Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar.lz Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.tar.xz Essentials-78f4820876f42f7b50bf88f64afd45bee939e4e4.zip |
Initial formatted and slightly tweaked version of @evenprime 's NoCheat. Will be intergrated into the main Essentials as soon as possible
Diffstat (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/chat/ChatCheck.java')
-rw-r--r-- | EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/chat/ChatCheck.java | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/chat/ChatCheck.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/chat/ChatCheck.java new file mode 100644 index 000000000..b1f14deec --- /dev/null +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/chat/ChatCheck.java @@ -0,0 +1,79 @@ +package com.earth2me.essentials.anticheat.checks.chat; + +import com.earth2me.essentials.anticheat.NoCheat; +import com.earth2me.essentials.anticheat.NoCheatPlayer; +import com.earth2me.essentials.anticheat.actions.ParameterName; +import com.earth2me.essentials.anticheat.checks.Check; +import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; +import com.earth2me.essentials.anticheat.data.DataStore; + + +/** + * Abstract base class for Chat checks, provides some convenience methods for access to data and config that's relevant + * to this checktype + */ +public abstract class ChatCheck extends Check +{ + private static final String id = "chat"; + + public ChatCheck(NoCheat plugin, String name) + { + super(plugin, id, name); + } + + @Override + public String getParameter(ParameterName wildcard, NoCheatPlayer player) + { + + if (wildcard == ParameterName.TEXT) + // Filter colors from the players message when logging + { + return getData(player).message.replaceAll("\302\247.", "").replaceAll("\247.", ""); + } + else + { + return super.getParameter(wildcard, player); + } + } + + /** + * Get the "ChatData" object that belongs to the player. Will ensure that such a object exists and if not, create + * one + * + * @param player + * @return + */ + public static ChatData getData(NoCheatPlayer player) + { + DataStore base = player.getDataStore(); + ChatData data = base.get(id); + if (data == null) + { + data = new ChatData(); + base.set(id, data); + } + return data; + } + + /** + * Get the ChatConfig object that belongs to the world that the player currently resides in. + * + * @param player + * @return + */ + public static ChatConfig getConfig(NoCheatPlayer player) + { + return getConfig(player.getConfigurationStore()); + } + + public static ChatConfig getConfig(ConfigurationCacheStore cache) + { + ChatConfig config = cache.get(id); + if (config == null) + { + config = new ChatConfig(cache.getConfiguration()); + cache.set(id, config); + } + return config; + } +} |