1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-08 21:50:45 +02:00

Why are all these static methods final? Also what black magic is an enum set :O

This commit is contained in:
md_5
2012-04-05 20:47:09 +10:00
parent 3d3b57cb1b
commit 2ce7f5726f
4 changed files with 15 additions and 94 deletions

View File

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

View File

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

View File

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

View File

@@ -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(' ');
}
}
}
}
}