mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 14:38:46 +00:00
Test commit please ignore
Formatting for everything
This commit is contained in:
1 parent
8a5d531857
commit
f00130f3f7
17 files changed
+219
-119
No files matched your search
@@ -31,7 +31,6 @@ import org.bukkit.entity.Player;
|
|||||||
* Developer's interface for all things AntiCheat.
|
* Developer's interface for all things AntiCheat.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public class AnticheatAPI
|
public class AnticheatAPI
|
||||||
{
|
{
|
||||||
private static CheckManager chk = Anticheat.getManager().getCheckManager();
|
private static CheckManager chk = Anticheat.getManager().getCheckManager();
|
||||||
@@ -43,7 +42,8 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Start running a certain check
|
* Start running a certain check
|
||||||
*
|
*
|
||||||
* @param type Check to start watching for
|
* @param type
|
||||||
|
* Check to start watching for
|
||||||
*/
|
*/
|
||||||
public static void activateCheck(CheckType type)
|
public static void activateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,8 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Stop running a certain check
|
* Stop running a certain check
|
||||||
*
|
*
|
||||||
* @param type Check to stop watching for
|
* @param type
|
||||||
|
* Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void deactivateCheck(CheckType type)
|
public static void deactivateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
@@ -63,7 +64,8 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Find out if a check is currently being watched for
|
* Find out if a check is currently being watched for
|
||||||
*
|
*
|
||||||
* @param type Type to check
|
* @param type
|
||||||
|
* Type to check
|
||||||
* @return true if plugin is watching for this check
|
* @return true if plugin is watching for this check
|
||||||
*/
|
*/
|
||||||
public static boolean isActive(CheckType type)
|
public static boolean isActive(CheckType type)
|
||||||
@@ -74,8 +76,10 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Allow a player to skip a certain check
|
* Allow a player to skip a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to stop watching
|
* @param player
|
||||||
* @param type Check to stop watching for
|
* Player to stop watching
|
||||||
|
* @param type
|
||||||
|
* Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void exemptPlayer(Player player, CheckType type)
|
public static void exemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
@@ -85,8 +89,10 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Stop allowing a player to skip a certain check
|
* Stop allowing a player to skip a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to start watching
|
* @param player
|
||||||
* @param type Check to start watching for
|
* Player to start watching
|
||||||
|
* @param type
|
||||||
|
* Check to start watching for
|
||||||
*/
|
*/
|
||||||
public static void unexemptPlayer(Player player, CheckType type)
|
public static void unexemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
@@ -96,8 +102,10 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Find out if a player is currently exempt from a certain check
|
* Find out if a player is currently exempt from a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player
|
||||||
* @param type Type to check
|
* Player to check
|
||||||
|
* @param type
|
||||||
|
* Type to check
|
||||||
* @return true if plugin is ignoring this check on this player
|
* @return true if plugin is ignoring this check on this player
|
||||||
*/
|
*/
|
||||||
public static boolean isExempt(Player player, CheckType type)
|
public static boolean isExempt(Player player, CheckType type)
|
||||||
@@ -106,11 +114,16 @@ public class AnticheatAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a check will occur for a player. This checks if they are being tracked, the check is active, the player isn't exempt from the check, and the player doesn't have override permission.
|
* Find out if a check will occur for a player. This checks if they are
|
||||||
|
* being tracked, the check is active, the player isn't exempt from the
|
||||||
|
* check, and the player doesn't have override permission.
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player
|
||||||
* @param type Type to check
|
* Player to check
|
||||||
* @return true if plugin will check this player, and that all things allow it to happen.
|
* @param type
|
||||||
|
* Type to check
|
||||||
|
* @return true if plugin will check this player, and that all things allow
|
||||||
|
* it to happen.
|
||||||
*/
|
*/
|
||||||
public boolean willCheck(Player player, CheckType type)
|
public boolean willCheck(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
@@ -120,9 +133,11 @@ public class AnticheatAPI
|
|||||||
//PlayerManager API
|
//PlayerManager API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player's integer hack level (0-19 = Low, 20-49 = Medium, 50-60 = High)
|
* Get a player's integer hack level (0-19 = Low, 20-49 = Medium, 50-60 =
|
||||||
|
* High)
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player
|
||||||
|
* Player to check
|
||||||
* @return player's hack level
|
* @return player's hack level
|
||||||
*/
|
*/
|
||||||
public static int getLevel(Player player)
|
public static int getLevel(Player player)
|
||||||
@@ -137,8 +152,10 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Set a player's hack level (Min = 0, Max = 60)
|
* Set a player's hack level (Min = 0, Max = 60)
|
||||||
*
|
*
|
||||||
* @param player Player to set
|
* @param player
|
||||||
* @param level Level to set to
|
* Player to set
|
||||||
|
* @param level
|
||||||
|
* Level to set to
|
||||||
*/
|
*/
|
||||||
public static void setLevel(Player player, int level)
|
public static void setLevel(Player player, int level)
|
||||||
{
|
{
|
||||||
@@ -150,7 +167,8 @@ public class AnticheatAPI
|
|||||||
/**
|
/**
|
||||||
* Find out if a player is detected as using xray hacks (on any ore)
|
* Find out if a player is detected as using xray hacks (on any ore)
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player
|
||||||
|
* Player to check
|
||||||
* @return true if the player has any xray anomalies.
|
* @return true if the player has any xray anomalies.
|
||||||
*/
|
*/
|
||||||
public static boolean isXrayer(Player player)
|
public static boolean isXrayer(Player player)
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
|
|
||||||
|
|
||||||
public class EntityListener extends EventListener
|
public class EntityListener extends EventListener
|
||||||
{
|
{
|
||||||
private final Backend backend = getBackend();
|
private final Backend backend = getBackend();
|
||||||
|
|||||||
@@ -114,7 +114,8 @@ public class EventListener implements Listener
|
|||||||
return BACKEND;
|
return BACKEND;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerManager getPlayerManager() {
|
public static PlayerManager getPlayerManager()
|
||||||
|
{
|
||||||
return PLAYER_MANAGER;
|
return PLAYER_MANAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ public class PlayerListener extends EventListener
|
|||||||
log("tried avoid fall damage.", player, CheckType.NOFALL);
|
log("tried avoid fall damage.", player, CheckType.NOFALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void checkSpeed(PlayerMoveEvent event)
|
public void checkSpeed(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,9 @@ public class AnticheatManager
|
|||||||
}
|
}
|
||||||
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
||||||
fileHandler.setFormatter(new FileFormatter());
|
fileHandler.setFormatter(new FileFormatter());
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
FILE_LOGGER.setUseParentHandlers(false);
|
FILE_LOGGER.setUseParentHandlers(false);
|
||||||
@@ -116,6 +118,7 @@ public class AnticheatManager
|
|||||||
{
|
{
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close()
|
public static void close()
|
||||||
{
|
{
|
||||||
fileHandler.close();
|
fileHandler.close();
|
||||||
|
|||||||
@@ -642,8 +642,7 @@ public class Backend
|
|||||||
lastZeroHitPlace.put(name, lastZeroHitPlace.get(name) + 1);
|
lastZeroHitPlace.put(name, lastZeroHitPlace.get(name) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(thisTime < FASTPLACE_TIMEMAX && lastTime < FASTPLACE_TIMEMAX
|
if (thisTime < FASTPLACE_TIMEMAX && lastTime < FASTPLACE_TIMEMAX && nocheck && lastZeroHitPlace.get(name) > FASTPLACE_ZEROLIMIT)
|
||||||
&& nocheck && lastZeroHitPlace.get(name) > FASTPLACE_ZEROLIMIT)
|
|
||||||
{
|
{
|
||||||
lastBlockPlaceTime.put(name, (time - last));
|
lastBlockPlaceTime.put(name, (time - last));
|
||||||
lastBlockPlaced.put(name, time);
|
lastBlockPlaced.put(name, time);
|
||||||
@@ -784,7 +783,8 @@ public class Backend
|
|||||||
if (velocitytrack.containsKey(player.getName()))
|
if (velocitytrack.containsKey(player.getName()))
|
||||||
{
|
{
|
||||||
velocitytrack.put(player.getName(), velocitytrack.get(player.getName()) + 1);
|
velocitytrack.put(player.getName(), velocitytrack.get(player.getName()) + 1);
|
||||||
if(velocitytrack.get(player.getName()) > VELOCITY_MAXTIMES) {
|
if (velocitytrack.get(player.getName()) > VELOCITY_MAXTIMES)
|
||||||
|
{
|
||||||
velocitized.put(player.getName(), System.currentTimeMillis() + VELOCITY_PREVENT);
|
velocitized.put(player.getName(), System.currentTimeMillis() + VELOCITY_PREVENT);
|
||||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||||
{
|
{
|
||||||
@@ -956,6 +956,7 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}, time);
|
}, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkChatLevel(Player player, int amount)
|
private void checkChatLevel(Player player, int amount)
|
||||||
{
|
{
|
||||||
if (amount >= CHAT_WARN_LEVEL)
|
if (amount >= CHAT_WARN_LEVEL)
|
||||||
@@ -990,6 +991,7 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increment(Player player, Map<String, Integer> map, int num)
|
public void increment(Player player, Map<String, Integer> map, int num)
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
* The manager that AntiCheat will check with to see if it should watch certain
|
||||||
|
* checks and certain players.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CheckManager
|
public class CheckManager
|
||||||
@@ -86,10 +87,7 @@ public class CheckManager
|
|||||||
|
|
||||||
public boolean willCheck(Player player, CheckType type)
|
public boolean willCheck(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return isActive(type)
|
return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) && !type.checkPermission(player);
|
||||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
|
||||||
&& !isExempt(player, type)
|
|
||||||
&& !type.checkPermission(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExempt()
|
public int getExempt()
|
||||||
|
|||||||
@@ -23,13 +23,11 @@ import java.util.Map;
|
|||||||
import net.h31ix.anticheat.Permission;
|
import net.h31ix.anticheat.Permission;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* All the types of checks and their corresponding permission nodes.
|
* All the types of checks and their corresponding permission nodes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public enum CheckType
|
public enum CheckType
|
||||||
{
|
{
|
||||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ public class Distance
|
|||||||
l2 = from;
|
l2 = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fromY() {
|
public double fromY()
|
||||||
|
{
|
||||||
return l2.getY();
|
return l2.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double toY() {
|
public double toY()
|
||||||
|
{
|
||||||
return l1.getY();
|
return l1.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The manager that AntiCheat will use to monitor player's hack levels and to execute events that the admin has set
|
* The manager that AntiCheat will use to monitor player's hack levels and to
|
||||||
|
* execute events that the admin has set
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlayerManager
|
public class PlayerManager
|
||||||
@@ -43,7 +44,8 @@ public class PlayerManager
|
|||||||
private static final int LEVEL_MAX = 60;
|
private static final int LEVEL_MAX = 60;
|
||||||
private static final int LEVEL_BOOST = 5;
|
private static final int LEVEL_BOOST = 5;
|
||||||
|
|
||||||
public PlayerManager(AnticheatManager instance) {
|
public PlayerManager(AnticheatManager instance)
|
||||||
|
{
|
||||||
config = instance.getConfiguration();
|
config = instance.getConfiguration();
|
||||||
lang = config.getLang();
|
lang = config.getLang();
|
||||||
}
|
}
|
||||||
@@ -53,6 +55,7 @@ public class PlayerManager
|
|||||||
execute("Medium", player);
|
execute("Medium", player);
|
||||||
Utilities.alert(formatArray(lang.getMediumAlert(), player, ChatColor.YELLOW));
|
Utilities.alert(formatArray(lang.getMediumAlert(), player, ChatColor.YELLOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reactHigh(Player player)
|
private static void reactHigh(Player player)
|
||||||
{
|
{
|
||||||
execute("High", player);
|
execute("High", player);
|
||||||
@@ -164,6 +167,7 @@ public class PlayerManager
|
|||||||
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(), player, ChatColor.RED));
|
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(), player, ChatColor.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String[] formatArray(String[] array, Player player, ChatColor color)
|
private static String[] formatArray(String[] array, Player player, ChatColor color)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < array.length; i++)
|
for (int i = 0; i < array.length; i++)
|
||||||
@@ -172,6 +176,7 @@ public class PlayerManager
|
|||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatString(String string, Player player, ChatColor color)
|
private static String formatString(String string, Player player, ChatColor color)
|
||||||
{
|
{
|
||||||
return color + string.replaceAll("&player", ChatColor.WHITE + player.getName() + color);
|
return color + string.replaceAll("&player", ChatColor.WHITE + player.getName() + color);
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend.
|
* The metrics class obtains data about a plugin and submits statistics about it
|
||||||
|
* to the metrics backend.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Public methods provided by this class:
|
* Public methods provided by this class:
|
||||||
@@ -52,7 +53,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
* void start(); <br/>
|
* void start(); <br/>
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
public class Metrics {
|
public class Metrics
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current revision number
|
* The current revision number
|
||||||
@@ -75,8 +77,8 @@ public class Metrics {
|
|||||||
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
|
* The separator to use for custom data. This MUST NOT change unless you are
|
||||||
* version of metrics and want to change it.
|
* hosting your own version of metrics and want to change it.
|
||||||
*/
|
*/
|
||||||
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||||
|
|
||||||
@@ -96,7 +98,8 @@ public class Metrics {
|
|||||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default graph, used for addCustomData when you don't want a specific graph
|
* The default graph, used for addCustomData when you don't want a specific
|
||||||
|
* graph
|
||||||
*/
|
*/
|
||||||
private final Graph defaultGraph = new Graph("Default");
|
private final Graph defaultGraph = new Graph("Default");
|
||||||
|
|
||||||
@@ -110,8 +113,10 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private final String guid;
|
private final String guid;
|
||||||
|
|
||||||
public Metrics(Plugin plugin) throws IOException {
|
public Metrics(Plugin plugin) throws IOException
|
||||||
if (plugin == null) {
|
{
|
||||||
|
if (plugin == null)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Plugin cannot be null");
|
throw new IllegalArgumentException("Plugin cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +131,8 @@ public class Metrics {
|
|||||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||||
|
|
||||||
// Do we need to create the file?
|
// Do we need to create the file?
|
||||||
if (configuration.get("guid", null) == null) {
|
if (configuration.get("guid", null) == null)
|
||||||
|
{
|
||||||
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
||||||
configuration.save(file);
|
configuration.save(file);
|
||||||
}
|
}
|
||||||
@@ -136,14 +142,18 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs
|
* Construct and create a Graph that can be used to separate specific
|
||||||
* on the metrics website. Plotters can be added to the graph object returned.
|
* plotters to their own graphs on the metrics website. Plotters can be
|
||||||
|
* added to the graph object returned.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
* @return Graph object created. Will never return NULL under normal
|
||||||
|
* circumstances unless bad parameters are given
|
||||||
*/
|
*/
|
||||||
public Graph createGraph(String name) {
|
public Graph createGraph(String name)
|
||||||
if (name == null) {
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Graph name cannot be null");
|
throw new IllegalArgumentException("Graph name cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +172,10 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @param plotter
|
* @param plotter
|
||||||
*/
|
*/
|
||||||
public void addCustomData(Plotter plotter) {
|
public void addCustomData(Plotter plotter)
|
||||||
if (plotter == null) {
|
{
|
||||||
|
if (plotter == null)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Plotter cannot be null");
|
throw new IllegalArgumentException("Plotter cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,23 +187,29 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send
|
* Start measuring statistics. This will immediately create an async
|
||||||
* the initial data to the metrics backend, and then after that it will post in increments of
|
* repeating task as the plugin and send the initial data to the metrics
|
||||||
* PING_INTERVAL * 1200 ticks.
|
* backend, and then after that it will post in increments of PING_INTERVAL
|
||||||
|
* * 1200 ticks.
|
||||||
*/
|
*/
|
||||||
public void start() {
|
public void start()
|
||||||
|
{
|
||||||
// Did we opt out?
|
// Did we opt out?
|
||||||
if (configuration.getBoolean("opt-out", false)) {
|
if (configuration.getBoolean("opt-out", false))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin hitting the server with glorious data
|
// Begin hitting the server with glorious data
|
||||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
|
||||||
|
{
|
||||||
private boolean firstPost = true;
|
private boolean firstPost = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||||
// it is not a interval ping, so it evaluates to FALSE
|
// it is not a interval ping, so it evaluates to FALSE
|
||||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||||
@@ -200,7 +218,9 @@ public class Metrics {
|
|||||||
// After the first post we set firstPost to false
|
// After the first post we set firstPost to false
|
||||||
// Each post thereafter will be a ping
|
// Each post thereafter will be a ping
|
||||||
firstPost = false;
|
firstPost = false;
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
System.err.println("[Metrics] " + e.getMessage());
|
System.err.println("[Metrics] " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,35 +230,36 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Generic method that posts a plugin to the metrics website
|
* Generic method that posts a plugin to the metrics website
|
||||||
*/
|
*/
|
||||||
private void postPlugin(boolean isPing) throws IOException {
|
private void postPlugin(boolean isPing) throws IOException
|
||||||
|
{
|
||||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||||
PluginDescriptionFile description = plugin.getDescription();
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
|
||||||
// Construct the post data
|
// Construct the post data
|
||||||
String data = encode("guid") + '=' + encode(guid)
|
String data = encode("guid") + '=' + encode(guid) + encodeDataPair("version", description.getVersion().split("-b")[0]) + encodeDataPair("server", Bukkit.getVersion()) + encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length)) + encodeDataPair("revision", String.valueOf(REVISION));
|
||||||
+ encodeDataPair("version", description.getVersion().split("-b")[0])
|
|
||||||
+ encodeDataPair("server", Bukkit.getVersion())
|
|
||||||
+ encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length))
|
|
||||||
+ encodeDataPair("revision", String.valueOf(REVISION));
|
|
||||||
|
|
||||||
// If we're pinging, append it
|
// If we're pinging, append it
|
||||||
if (isPing) {
|
if (isPing)
|
||||||
|
{
|
||||||
data += encodeDataPair("ping", "true");
|
data += encodeDataPair("ping", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||||
// inside of the graph (e.g plotters)
|
// inside of the graph (e.g plotters)
|
||||||
synchronized (graphs) {
|
synchronized (graphs)
|
||||||
|
{
|
||||||
Iterator<Graph> iter = graphs.iterator();
|
Iterator<Graph> iter = graphs.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
Graph graph = iter.next();
|
Graph graph = iter.next();
|
||||||
|
|
||||||
// Because we have a lock on the graphs set already, it is reasonable to assume
|
// Because we have a lock on the graphs set already, it is reasonable to assume
|
||||||
// that our lock transcends down to the individual plotters in the graphs also.
|
// that our lock transcends down to the individual plotters in the graphs also.
|
||||||
// Because our methods are private, no one but us can reasonably access this list
|
// Because our methods are private, no one but us can reasonably access this list
|
||||||
// without reflection so this is a safe assumption without adding more code.
|
// without reflection so this is a safe assumption without adding more code.
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
for (Plotter plotter : graph.getPlotters())
|
||||||
|
{
|
||||||
// The key name to send to the metrics server
|
// The key name to send to the metrics server
|
||||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||||
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||||
@@ -262,9 +283,12 @@ public class Metrics {
|
|||||||
|
|
||||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||||
// It does not reroute POST requests so we need to go around it
|
// It does not reroute POST requests so we need to go around it
|
||||||
if (isMineshafterPresent()) {
|
if (isMineshafterPresent())
|
||||||
|
{
|
||||||
connection = url.openConnection(Proxy.NO_PROXY);
|
connection = url.openConnection(Proxy.NO_PROXY);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
connection = url.openConnection();
|
connection = url.openConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,18 +307,25 @@ public class Metrics {
|
|||||||
writer.close();
|
writer.close();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
if (response.startsWith("ERR")) {
|
if (response.startsWith("ERR"))
|
||||||
|
{
|
||||||
throw new IOException(response); //Throw the exception
|
throw new IOException(response); //Throw the exception
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Is this the first update this hour?
|
// Is this the first update this hour?
|
||||||
if (response.contains("OK This is your first update this hour")) {
|
if (response.contains("OK This is your first update this hour"))
|
||||||
synchronized (graphs) {
|
{
|
||||||
|
synchronized (graphs)
|
||||||
|
{
|
||||||
Iterator<Graph> iter = graphs.iterator();
|
Iterator<Graph> iter = graphs.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
Graph graph = iter.next();
|
Graph graph = iter.next();
|
||||||
|
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
for (Plotter plotter : graph.getPlotters())
|
||||||
|
{
|
||||||
plotter.reset();
|
plotter.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,22 +336,29 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
* Check if mineshafter is present. If it is, we need to bypass it to send
|
||||||
|
* POST requests
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isMineshafterPresent() {
|
private boolean isMineshafterPresent()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Class.forName("mineshafter.MineServer");
|
Class.forName("mineshafter.MineServer");
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
|
* <p>
|
||||||
* key/value pair MUST be included manually, e.g:</p>
|
* Encode a key/value data pair to be used in a HTTP post request. This
|
||||||
|
* INCLUDES a & so the first key/value pair MUST be included manually, e.g:
|
||||||
|
* </p>
|
||||||
* <code>
|
* <code>
|
||||||
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
||||||
* </code>
|
* </code>
|
||||||
@@ -329,7 +367,8 @@ public class Metrics {
|
|||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException {
|
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException
|
||||||
|
{
|
||||||
return '&' + encode(key) + '=' + encode(value);
|
return '&' + encode(key) + '=' + encode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,18 +378,20 @@ public class Metrics {
|
|||||||
* @param text
|
* @param text
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String encode(String text) throws UnsupportedEncodingException {
|
private static String encode(String text) throws UnsupportedEncodingException
|
||||||
|
{
|
||||||
return URLEncoder.encode(text, "UTF-8");
|
return URLEncoder.encode(text, "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a custom graph on the website
|
* Represents a custom graph on the website
|
||||||
*/
|
*/
|
||||||
public static class Graph {
|
public static class Graph
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The graph's name, alphanumeric and spaces only :)
|
* The graph's name, alphanumeric and spaces only :) If it does not
|
||||||
* If it does not comply to the above when submitted, it is rejected
|
* comply to the above when submitted, it is rejected
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@@ -359,7 +400,8 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||||
|
|
||||||
private Graph(String name) {
|
private Graph(String name)
|
||||||
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,7 +410,8 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName()
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +420,8 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @param plotter
|
* @param plotter
|
||||||
*/
|
*/
|
||||||
public void addPlotter(Plotter plotter) {
|
public void addPlotter(Plotter plotter)
|
||||||
|
{
|
||||||
plotters.add(plotter);
|
plotters.add(plotter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +430,8 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @param plotter
|
* @param plotter
|
||||||
*/
|
*/
|
||||||
public void removePlotter(Plotter plotter) {
|
public void removePlotter(Plotter plotter)
|
||||||
|
{
|
||||||
plotters.remove(plotter);
|
plotters.remove(plotter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,18 +440,22 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Plotter> getPlotters() {
|
public Set<Plotter> getPlotters()
|
||||||
|
{
|
||||||
return Collections.unmodifiableSet(plotters);
|
return Collections.unmodifiableSet(plotters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode()
|
||||||
|
{
|
||||||
return name.hashCode();
|
return name.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object)
|
||||||
if (!(object instanceof Graph)) {
|
{
|
||||||
|
if (!(object instanceof Graph))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,7 +468,8 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Interface used to collect custom data for a plugin
|
* Interface used to collect custom data for a plugin
|
||||||
*/
|
*/
|
||||||
public static abstract class Plotter {
|
public static abstract class Plotter
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plot's name
|
* The plot's name
|
||||||
@@ -429,7 +479,8 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Construct a plotter with the default plot name
|
* Construct a plotter with the default plot name
|
||||||
*/
|
*/
|
||||||
public Plotter() {
|
public Plotter()
|
||||||
|
{
|
||||||
this("Default");
|
this("Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +489,8 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public Plotter(String name) {
|
public Plotter(String name)
|
||||||
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,24 +506,29 @@ public class Metrics {
|
|||||||
*
|
*
|
||||||
* @return the plotted point's column name
|
* @return the plotted point's column name
|
||||||
*/
|
*/
|
||||||
public String getColumnName() {
|
public String getColumnName()
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the website graphs have been updated
|
* Called after the website graphs have been updated
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode()
|
||||||
|
{
|
||||||
return getColumnName().hashCode() + getValue();
|
return getColumnName().hashCode() + getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object)
|
||||||
if (!(object instanceof Plotter)) {
|
{
|
||||||
|
if (!(object instanceof Plotter))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ package net.h31ix.anticheat.util;
|
|||||||
import java.util.logging.Formatter;
|
import java.util.logging.Formatter;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
public class ConsoleFormatter extends Formatter {
|
public class ConsoleFormatter extends Formatter
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record)
|
public String format(LogRecord record)
|
||||||
|
|||||||
@@ -24,22 +24,18 @@ import java.util.Date;
|
|||||||
import java.util.logging.Formatter;
|
import java.util.logging.Formatter;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
public class FileFormatter extends Formatter {
|
public class FileFormatter extends Formatter
|
||||||
|
{
|
||||||
|
|
||||||
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
||||||
private static final String lineSep = System.getProperty("line.separator");
|
private static final String lineSep = System.getProperty("line.separator");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record) {
|
public String format(LogRecord record)
|
||||||
|
{
|
||||||
if (record.getMessage().startsWith("[AntiCheat]"))
|
if (record.getMessage().startsWith("[AntiCheat]"))
|
||||||
{
|
{
|
||||||
StringBuilder output = new StringBuilder()
|
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(format.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(lineSep);
|
||||||
.append("[")
|
|
||||||
.append(record.getLevel()).append('|')
|
|
||||||
.append(format.format(new Date(record.getMillis())))
|
|
||||||
.append("]: ")
|
|
||||||
.append(record.getMessage()).append(' ')
|
|
||||||
.append(lineSep);
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public final class Utilities
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void alert(String[] message)
|
public static void alert(String[] message)
|
||||||
{
|
{
|
||||||
for (String msg : message)
|
for (String msg : message)
|
||||||
@@ -52,40 +53,49 @@ public final class Utilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandAt(Block block)
|
public static boolean cantStandAt(Block block)
|
||||||
{
|
{
|
||||||
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandClose(Block block)
|
public static boolean cantStandClose(Block block)
|
||||||
{
|
{
|
||||||
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandFar(Block block)
|
public static boolean cantStandFar(Block block)
|
||||||
{
|
{
|
||||||
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canStand(Block block)
|
public static boolean canStand(Block block)
|
||||||
{
|
{
|
||||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInstantBreak(Material m)
|
public static boolean isInstantBreak(Material m)
|
||||||
{
|
{
|
||||||
return INSTANT_BREAK.contains(m);
|
return INSTANT_BREAK.contains(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFood(Material m)
|
public static boolean isFood(Material m)
|
||||||
{
|
{
|
||||||
return FOOD.contains(m);
|
return FOOD.contains(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sprintFly(Player player)
|
public static boolean sprintFly(Player player)
|
||||||
{
|
{
|
||||||
return player.isSprinting() || player.isFlying();
|
return player.isSprinting() || player.isFlying();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnLilyPad(Player player)
|
public static boolean isOnLilyPad(Player player)
|
||||||
{
|
{
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
Material lily = Material.WATER_LILY;
|
Material lily = Material.WATER_LILY;
|
||||||
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUsingMcMMOAbility(Player player)
|
public static boolean isUsingMcMMOAbility(Player player)
|
||||||
{
|
{
|
||||||
boolean b = false;
|
boolean b = false;
|
||||||
@@ -98,22 +108,27 @@ public final class Utilities
|
|||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSubmersed(Player player)
|
public static boolean isSubmersed(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInWater(Player player)
|
public static boolean isInWater(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnLadder(Player player)
|
public static boolean isOnLadder(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
|
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInt(String string)
|
public static boolean isInt(String string)
|
||||||
{
|
{
|
||||||
boolean x = false;
|
boolean x = false;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
Integer.parseInt(string);
|
Integer.parseInt(string);
|
||||||
x = true;
|
x = true;
|
||||||
}
|
}
|
||||||
@@ -122,6 +137,7 @@ public final class Utilities
|
|||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
|
||||||
public class XRayListener implements Listener {
|
public class XRayListener implements Listener
|
||||||
|
{
|
||||||
private XRayTracker tracker = Anticheat.getManager().getXRayTracker();
|
private XRayTracker tracker = Anticheat.getManager().getXRayTracker();
|
||||||
private Configuration config = Anticheat.getManager().getConfiguration();
|
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private CheckManager checkManager = Anticheat.getManager().getCheckManager();
|
private CheckManager checkManager = Anticheat.getManager().getCheckManager();
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ package net.h31ix.anticheat.xray;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class XRayStats {
|
public class XRayStats
|
||||||
|
{
|
||||||
private static final int DIVISOR = 100;
|
private static final int DIVISOR = 100;
|
||||||
private double t = 1;
|
private double t = 1;
|
||||||
private double d = 0;
|
private double d = 0;
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ import java.util.Map;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class XRayTracker {
|
public class XRayTracker
|
||||||
|
{
|
||||||
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> iron = new HashMap<String, Integer>();
|
private Map<String, Integer> iron = new HashMap<String, Integer>();
|
||||||
|
|||||||
Reference in new issue
Block a user