From 2ce7f5726fc1261452c3d2f87def3e713422f38b Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 5 Apr 2012 20:47:09 +1000 Subject: Why are all these static methods final? Also what black magic is an enum set :O --- .../src/com/earth2me/essentials/anticheat/checks/Check.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java') diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java index 5482efa5a..069980568 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java @@ -14,10 +14,6 @@ import org.bukkit.Location; import org.bukkit.command.CommandException; -/** - * The abstract Check class, providing some basic functionality - * - */ public abstract class Check { private final String name; @@ -36,7 +32,6 @@ public abstract class Check * Execute some actions for the specified player * * @param player - * @param actions * @return */ protected final boolean executeActions(NoCheatPlayer player, ActionList actionList, double violationLevel) @@ -92,7 +87,7 @@ public abstract class Check player.getDataStore().getStatistics().increment(id, vl); } - private final void executeLogAction(LogAction l, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) + private void executeLogAction(LogAction l, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) { if (!cc.logging.active) @@ -104,7 +99,7 @@ public abstract class Check Bukkit.getServer().getPluginManager().callEvent(new NoCheatLogEvent(cc.logging.prefix, l.getLogMessage(player, check), cc.logging.toConsole && l.toConsole(), cc.logging.toChat && l.toChat(), cc.logging.toFile && l.toFile())); } - private final void executeConsoleCommand(ConsolecommandAction action, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) + private void executeConsoleCommand(ConsolecommandAction action, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) { final String command = action.getCommand(player, check); -- cgit v1.2.3 From b69a16bcf0abac1ebd2ca3d35520cfcb5b433e88 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 16 Apr 2012 16:51:29 +1000 Subject: Remove EssentialsAntiCheat pending the release of a better alternative in 2.0 by @neatmonster --- .../essentials/anticheat/checks/Check.java | 154 --------------------- 1 file changed, 154 deletions(-) delete mode 100644 EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java (limited to 'EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java') diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java deleted file mode 100644 index 069980568..000000000 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/Check.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.earth2me.essentials.anticheat.checks; - -import com.earth2me.essentials.anticheat.NoCheat; -import com.earth2me.essentials.anticheat.NoCheatLogEvent; -import com.earth2me.essentials.anticheat.NoCheatPlayer; -import com.earth2me.essentials.anticheat.actions.Action; -import com.earth2me.essentials.anticheat.actions.ParameterName; -import com.earth2me.essentials.anticheat.actions.types.*; -import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; -import com.earth2me.essentials.anticheat.data.Statistics.Id; -import java.util.Locale; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.command.CommandException; - - -public abstract class Check -{ - private final String name; - // used to bundle information of multiple checks - private final String groupId; - protected final NoCheat plugin; - - public Check(NoCheat plugin, String groupId, String name) - { - this.plugin = plugin; - this.groupId = groupId; - this.name = name; - } - - /** - * Execute some actions for the specified player - * - * @param player - * @return - */ - protected final boolean executeActions(NoCheatPlayer player, ActionList actionList, double violationLevel) - { - - boolean special = false; - - // Get the to be executed actions - Action[] actions = actionList.getActions(violationLevel); - - final long time = System.currentTimeMillis() / 1000L; - - // The configuration will be needed too - final ConfigurationCacheStore cc = player.getConfigurationStore(); - - for (Action ac : actions) - { - if (player.getExecutionHistory().executeAction(groupId, ac, time)) - { - // The executionHistory said it really is time to execute the - // action, find out what it is and do what is needed - if (ac instanceof LogAction && !player.hasPermission(actionList.permissionSilent)) - { - executeLogAction((LogAction)ac, this, player, cc); - } - else if (ac instanceof SpecialAction) - { - special = true; - } - else if (ac instanceof ConsolecommandAction) - { - executeConsoleCommand((ConsolecommandAction)ac, this, player, cc); - } - else if (ac instanceof DummyAction) - { - // nothing - it's a "DummyAction" after all - } - } - } - - return special; - } - - /** - * Collect information about the players violations - * - * @param player - * @param id - * @param vl - */ - protected void incrementStatistics(NoCheatPlayer player, Id id, double vl) - { - player.getDataStore().getStatistics().increment(id, vl); - } - - private void executeLogAction(LogAction l, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) - { - - if (!cc.logging.active) - { - return; - } - - // Fire one of our custom "Log" Events - Bukkit.getServer().getPluginManager().callEvent(new NoCheatLogEvent(cc.logging.prefix, l.getLogMessage(player, check), cc.logging.toConsole && l.toConsole(), cc.logging.toChat && l.toChat(), cc.logging.toFile && l.toFile())); - } - - private void executeConsoleCommand(ConsolecommandAction action, Check check, NoCheatPlayer player, ConfigurationCacheStore cc) - { - final String command = action.getCommand(player, check); - - try - { - plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command); - } - catch (CommandException e) - { - plugin.getLogger().warning("failed to execute the command '" + command + "': " + e.getMessage() + ", please check if everything is setup correct."); - } - catch (Exception e) - { - // I don't care in this case, your problem if your command fails - } - } - - /** - * Replace a parameter for commands or log actions with an actual value. Individual checks should override this to - * get their own parameters handled too. - * - * @param wildcard - * @param player - * @return - */ - public String getParameter(ParameterName wildcard, NoCheatPlayer player) - { - - if (wildcard == ParameterName.PLAYER) - { - return player.getName(); - } - else if (wildcard == ParameterName.CHECK) - { - return name; - } - else if (wildcard == ParameterName.LOCATION) - { - Location l = player.getPlayer().getLocation(); - return String.format(Locale.US, "%.2f,%.2f,%.2f", l.getX(), l.getY(), l.getZ()); - } - else if (wildcard == ParameterName.WORLD) - { - return player.getPlayer().getWorld().getName(); - } - else - { - return "the Author was lazy and forgot to define " + wildcard + "."; - } - - } -} -- cgit v1.2.3