diff options
author | md_5 <md_5@bigpond.com> | 2012-04-05 20:47:09 +1000 |
---|---|---|
committer | md_5 <md_5@bigpond.com> | 2012-04-05 20:47:09 +1000 |
commit | 2ce7f5726fc1261452c3d2f87def3e713422f38b (patch) | |
tree | a2c2edf1cc12123afbb579da1917bf246c0d1efe /EssentialsAntiCheat/src | |
parent | 3d3b57cb1b10b5e3215f52a3015b830c57111f85 (diff) | |
download | Essentials-2ce7f5726fc1261452c3d2f87def3e713422f38b.tar Essentials-2ce7f5726fc1261452c3d2f87def3e713422f38b.tar.gz Essentials-2ce7f5726fc1261452c3d2f87def3e713422f38b.tar.lz Essentials-2ce7f5726fc1261452c3d2f87def3e713422f38b.tar.xz Essentials-2ce7f5726fc1261452c3d2f87def3e713422f38b.zip |
Why are all these static methods final? Also what black magic is an enum set :O
Diffstat (limited to 'EssentialsAntiCheat/src')
4 files changed, 15 insertions, 94 deletions
diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/NoCheat.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/NoCheat.java index 29e1cdc22..5a05f78bc 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/NoCheat.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/NoCheat.java @@ -13,7 +13,6 @@ import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; import com.earth2me.essentials.anticheat.config.ConfigurationManager; import com.earth2me.essentials.anticheat.config.Permissions; import com.earth2me.essentials.anticheat.data.PlayerManager; -import com.earth2me.essentials.anticheat.debug.ActiveCheckPrinter; import com.earth2me.essentials.anticheat.debug.LagMeasureTask; import java.util.ArrayList; import java.util.List; @@ -78,9 +77,6 @@ public class NoCheat extends JavaPlugin implements Listener lagMeasureTask.start(); } - // Then print a list of active checks per world - ActiveCheckPrinter.printActiveChecks(this, eventManagers); - // register all listeners for (EventManager eventManager : eventManagers) { 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); diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/CheckUtil.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/CheckUtil.java index 390d2207d..30e9a3fba 100644 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/CheckUtil.java +++ b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/checks/CheckUtil.java @@ -2,7 +2,7 @@ package com.earth2me.essentials.anticheat.checks; import com.earth2me.essentials.anticheat.NoCheatPlayer; import com.earth2me.essentials.anticheat.data.PreciseLocation; -import java.util.HashSet; +import java.util.EnumSet; import java.util.Set; import net.minecraft.server.Block; import org.bukkit.Location; @@ -12,10 +12,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -/** - * Some stuff that's used by different checks or just too complex to keep in other places - * - */ public class CheckUtil { /** @@ -64,7 +60,7 @@ public class CheckUtil * @param limit * @return */ - public static final double reachCheck(final NoCheatPlayer player, final double targetX, final double targetY, final double targetZ, final double limit) + public static double reachCheck(final NoCheatPlayer player, final double targetX, final double targetY, final double targetZ, final double limit) { final Location eyes = player.getPlayer().getEyeLocation(); @@ -89,7 +85,7 @@ public class CheckUtil // Until I can think of a better way to determine if a block is solid or // not, this is what I'll do private static final int types[]; - private static final Set<Material> foods = new HashSet<Material>(); + private static final Set<Material> foods = EnumSet.noneOf(Material.class); static { @@ -190,7 +186,7 @@ public class CheckUtil * * @return */ - public static final int evaluateLocation(final World world, final PreciseLocation location) + public static int evaluateLocation(final World world, final PreciseLocation location) { final int lowerX = lowerBorder(location.x); @@ -230,7 +226,7 @@ public class CheckUtil * @param z * @return Returns INGROUND, ONGROUND, LIQUID, combination of the three or 0 */ - private static final int evaluateSimpleLocation(final World world, final int x, final int y, final int z) + private static int evaluateSimpleLocation(final World world, final int x, final int y, final int z) { // First we need to know about the block itself, the block @@ -284,32 +280,32 @@ public class CheckUtil return type; } - public static final boolean isSolid(final int value) + public static boolean isSolid(final int value) { return (value & SOLID) == SOLID; } - public static final boolean isLiquid(final int value) + public static boolean isLiquid(final int value) { return (value & LIQUID) == LIQUID; } - private static final boolean isNonSolid(final int value) + private static boolean isNonSolid(final int value) { return ((value & NONSOLID) == NONSOLID); } - private static final boolean isLadder(final int value) + private static boolean isLadder(final int value) { return ((value & LADDER) == LADDER); } - public static final boolean isOnGround(final int fromType) + public static boolean isOnGround(final int fromType) { return (fromType & ONGROUND) == ONGROUND; } - public static final boolean isInGround(final int fromType) + public static boolean isInGround(final int fromType) { return (fromType & INGROUND) == INGROUND; } @@ -320,7 +316,7 @@ public class CheckUtil * @param d1 * @return */ - private static final int lowerBorder(final double d1) + private static int lowerBorder(final double d1) { final double floor = Math.floor(d1); @@ -341,7 +337,7 @@ public class CheckUtil * @param d1 * @return */ - private static final int upperBorder(final double d1) + private static int upperBorder(final double d1) { final double floor = Math.floor(d1); diff --git a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java b/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java deleted file mode 100644 index 295acb9ef..000000000 --- a/EssentialsAntiCheat/src/com/earth2me/essentials/anticheat/debug/ActiveCheckPrinter.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.earth2me.essentials.anticheat.debug; - -import com.earth2me.essentials.anticheat.EventManager; -import com.earth2me.essentials.anticheat.NoCheat; -import com.earth2me.essentials.anticheat.config.ConfigurationCacheStore; -import java.util.List; -import org.bukkit.World; - - -/** - * Prints the list of active checks per world on startup, if requested - * - */ -public class ActiveCheckPrinter -{ - public static void printActiveChecks(NoCheat plugin, List<EventManager> eventManagers) - { - - boolean introPrinted = false; - - // Print active checks for NoCheat, if needed. - for (World world : plugin.getServer().getWorlds()) - { - - StringBuilder line = new StringBuilder(" ").append(world.getName()).append(": "); - - int length = line.length(); - - ConfigurationCacheStore cc = plugin.getConfig(world); - - if (!cc.logging.showactivechecks) - { - continue; - } - - for (EventManager em : eventManagers) - { - if (em.getActiveChecks(cc).isEmpty()) - { - continue; - } - - for (String active : em.getActiveChecks(cc)) - { - line.append(active).append(' '); - } - - if (!introPrinted) - { - plugin.getLogger().info("Active Checks: "); - introPrinted = true; - } - - plugin.getServer().getLogger().info(line.toString()); - - line = new StringBuilder(length); - - for (int i = 0; i < length; i++) - { - line.append(' '); - } - } - - } - } -} |