mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 06:28:52 +00:00
Run through new formatter.
This commit is contained in:
1 parent
b48e97a799
commit
170f4dd946
34 files changed
+5636
-7150
No files matched your search
@@ -43,272 +43,216 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class Anticheat extends JavaPlugin
|
public class Anticheat extends JavaPlugin {
|
||||||
{
|
private static AnticheatManager manager;
|
||||||
private static AnticheatManager manager;
|
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
private static boolean update = false;
|
||||||
private static boolean update = false;
|
private static Configuration config;
|
||||||
private static Configuration config;
|
private static boolean verbose;
|
||||||
private static boolean verbose;
|
private static Metrics metrics;
|
||||||
private static Metrics metrics;
|
private static final long XRAY_TIME = 1200;
|
||||||
private static final long XRAY_TIME = 1200;
|
public static final String SPY_METADATA = "ac-spydata";
|
||||||
public static final String SPY_METADATA = "ac-spydata";
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onEnable() {
|
||||||
public void onEnable()
|
manager = new AnticheatManager(this, getLogger());
|
||||||
{
|
eventList.add(new PlayerListener());
|
||||||
manager = new AnticheatManager(this, getLogger());
|
eventList.add(new BlockListener());
|
||||||
eventList.add(new PlayerListener());
|
eventList.add(new EntityListener());
|
||||||
eventList.add(new BlockListener());
|
eventList.add(new VehicleListener());
|
||||||
eventList.add(new EntityListener());
|
eventList.add(new InventoryListener());
|
||||||
eventList.add(new VehicleListener());
|
// Order is important in some cases, don't screw with these unless needed, especially config
|
||||||
eventList.add(new InventoryListener());
|
setupConfig();
|
||||||
// Order is important in some cases, don't screw with these unless needed, especially config
|
// Xray must come before events
|
||||||
setupConfig();
|
setupXray();
|
||||||
// Xray must come before events
|
setupEvents();
|
||||||
setupXray();
|
setupCommands();
|
||||||
setupEvents();
|
setupUpdater();
|
||||||
setupCommands();
|
setupMetrics();
|
||||||
setupUpdater();
|
restoreLevels();
|
||||||
setupMetrics();
|
// Test for compatibility for 1.4.5-R1.0
|
||||||
restoreLevels();
|
try {
|
||||||
// Test for compatibility for 1.4.5-R1.0
|
Material.AIR.isSolid();
|
||||||
try
|
} catch (NoSuchMethodError error) {
|
||||||
{
|
getLogger().severe("You are using an outdated version of CraftBukkit that does not contain the API required for AntiCheat to run properly.");
|
||||||
Material.AIR.isSolid();
|
getLogger().severe("Please update to CraftBukkit 1.4.5-R1.0 or higher by visiting dl.bukkit.org and hitting the green download button.");
|
||||||
}
|
getLogger().severe("AntiCheat will now be disabled, and will not protect your server until it is updated.");
|
||||||
catch(NoSuchMethodError error)
|
getPluginLoader().disablePlugin(this);
|
||||||
{
|
return;
|
||||||
getLogger().severe("You are using an outdated version of CraftBukkit that does not contain the API required for AntiCheat to run properly.");
|
}
|
||||||
getLogger().severe("Please update to CraftBukkit 1.4.5-R1.0 or higher by visiting dl.bukkit.org and hitting the green download button.");
|
// End test
|
||||||
getLogger().severe("AntiCheat will now be disabled, and will not protect your server until it is updated.");
|
if (verbose) {
|
||||||
getPluginLoader().disablePlugin(this);
|
getLogger().log(Level.INFO, "Finished loading.");
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
// End test
|
|
||||||
if (verbose)
|
@Override
|
||||||
{
|
public void onDisable() {
|
||||||
getLogger().log(Level.INFO, "Finished loading.");
|
AnticheatManager.close();
|
||||||
}
|
for (User user : manager.getUserManager().getUsers()) {
|
||||||
}
|
config.saveLevel(user.getName(), user.getLevel());
|
||||||
|
}
|
||||||
@Override
|
config.saveLevels();
|
||||||
public void onDisable()
|
getServer().getScheduler().cancelAllTasks();
|
||||||
{
|
cleanup();
|
||||||
AnticheatManager.close();
|
}
|
||||||
for(User user : manager.getUserManager().getUsers())
|
|
||||||
{
|
private void save(InputStream in, File file) {
|
||||||
config.saveLevel(user.getName(), user.getLevel());
|
if (!file.exists()) {
|
||||||
}
|
file.getParentFile().mkdirs();
|
||||||
config.saveLevels();
|
try {
|
||||||
getServer().getScheduler().cancelAllTasks();
|
OutputStream out = new FileOutputStream(file);
|
||||||
cleanup();
|
byte[] buf = new byte[1024];
|
||||||
}
|
int len;
|
||||||
|
while ((len = in.read(buf)) > 0) {
|
||||||
private void save(InputStream in, File file)
|
out.write(buf, 0, len);
|
||||||
{
|
}
|
||||||
if (!file.exists())
|
out.close();
|
||||||
{
|
in.close();
|
||||||
file.getParentFile().mkdirs();
|
} catch (Exception e) {
|
||||||
try
|
getLogger().severe("Unable to save files. Is the directory writeable?");
|
||||||
{
|
}
|
||||||
OutputStream out = new FileOutputStream(file);
|
if (verbose) {
|
||||||
byte[] buf = new byte[1024];
|
getLogger().log(Level.INFO, file.getName() + " created.");
|
||||||
int len;
|
}
|
||||||
while((len=in.read(buf))>0)
|
}
|
||||||
{
|
}
|
||||||
out.write(buf,0,len);
|
|
||||||
}
|
private void setupXray() {
|
||||||
out.close();
|
final XRayTracker xtracker = manager.getXRayTracker();
|
||||||
in.close();
|
if (config.logXRay()) {
|
||||||
}
|
eventList.add(new XRayListener());
|
||||||
catch (Exception e)
|
if (config.alertXRay()) {
|
||||||
{
|
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
|
||||||
getLogger().severe("Unable to save files. Is the directory writeable?");
|
@Override
|
||||||
}
|
public void run() {
|
||||||
if (verbose)
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
{
|
String name = player.getName();
|
||||||
getLogger().log(Level.INFO, file.getName()+" created.");
|
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name)) {
|
||||||
}
|
List<String> alert = new ArrayList<String>();
|
||||||
}
|
alert.add(ChatColor.YELLOW + "[ALERT] " + ChatColor.WHITE + name + ChatColor.YELLOW + " might be using xray.");
|
||||||
}
|
alert.add(ChatColor.YELLOW + "[ALERT] Please check their xray stats using " + ChatColor.WHITE + "/anticheat xray " + name + ChatColor.YELLOW + ".");
|
||||||
|
Utilities.alert(alert);
|
||||||
private void setupXray()
|
xtracker.logAlert(name);
|
||||||
{
|
}
|
||||||
final XRayTracker xtracker = manager.getXRayTracker();
|
}
|
||||||
if (config.logXRay())
|
}
|
||||||
{
|
}, XRAY_TIME, XRAY_TIME);
|
||||||
eventList.add(new XRayListener());
|
if (verbose) {
|
||||||
if (config.alertXRay())
|
getLogger().log(Level.INFO, "Scheduled the XRay checker.");
|
||||||
{
|
}
|
||||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
}
|
||||||
{
|
}
|
||||||
@Override
|
}
|
||||||
public void run()
|
|
||||||
{
|
private void setupEvents() {
|
||||||
for (Player player : getServer().getOnlinePlayers())
|
for (Listener listener : eventList) {
|
||||||
{
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
String name = player.getName();
|
if (verbose) {
|
||||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
getLogger().log(Level.INFO, "Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||||
{
|
}
|
||||||
List<String> alert = new ArrayList<String>();
|
}
|
||||||
alert.add(ChatColor.YELLOW + "[ALERT] " + ChatColor.WHITE + name + ChatColor.YELLOW + " might be using xray.");
|
}
|
||||||
alert.add(ChatColor.YELLOW + "[ALERT] Please check their xray stats using " + ChatColor.WHITE + "/anticheat xray " + name + ChatColor.YELLOW + ".");
|
|
||||||
Utilities.alert(alert);
|
private void setupCommands() {
|
||||||
xtracker.logAlert(name);
|
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||||
}
|
if (verbose) {
|
||||||
}
|
getLogger().log(Level.INFO, "Registered commands.");
|
||||||
}
|
}
|
||||||
}, XRAY_TIME, XRAY_TIME);
|
}
|
||||||
if (verbose)
|
|
||||||
{
|
private void setupUpdater() {
|
||||||
getLogger().log(Level.INFO, "Scheduled the XRay checker.");
|
if (config.autoUpdate()) {
|
||||||
}
|
if (verbose) {
|
||||||
}
|
getLogger().log(Level.INFO, "Checking for a new update...");
|
||||||
}
|
}
|
||||||
}
|
Updater updater = new Updater(this, "anticheat", this.getFile(), Updater.UpdateType.DEFAULT, false);
|
||||||
|
update = updater.getResult() != Updater.UpdateResult.NO_UPDATE;
|
||||||
private void setupEvents()
|
if (verbose) {
|
||||||
{
|
getLogger().log(Level.INFO, "Update avaliable: " + update);
|
||||||
for (Listener listener : eventList)
|
}
|
||||||
{
|
}
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
}
|
||||||
if (verbose)
|
|
||||||
{
|
private void setupMetrics() {
|
||||||
getLogger().log(Level.INFO, "Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
try {
|
||||||
}
|
metrics = new Metrics(this);
|
||||||
}
|
final EventListener listener = new EventListener();
|
||||||
}
|
Graph hacksGraph = metrics.createGraph("Hacks blocked");
|
||||||
|
for (final CheckType type : CheckType.values()) {
|
||||||
private void setupCommands()
|
hacksGraph.addPlotter(new Metrics.Plotter(CheckType.getName(type)) {
|
||||||
{
|
@Override
|
||||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
public int getValue() {
|
||||||
if (verbose)
|
return EventListener.getCheats(type);
|
||||||
{
|
}
|
||||||
getLogger().log(Level.INFO, "Registered commands.");
|
});
|
||||||
}
|
listener.resetCheck(type);
|
||||||
}
|
}
|
||||||
|
Graph apiGraph = metrics.createGraph("API Usage");
|
||||||
private void setupUpdater()
|
apiGraph.addPlotter(new Metrics.Plotter("Checks disabled") {
|
||||||
{
|
@Override
|
||||||
if (config.autoUpdate())
|
public int getValue() {
|
||||||
{
|
return manager.getCheckManager().getDisabled();
|
||||||
if (verbose)
|
}
|
||||||
{
|
});
|
||||||
getLogger().log(Level.INFO, "Checking for a new update...");
|
apiGraph.addPlotter(new Metrics.Plotter("Players exempted") {
|
||||||
}
|
@Override
|
||||||
Updater updater = new Updater(this, "anticheat", this.getFile(), Updater.UpdateType.DEFAULT, false);
|
public int getValue() {
|
||||||
update = updater.getResult() != Updater.UpdateResult.NO_UPDATE;
|
return manager.getCheckManager().getExempt();
|
||||||
if (verbose)
|
}
|
||||||
{
|
});
|
||||||
getLogger().log(Level.INFO, "Update avaliable: "+update);
|
metrics.start();
|
||||||
}
|
if (verbose) {
|
||||||
}
|
getLogger().log(Level.INFO, "Metrics started.");
|
||||||
}
|
}
|
||||||
|
} catch (IOException ex) {}
|
||||||
private void setupMetrics()
|
}
|
||||||
{
|
|
||||||
try
|
private void setupConfig() {
|
||||||
{
|
config = manager.getConfiguration();
|
||||||
metrics = new Metrics(this);
|
checkConfigs();
|
||||||
final EventListener listener = new EventListener();
|
verbose = config.verboseStartup();
|
||||||
Graph hacksGraph = metrics.createGraph("Hacks blocked");
|
if (verbose) {
|
||||||
for (final CheckType type : CheckType.values())
|
getLogger().log(Level.INFO, "Setup the config.");
|
||||||
{
|
}
|
||||||
hacksGraph.addPlotter(new Metrics.Plotter(CheckType.getName(type))
|
}
|
||||||
{
|
|
||||||
@Override
|
private void restoreLevels() {
|
||||||
public int getValue()
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
{
|
String name = player.getName();
|
||||||
return EventListener.getCheats(type);
|
manager.getUserManager().addUser(new User(player.getName(), config.getLevel(name)));
|
||||||
}
|
if (verbose) {
|
||||||
});
|
getLogger().log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
||||||
listener.resetCheck(type);
|
}
|
||||||
}
|
}
|
||||||
Graph apiGraph = metrics.createGraph("API Usage");
|
}
|
||||||
apiGraph.addPlotter(new Metrics.Plotter("Checks disabled")
|
|
||||||
{
|
public void checkConfigs() {
|
||||||
@Override
|
save(getResource("config.yml"), new File(getDataFolder() + "/config.yml"));
|
||||||
public int getValue()
|
save(getResource("lang.yml"), new File(getDataFolder() + "/lang.yml"));
|
||||||
{
|
save(getResource("magic.yml"), new File(getDataFolder() + "/magic.yml"));
|
||||||
return manager.getCheckManager().getDisabled();
|
}
|
||||||
}
|
|
||||||
});
|
public static Anticheat getPlugin() {
|
||||||
apiGraph.addPlotter(new Metrics.Plotter("Players exempted")
|
return manager.getPlugin();
|
||||||
{
|
}
|
||||||
@Override
|
|
||||||
public int getValue()
|
public static AnticheatManager getManager() {
|
||||||
{
|
return manager;
|
||||||
return manager.getCheckManager().getExempt();
|
}
|
||||||
}
|
|
||||||
});
|
public static boolean isUpdated() {
|
||||||
metrics.start();
|
return !update;
|
||||||
if (verbose)
|
}
|
||||||
{
|
|
||||||
getLogger().log(Level.INFO, "Metrics started.");
|
public static String getVersion() {
|
||||||
}
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
|
||||||
{
|
private void cleanup() {
|
||||||
}
|
eventList = null;
|
||||||
}
|
manager = null;
|
||||||
|
config = null;
|
||||||
private void setupConfig()
|
metrics = null;
|
||||||
{
|
}
|
||||||
config = manager.getConfiguration();
|
|
||||||
checkConfigs();
|
|
||||||
verbose = config.verboseStartup();
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
getLogger().log(Level.INFO, "Setup the config.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void restoreLevels()
|
|
||||||
{
|
|
||||||
for (Player player : getServer().getOnlinePlayers())
|
|
||||||
{
|
|
||||||
String name = player.getName();
|
|
||||||
manager.getUserManager().addUser(new User(player.getName(), config.getLevel(name)));
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
getLogger().log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void checkConfigs()
|
|
||||||
{
|
|
||||||
save(getResource("config.yml"), new File(getDataFolder() + "/config.yml"));
|
|
||||||
save(getResource("lang.yml"), new File(getDataFolder() + "/lang.yml"));
|
|
||||||
save(getResource("magic.yml"), new File(getDataFolder() + "/magic.yml"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Anticheat getPlugin()
|
|
||||||
{
|
|
||||||
return manager.getPlugin();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AnticheatManager getManager()
|
|
||||||
{
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUpdated()
|
|
||||||
{
|
|
||||||
return !update;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion()
|
|
||||||
{
|
|
||||||
return manager.getPlugin().getDescription().getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanup()
|
|
||||||
{
|
|
||||||
eventList = null;
|
|
||||||
manager = null;
|
|
||||||
config = null;
|
|
||||||
metrics = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -28,161 +28,128 @@ 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();
|
private static UserManager umr = Anticheat.getManager().getUserManager();
|
||||||
private static UserManager umr = Anticheat.getManager().getUserManager();
|
private static XRayTracker xtracker = Anticheat.getManager().getXRayTracker();
|
||||||
private static XRayTracker xtracker = Anticheat.getManager().getXRayTracker();
|
|
||||||
|
// CheckManager API
|
||||||
//CheckManager API
|
|
||||||
|
/**
|
||||||
/**
|
* 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) {
|
||||||
*/
|
chk.activateCheck(type);
|
||||||
public static void activateCheck(CheckType type)
|
}
|
||||||
{
|
|
||||||
chk.activateCheck(type);
|
/**
|
||||||
}
|
* Stop running a certain check
|
||||||
|
*
|
||||||
/**
|
* @param type Check to stop watching for
|
||||||
* Stop running a certain check
|
*/
|
||||||
*
|
public static void deactivateCheck(CheckType type) {
|
||||||
* @param type
|
chk.deactivateCheck(type);
|
||||||
* Check to stop watching for
|
}
|
||||||
*/
|
|
||||||
public static void deactivateCheck(CheckType type)
|
/**
|
||||||
{
|
* Find out if a check is currently being watched for
|
||||||
chk.deactivateCheck(type);
|
*
|
||||||
}
|
* @param type Type to check
|
||||||
|
* @return true if plugin is watching for this check
|
||||||
/**
|
*/
|
||||||
* Find out if a check is currently being watched for
|
public static boolean isActive(CheckType type) {
|
||||||
*
|
return chk.isActive(type);
|
||||||
* @param type
|
}
|
||||||
* Type to check
|
|
||||||
* @return true if plugin is watching for this check
|
/**
|
||||||
*/
|
* Allow a player to skip a certain check
|
||||||
public static boolean isActive(CheckType type)
|
*
|
||||||
{
|
* @param player Player to stop watching
|
||||||
return chk.isActive(type);
|
* @param type Check to stop watching for
|
||||||
}
|
*/
|
||||||
|
public static void exemptPlayer(Player player, CheckType type) {
|
||||||
/**
|
chk.exemptPlayer(player, type);
|
||||||
* Allow a player to skip a certain check
|
}
|
||||||
*
|
|
||||||
* @param player
|
/**
|
||||||
* Player to stop watching
|
* Stop allowing a player to skip a certain check
|
||||||
* @param type
|
*
|
||||||
* Check to stop watching for
|
* @param player Player to start watching
|
||||||
*/
|
* @param type Check to start watching for
|
||||||
public static void exemptPlayer(Player player, CheckType type)
|
*/
|
||||||
{
|
public static void unexemptPlayer(Player player, CheckType type) {
|
||||||
chk.exemptPlayer(player, type);
|
chk.unexemptPlayer(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop allowing a player to skip a certain check
|
* Find out if a player is currently exempt from a certain check
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player Player to check
|
||||||
* Player to start watching
|
* @param type Type to check
|
||||||
* @param type
|
* @return true if plugin is ignoring this check on this player
|
||||||
* Check to start watching for
|
*/
|
||||||
*/
|
public static boolean isExempt(Player player, CheckType type) {
|
||||||
public static void unexemptPlayer(Player player, CheckType type)
|
return chk.isExempt(player, type);
|
||||||
{
|
}
|
||||||
chk.unexemptPlayer(player, type);
|
|
||||||
}
|
/**
|
||||||
|
* 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 player is currently exempt from a certain check
|
* @param player Player to check
|
||||||
*
|
* @param type Type to check
|
||||||
* @param player
|
* @return true if plugin will check this player, and that all things allow it to happen.
|
||||||
* Player to check
|
*/
|
||||||
* @param type
|
public boolean willCheck(Player player, CheckType type) {
|
||||||
* Type to check
|
return chk.willCheck(player, type);
|
||||||
* @return true if plugin is ignoring this check on this player
|
}
|
||||||
*/
|
|
||||||
public static boolean isExempt(Player player, CheckType type)
|
// PlayerManager API
|
||||||
{
|
|
||||||
return chk.isExempt(player, type);
|
/**
|
||||||
}
|
* Get a player's integer hack level
|
||||||
|
*
|
||||||
/**
|
* @param player Player to check
|
||||||
* Find out if a check will occur for a player. This checks if they are
|
* @return player's hack level
|
||||||
* being tracked, the check is active, the player isn't exempt from the
|
*/
|
||||||
* check, and the player doesn't have override permission.
|
public static int getLevel(Player player) {
|
||||||
*
|
return umr.safeGetLevel(player.getName());
|
||||||
* @param player
|
}
|
||||||
* Player to check
|
|
||||||
* @param type
|
|
||||||
* Type to check
|
/**
|
||||||
* @return true if plugin will check this player, and that all things allow
|
* Set a player's hack level (Min = 0, Max = 50)
|
||||||
* it to happen.
|
*
|
||||||
*/
|
* @param player Player to set
|
||||||
public boolean willCheck(Player player, CheckType type)
|
* @param level Level to set to
|
||||||
{
|
*/
|
||||||
return chk.willCheck(player, type);
|
public static void setLevel(Player player, int level) {
|
||||||
}
|
umr.safeSetLevel(player.getName(), level);
|
||||||
|
}
|
||||||
//PlayerManager API
|
|
||||||
|
// XrayTracker API
|
||||||
/**
|
|
||||||
* Get a player's integer hack level
|
/**
|
||||||
*
|
* 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 player's hack level
|
* @return true if the player has any xray anomalies.
|
||||||
*/
|
*/
|
||||||
public static int getLevel(Player player)
|
public static boolean isXrayer(Player player) {
|
||||||
{
|
String name = player.getName();
|
||||||
return umr.safeGetLevel(player.getName());
|
if (xtracker.sufficientData(name) && xtracker.hasAbnormal(name)) { return true; }
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
// Advanced Users Only API.
|
||||||
* Set a player's hack level (Min = 0, Max = 50)
|
|
||||||
*
|
/**
|
||||||
* @param player
|
* Get access to all the other managers, advanced users ONLY
|
||||||
* Player to set
|
*
|
||||||
* @param level
|
* @return the AntiCheat Manager
|
||||||
* Level to set to
|
*/
|
||||||
*/
|
public static AnticheatManager getManager() {
|
||||||
public static void setLevel(Player player, int level)
|
return Anticheat.getManager();
|
||||||
{
|
}
|
||||||
umr.safeSetLevel(player.getName(), level);
|
|
||||||
}
|
|
||||||
|
|
||||||
//XrayTracker API
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find out if a player is detected as using xray hacks (on any ore)
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* Player to check
|
|
||||||
* @return true if the player has any xray anomalies.
|
|
||||||
*/
|
|
||||||
public static boolean isXrayer(Player player)
|
|
||||||
{
|
|
||||||
String name = player.getName();
|
|
||||||
if (xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Advanced Users Only API.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get access to all the other managers, advanced users ONLY
|
|
||||||
*
|
|
||||||
* @return the AntiCheat Manager
|
|
||||||
*/
|
|
||||||
public static AnticheatManager getManager()
|
|
||||||
{
|
|
||||||
return Anticheat.getManager();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,6 @@ import net.h31ix.anticheat.manage.CheckType;
|
|||||||
import net.h31ix.anticheat.util.Configuration;
|
import net.h31ix.anticheat.util.Configuration;
|
||||||
import net.h31ix.anticheat.util.Distance;
|
import net.h31ix.anticheat.util.Distance;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.h31ix.anticheat.util.Utilities;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -34,82 +33,66 @@ import org.bukkit.event.block.BlockBreakEvent;
|
|||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
public class BlockListener extends EventListener
|
public class BlockListener extends EventListener {
|
||||||
{
|
private final Backend backend = getBackend();
|
||||||
private final Backend backend = getBackend();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private final Configuration config = Anticheat.getManager().getConfiguration();
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
Player player = event.getPlayer();
|
||||||
{
|
if (event.getInstaBreak() && Utilities.isInstantBreak(event.getBlock().getType())) {
|
||||||
Player player = event.getPlayer();
|
backend.logInstantBreak(player);
|
||||||
if (event.getInstaBreak() && Utilities.isInstantBreak(event.getBlock().getType()))
|
}
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.AUTOTOOL) && backend.justSwitchedTool(player)) {
|
||||||
backend.logInstantBreak(player);
|
event.setCancelled(!config.silentMode());
|
||||||
}
|
log("tried to switch their tool too fast.", player, CheckType.AUTOTOOL);
|
||||||
if (checkManager.willCheck(player, CheckType.AUTOTOOL) && backend.justSwitchedTool(player))
|
}
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
log("tried to switch their tool too fast.", player, CheckType.AUTOTOOL);
|
@EventHandler(ignoreCancelled = true)
|
||||||
}
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
}
|
final Player player = event.getPlayer();
|
||||||
|
Block block = event.getBlock();
|
||||||
@EventHandler(ignoreCancelled = true)
|
if (player != null && checkManager.willCheck(player, CheckType.FAST_PLACE)) {
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
if (backend.checkFastPlace(player)) {
|
||||||
{
|
event.setCancelled(!config.silentMode());
|
||||||
final Player player = event.getPlayer();
|
log("tried to place a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_PLACE);
|
||||||
Block block = event.getBlock();
|
} else {
|
||||||
if (player != null && checkManager.willCheck(player, CheckType.FAST_PLACE))
|
decrease(player);
|
||||||
{
|
backend.logBlockPlace(player);
|
||||||
if (backend.checkFastPlace(player))
|
}
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
}
|
||||||
log("tried to place a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_PLACE);
|
|
||||||
}
|
@EventHandler(ignoreCancelled = true)
|
||||||
else
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
{
|
final Player player = event.getPlayer();
|
||||||
decrease(player);
|
final Block block = event.getBlock();
|
||||||
backend.logBlockPlace(player);
|
boolean noHack = true;
|
||||||
}
|
if (player != null) {
|
||||||
}
|
if (checkManager.willCheck(player, CheckType.FAST_BREAK) && !backend.isInstantBreakExempt(player) && backend.checkFastBreak(player, block)) {
|
||||||
}
|
event.setCancelled(!config.silentMode());
|
||||||
|
log("tried to break a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_BREAK);
|
||||||
@EventHandler(ignoreCancelled = true)
|
noHack = false;
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
}
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.NO_SWING) && backend.checkSwing(player, block)) {
|
||||||
final Player player = event.getPlayer();
|
event.setCancelled(!config.silentMode());
|
||||||
final Block block = event.getBlock();
|
log("tried to break a block of " + block.getType().name() + " without swinging their arm.", player, CheckType.NO_SWING);
|
||||||
boolean noHack = true;
|
noHack = false;
|
||||||
if (player != null)
|
}
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.LONG_REACH)) {
|
||||||
if (checkManager.willCheck(player, CheckType.FAST_BREAK) && !backend.isInstantBreakExempt(player) && backend.checkFastBreak(player, block))
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
{
|
if (backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference())) {
|
||||||
event.setCancelled(!config.silentMode());
|
event.setCancelled(!config.silentMode());
|
||||||
log("tried to break a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_BREAK);
|
log("tried to break a block of " + block.getType().name() + " that was too far away.", player, CheckType.LONG_REACH);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.NO_SWING) && backend.checkSwing(player, block))
|
}
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
if (noHack) {
|
||||||
log("tried to break a block of " + block.getType().name() + " without swinging their arm.", player, CheckType.NO_SWING);
|
decrease(player);
|
||||||
noHack = false;
|
}
|
||||||
}
|
backend.logBlockBreak(player);
|
||||||
if (checkManager.willCheck(player, CheckType.LONG_REACH))
|
}
|
||||||
{
|
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
|
||||||
if (backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference()))
|
|
||||||
{
|
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
log("tried to break a block of " + block.getType().name() + " that was too far away.", player, CheckType.LONG_REACH);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (noHack)
|
|
||||||
{
|
|
||||||
decrease(player);
|
|
||||||
}
|
|
||||||
backend.logBlockBreak(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -33,157 +33,120 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
|
|
||||||
public class EntityListener extends EventListener
|
public class EntityListener extends EventListener {
|
||||||
{
|
private final Backend backend = getBackend();
|
||||||
private final Backend backend = getBackend();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private final Configuration config = Anticheat.getManager().getConfiguration();
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
public void onEntityShootBow(EntityShootBowEvent event)
|
if (event.getEntity() instanceof Player) {
|
||||||
{
|
Player player = (Player) event.getEntity();
|
||||||
if (event.getEntity() instanceof Player)
|
if (checkManager.willCheck(player, CheckType.FAST_BOW)) {
|
||||||
{
|
if (backend.checkFastBow(player, event.getForce())) {
|
||||||
Player player = (Player) event.getEntity();
|
event.setCancelled(!config.silentMode());
|
||||||
if (checkManager.willCheck(player, CheckType.FAST_BOW))
|
log("tried to fire a bow too fast.", player, CheckType.FAST_BOW);
|
||||||
{
|
} else {
|
||||||
if (backend.checkFastBow(player, event.getForce()))
|
decrease(player);
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
}
|
||||||
log("tried to fire a bow too fast.", player, CheckType.FAST_BOW);
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
@EventHandler
|
||||||
decrease(player);
|
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||||
}
|
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
|
||||||
}
|
Player player = (Player) event.getEntity();
|
||||||
}
|
if (checkManager.willCheck(player, CheckType.FAST_HEAL)) {
|
||||||
}
|
if (backend.justHealed(player)) {
|
||||||
|
event.setCancelled(!config.silentMode());
|
||||||
@EventHandler
|
log("tried to heal too fast.", player, CheckType.FAST_HEAL);
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
} else {
|
||||||
{
|
decrease(player);
|
||||||
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
backend.logHeal(player);
|
||||||
{
|
}
|
||||||
Player player = (Player) event.getEntity();
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.FAST_HEAL))
|
}
|
||||||
{
|
}
|
||||||
if (backend.justHealed(player))
|
|
||||||
{
|
@EventHandler
|
||||||
event.setCancelled(!config.silentMode());
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
log("tried to heal too fast.", player, CheckType.FAST_HEAL);
|
if (event.getEntity() instanceof Player) {
|
||||||
}
|
Player player = (Player) event.getEntity();
|
||||||
else
|
if (player.getFoodLevel() < event.getFoodLevel() && checkManager.willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level
|
||||||
{
|
{
|
||||||
decrease(player);
|
if (backend.justStartedEating(player)) {
|
||||||
backend.logHeal(player);
|
event.setCancelled(!config.silentMode());
|
||||||
}
|
log("tried to eat too fast.", player, CheckType.FAST_EAT);
|
||||||
}
|
} else {
|
||||||
}
|
decrease(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler
|
}
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
}
|
||||||
{
|
|
||||||
if (event.getEntity() instanceof Player)
|
@EventHandler(ignoreCancelled = true)
|
||||||
{
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
Player player = (Player) event.getEntity();
|
boolean noHack = true;
|
||||||
if(player.getFoodLevel() < event.getFoodLevel() && checkManager.willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level
|
if (event instanceof EntityDamageByEntityEvent) {
|
||||||
{
|
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||||
if (backend.justStartedEating(player))
|
if (event.getEntity() instanceof Player) {
|
||||||
{
|
Player player = (Player) event.getEntity();
|
||||||
event.setCancelled(!config.silentMode());
|
// Keep players from shooting an arrow at themselves in order to fly
|
||||||
log("tried to eat too fast.", player, CheckType.FAST_EAT);
|
if (e.getDamager() instanceof Arrow) {
|
||||||
}
|
Arrow arrow = (Arrow) e.getDamager();
|
||||||
else
|
if (arrow.getShooter() instanceof Player && event.getEntity() == arrow.getShooter()) {
|
||||||
{
|
event.setCancelled(true);
|
||||||
decrease(player);
|
}
|
||||||
}
|
}
|
||||||
}
|
if (e.getDamager() instanceof Player) {
|
||||||
}
|
Player p = (Player) e.getDamager();
|
||||||
}
|
backend.logDamage(p, 1);
|
||||||
|
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
||||||
@EventHandler(ignoreCancelled = true)
|
backend.logDamage(player, value);
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
if (checkManager.willCheck(p, CheckType.LONG_REACH)) {
|
||||||
{
|
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
||||||
boolean noHack = true;
|
if (backend.checkLongReachDamage(distance.getXDifference(), distance.getYDifference(), distance.getZDifference())) {
|
||||||
if (event instanceof EntityDamageByEntityEvent)
|
event.setCancelled(!config.silentMode());
|
||||||
{
|
log("tried to damage a player too far away from them.", p, CheckType.LONG_REACH);
|
||||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
noHack = false;
|
||||||
if (event.getEntity() instanceof Player)
|
}
|
||||||
{
|
}
|
||||||
Player player = (Player) event.getEntity();
|
} else {
|
||||||
// Keep players from shooting an arrow at themselves in order to fly
|
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
|
||||||
if(e.getDamager() instanceof Arrow)
|
backend.logDamage(player, 3);
|
||||||
{
|
} else {
|
||||||
Arrow arrow = (Arrow)e.getDamager();
|
backend.logDamage(player, 1);
|
||||||
if(arrow.getShooter() instanceof Player && event.getEntity() == arrow.getShooter())
|
}
|
||||||
{
|
}
|
||||||
event.setCancelled(true);
|
}
|
||||||
}
|
if (e.getDamager() instanceof Player) {
|
||||||
}
|
Player player = (Player) e.getDamager();
|
||||||
if (e.getDamager() instanceof Player)
|
backend.logDamage(player, 1);
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.AUTOTOOL) && backend.justSwitchedTool(player)) {
|
||||||
Player p = (Player) e.getDamager();
|
event.setCancelled(!config.silentMode());
|
||||||
backend.logDamage(p, 1);
|
log("tried to switch their tool too fast.", player, CheckType.AUTOTOOL);
|
||||||
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
noHack = false;
|
||||||
backend.logDamage(player, value);
|
}
|
||||||
if (checkManager.willCheck(p, CheckType.LONG_REACH))
|
if (checkManager.willCheck(player, CheckType.FORCEFIELD) && backend.justSprinted(player)) {
|
||||||
{
|
event.setCancelled(!config.silentMode());
|
||||||
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
log("tried to sprint & damage too fast.", player, CheckType.FORCEFIELD);
|
||||||
if (backend.checkLongReachDamage(distance.getXDifference(), distance.getYDifference(), distance.getZDifference()))
|
noHack = false;
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
if (checkManager.willCheck(player, CheckType.NO_SWING) && !backend.justAnimated(player)) {
|
||||||
log("tried to damage a player too far away from them.", p, CheckType.LONG_REACH);
|
event.setCancelled(!config.silentMode());
|
||||||
noHack = false;
|
log("tried to damage an entity without swinging their arm.", player, CheckType.NO_SWING);
|
||||||
}
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
if (checkManager.willCheck(player, CheckType.FORCEFIELD) && !backend.checkSight(player, e.getEntity())) {
|
||||||
else
|
event.setCancelled(!config.silentMode());
|
||||||
{
|
log("tried to damage an entity that they couldn't see.", player, CheckType.FORCEFIELD);
|
||||||
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper)
|
noHack = false;
|
||||||
{
|
}
|
||||||
backend.logDamage(player, 3);
|
if (noHack) {
|
||||||
}
|
decrease(player);
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
backend.logDamage(player, 1);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getDamager() instanceof Player)
|
|
||||||
{
|
|
||||||
Player player = (Player) e.getDamager();
|
|
||||||
backend.logDamage(player, 1);
|
|
||||||
if (checkManager.willCheck(player, CheckType.AUTOTOOL) && backend.justSwitchedTool(player))
|
|
||||||
{
|
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
log("tried to switch their tool too fast.", player, CheckType.AUTOTOOL);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
if (checkManager.willCheck(player, CheckType.FORCEFIELD) && backend.justSprinted(player))
|
|
||||||
{
|
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
log("tried to sprint & damage too fast.", player, CheckType.FORCEFIELD);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
if (checkManager.willCheck(player, CheckType.NO_SWING) && !backend.justAnimated(player))
|
|
||||||
{
|
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
log("tried to damage an entity without swinging their arm.", player, CheckType.NO_SWING);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
if (checkManager.willCheck(player, CheckType.FORCEFIELD) && !backend.checkSight(player, e.getEntity()))
|
|
||||||
{
|
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
log("tried to damage an entity that they couldn't see.", player, CheckType.FORCEFIELD);
|
|
||||||
noHack = false;
|
|
||||||
}
|
|
||||||
if (noHack)
|
|
||||||
{
|
|
||||||
decrease(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -26,117 +26,95 @@ import net.h31ix.anticheat.manage.*;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public class EventListener implements Listener
|
public class EventListener implements Listener {
|
||||||
{
|
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
||||||
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
private static final CheckManager CHECK_MANAGER = Anticheat.getManager().getCheckManager();
|
||||||
private static final CheckManager CHECK_MANAGER = Anticheat.getManager().getCheckManager();
|
private static final Backend BACKEND = Anticheat.getManager().getBackend();
|
||||||
private static final Backend BACKEND = Anticheat.getManager().getBackend();
|
private static final Anticheat PLUGIN = Anticheat.getManager().getPlugin();
|
||||||
private static final Anticheat PLUGIN = Anticheat.getManager().getPlugin();
|
private static final UserManager USER_MANAGER = Anticheat.getManager().getUserManager();
|
||||||
private static final UserManager USER_MANAGER = Anticheat.getManager().getUserManager();
|
|
||||||
|
public static void log(String message, Player player, CheckType type) {
|
||||||
public static void log(String message, Player player, CheckType type)
|
User user = getUserManager().getUser(player.getName());
|
||||||
{
|
if (user.increaseLevel(type)) {
|
||||||
User user = getUserManager().getUser(player.getName());
|
Anticheat.getManager().log(user.getName() + " " + message);
|
||||||
if (user.increaseLevel(type))
|
}
|
||||||
{
|
removeDecrease(user);
|
||||||
Anticheat.getManager().log(user.getName() + " " + message);
|
logCheat(type, user);
|
||||||
}
|
}
|
||||||
removeDecrease(user);
|
|
||||||
logCheat(type, user);
|
private static void logCheat(CheckType type, User user) {
|
||||||
}
|
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||||
|
type.logUse(user.getName());
|
||||||
private static void logCheat(CheckType type, User user)
|
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||||
{
|
if (user.getName() != null) {
|
||||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(user.getName()) % 10 == 0) {
|
||||||
type.logUse(user.getName());
|
Anticheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
||||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
}
|
||||||
if(user.getName() != null)
|
}
|
||||||
{
|
}
|
||||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(user.getName()) % 10 == 0)
|
|
||||||
{
|
public void resetCheck(CheckType type) {
|
||||||
Anticheat.getManager().fileLog(user.getName() + " has triggered multiple " + type + " checks.");
|
USAGE_LIST.put(type, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
public static int getCheats(CheckType type) {
|
||||||
|
int x = 0;
|
||||||
public void resetCheck(CheckType type)
|
if (USAGE_LIST.get(type) != null) {
|
||||||
{
|
x = USAGE_LIST.get(type);
|
||||||
USAGE_LIST.put(type, 0);
|
}
|
||||||
}
|
return x;
|
||||||
|
}
|
||||||
public static int getCheats(CheckType type)
|
|
||||||
{
|
private static void removeDecrease(User user) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if (USAGE_LIST.get(type) != null)
|
// Ignore plugins that are creating NPCs with no names
|
||||||
{
|
if (user.getName() != null) {
|
||||||
x = USAGE_LIST.get(type);
|
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||||
}
|
x = DECREASE_LIST.get(user.getName());
|
||||||
return x;
|
x -= 2;
|
||||||
}
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
private static void removeDecrease(User user)
|
}
|
||||||
{
|
}
|
||||||
int x = 0;
|
DECREASE_LIST.put(user.getName(), x);
|
||||||
// Ignore plugins that are creating NPCs with no names
|
}
|
||||||
if(user.getName() != null)
|
}
|
||||||
{
|
|
||||||
if (DECREASE_LIST.get(user.getName()) != null)
|
public static void decrease(Player player) {
|
||||||
{
|
User user = getUserManager().getUser(player.getName());
|
||||||
x = DECREASE_LIST.get(user.getName());
|
// Ignore plugins that are creating NPCs with no names
|
||||||
x -= 2;
|
if (user.getName() != null) {
|
||||||
if (x < 0)
|
int x = 0;
|
||||||
{
|
if (DECREASE_LIST.get(user.getName()) != null) {
|
||||||
x = 0;
|
x = DECREASE_LIST.get(user.getName());
|
||||||
}
|
}
|
||||||
}
|
x += 1;
|
||||||
DECREASE_LIST.put(user.getName(), x);
|
DECREASE_LIST.put(user.getName(), x);
|
||||||
}
|
if (x >= 10) {
|
||||||
}
|
user.decreaseLevel();
|
||||||
|
DECREASE_LIST.put(user.getName(), 0);
|
||||||
public static void decrease(Player player)
|
}
|
||||||
{
|
}
|
||||||
User user = getUserManager().getUser(player.getName());
|
}
|
||||||
// Ignore plugins that are creating NPCs with no names
|
|
||||||
if(user.getName() != null)
|
public static CheckManager getCheckManager() {
|
||||||
{
|
return CHECK_MANAGER;
|
||||||
int x = 0;
|
}
|
||||||
if (DECREASE_LIST.get(user.getName()) != null)
|
|
||||||
{
|
public static AnticheatManager getManager() {
|
||||||
x = DECREASE_LIST.get(user.getName());
|
return Anticheat.getManager();
|
||||||
}
|
}
|
||||||
x += 1;
|
|
||||||
DECREASE_LIST.put(user.getName(), x);
|
public static Backend getBackend() {
|
||||||
if (x >= 10)
|
return BACKEND;
|
||||||
{
|
}
|
||||||
user.decreaseLevel();
|
|
||||||
DECREASE_LIST.put(user.getName(), 0);
|
public static UserManager getUserManager() {
|
||||||
}
|
return USER_MANAGER;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static Anticheat getPlugin() {
|
||||||
public static CheckManager getCheckManager()
|
return PLUGIN;
|
||||||
{
|
}
|
||||||
return CHECK_MANAGER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static AnticheatManager getManager()
|
|
||||||
{
|
|
||||||
return Anticheat.getManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Backend getBackend()
|
|
||||||
{
|
|
||||||
return BACKEND;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static UserManager getUserManager()
|
|
||||||
{
|
|
||||||
return USER_MANAGER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Anticheat getPlugin()
|
|
||||||
{
|
|
||||||
return PLUGIN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -27,34 +27,27 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
public class InventoryListener extends EventListener{
|
public class InventoryListener extends EventListener {
|
||||||
|
|
||||||
private final Backend backend = getBackend();
|
private final Backend backend = getBackend();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
private final Configuration config = Anticheat.getManager().getConfiguration();
|
private final Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event)
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
{
|
if (event.getWhoClicked() instanceof Player) {
|
||||||
if (event.getWhoClicked() instanceof Player)
|
Player player = (Player) event.getWhoClicked();
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.FAST_INVENTORY)) {
|
||||||
Player player = (Player) event.getWhoClicked();
|
if (backend.checkInventoryClicks(player)) {
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_INVENTORY))
|
if (!config.silentMode()) {
|
||||||
{
|
event.setCancelled(!config.silentMode());
|
||||||
if(backend.checkInventoryClicks(player))
|
player.setHealth(0);
|
||||||
{
|
}
|
||||||
if(!config.silentMode())
|
log("tried to use their inventory too fast", player, CheckType.FAST_INVENTORY);
|
||||||
{
|
} else {
|
||||||
event.setCancelled(!config.silentMode());
|
decrease(player);
|
||||||
player.setHealth(0);
|
}
|
||||||
}
|
}
|
||||||
log("tried to use their inventory too fast", player, CheckType.FAST_INVENTORY);
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
decrease(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -42,400 +42,314 @@ import org.bukkit.event.player.*;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
public class PlayerListener extends EventListener
|
public class PlayerListener extends EventListener {
|
||||||
{
|
private final Backend backend = getBackend();
|
||||||
private final Backend backend = getBackend();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private final Configuration config = Anticheat.getManager().getConfiguration();
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
Player player = event.getPlayer();
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam()) {
|
||||||
Player player = event.getPlayer();
|
backend.logChat(player);
|
||||||
if (checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam())
|
if (backend.checkSpam(player, event.getMessage())) {
|
||||||
{
|
event.setCancelled(!config.silentMode());
|
||||||
backend.logChat(player);
|
player.sendMessage(ChatColor.RED + "Please do not spam.");
|
||||||
if (backend.checkSpam(player, event.getMessage()))
|
}
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
}
|
||||||
player.sendMessage(ChatColor.RED + "Please do not spam.");
|
|
||||||
}
|
@EventHandler
|
||||||
}
|
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||||
}
|
if (!event.isFlying()) {
|
||||||
|
backend.logEnterExit(event.getPlayer());
|
||||||
@EventHandler
|
}
|
||||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent event)
|
}
|
||||||
{
|
|
||||||
if (!event.isFlying())
|
@EventHandler
|
||||||
{
|
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||||
backend.logEnterExit(event.getPlayer());
|
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
||||||
}
|
backend.logEnterExit(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler
|
|
||||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event)
|
@EventHandler
|
||||||
{
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||||
if (event.getNewGameMode() != GameMode.CREATIVE)
|
if (event.getEntity().getShooter() instanceof Player) {
|
||||||
{
|
Player player = (Player) event.getEntity().getShooter();
|
||||||
backend.logEnterExit(event.getPlayer());
|
|
||||||
}
|
if (event.getEntity() instanceof Arrow) { return; }
|
||||||
}
|
|
||||||
|
if (checkManager.willCheck(player, CheckType.FAST_PROJECTILE) && backend.checkProjectile(player)) {
|
||||||
@EventHandler
|
event.setCancelled(!config.silentMode());
|
||||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
log("tried to fire projectiles too fast.", player, CheckType.FAST_PROJECTILE);
|
||||||
{
|
}
|
||||||
if (event.getEntity().getShooter() instanceof Player)
|
}
|
||||||
{
|
}
|
||||||
Player player = (Player) event.getEntity().getShooter();
|
|
||||||
|
@EventHandler
|
||||||
if (event.getEntity() instanceof Arrow)
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
{
|
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
|
||||||
return;
|
backend.logTeleport(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.FAST_PROJECTILE) && backend.checkProjectile(player))
|
|
||||||
{
|
@EventHandler
|
||||||
event.setCancelled(!config.silentMode());
|
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
|
||||||
log("tried to fire projectiles too fast.", player, CheckType.FAST_PROJECTILE);
|
backend.logTeleport(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
@EventHandler
|
||||||
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||||
@EventHandler
|
if (event.isSneaking()) {
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
backend.logToggleSneak(event.getPlayer());
|
||||||
{
|
}
|
||||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN)
|
}
|
||||||
{
|
|
||||||
backend.logTeleport(event.getPlayer());
|
@EventHandler
|
||||||
}
|
public void onPlayerVelocity(PlayerVelocityEvent event) {
|
||||||
}
|
Player player = event.getPlayer();
|
||||||
|
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY)) // @h31ix: Change if necessary. I'm not sure what perms should go here :3
|
||||||
@EventHandler
|
{
|
||||||
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event)
|
if (backend.justVelocity(player) && backend.extendVelocityTime(player)) {
|
||||||
{
|
event.setCancelled(!config.silentMode());
|
||||||
backend.logTeleport(event.getPlayer());
|
return; // don't log it lol.
|
||||||
}
|
}
|
||||||
|
backend.logVelocity(player);
|
||||||
@EventHandler
|
}
|
||||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
|
}
|
||||||
{
|
|
||||||
if (event.isSneaking())
|
@EventHandler(ignoreCancelled = true)
|
||||||
{
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
backend.logToggleSneak(event.getPlayer());
|
Player player = event.getPlayer();
|
||||||
}
|
if (checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam()) {
|
||||||
}
|
backend.logChat(player);
|
||||||
|
if (backend.checkSpam(player, event.getMessage())) {
|
||||||
@EventHandler
|
boolean b = !config.silentMode();
|
||||||
public void onPlayerVelocity(PlayerVelocityEvent event)
|
event.setCancelled(b);
|
||||||
{
|
if (b) {
|
||||||
Player player = event.getPlayer();
|
player.sendMessage(ChatColor.RED + config.getLang().getChatWarning());
|
||||||
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY)) //@h31ix: Change if necessary. I'm not sure what perms should go here :3
|
}
|
||||||
{
|
}
|
||||||
if (backend.justVelocity(player) && backend.extendVelocityTime(player))
|
}
|
||||||
{
|
}
|
||||||
event.setCancelled(!config.silentMode());
|
|
||||||
return; // don't log it lol.
|
@EventHandler
|
||||||
}
|
public void onPlayerKick(PlayerKickEvent event) {
|
||||||
backend.logVelocity(player);
|
backend.clearChatLevel(event.getPlayer());
|
||||||
}
|
backend.garbageClean(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
{
|
backend.garbageClean(event.getPlayer());
|
||||||
Player player = event.getPlayer();
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam())
|
|
||||||
{
|
@EventHandler
|
||||||
backend.logChat(player);
|
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
||||||
if (backend.checkSpam(player, event.getMessage()))
|
Player player = event.getPlayer();
|
||||||
{
|
if (checkManager.willCheck(player, CheckType.SPRINT)) {
|
||||||
boolean b = !config.silentMode();
|
if (backend.checkSprintHungry(event)) {
|
||||||
event.setCancelled(b);
|
event.setCancelled(!config.silentMode());
|
||||||
if (b)
|
log("tried to sprint while hungry.", player, CheckType.SPRINT);
|
||||||
{
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + config.getLang().getChatWarning());
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
Player player = event.getPlayer();
|
||||||
{
|
PlayerInventory inv = player.getInventory();
|
||||||
backend.clearChatLevel(event.getPlayer());
|
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
backend.garbageClean(event.getPlayer());
|
Material m = inv.getItemInHand().getType();
|
||||||
}
|
if (m == Material.BOW) {
|
||||||
|
backend.logBowWindUp(player);
|
||||||
@EventHandler
|
} else if (Utilities.isFood(m)) {
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
backend.logEatingStart(player);
|
||||||
{
|
}
|
||||||
backend.garbageClean(event.getPlayer());
|
}
|
||||||
}
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
@EventHandler
|
if (block != null) {
|
||||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
{
|
backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||||
Player player = event.getPlayer();
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.SPRINT))
|
}
|
||||||
{
|
|
||||||
if (backend.checkSprintHungry(event))
|
@EventHandler(ignoreCancelled = true)
|
||||||
{
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
event.setCancelled(!config.silentMode());
|
Player player = event.getPlayer();
|
||||||
log("tried to sprint while hungry.", player, CheckType.SPRINT);
|
if (checkManager.willCheck(player, CheckType.ITEM_SPAM) && backend.checkFastDrop(player)) {
|
||||||
}
|
event.setCancelled(!config.silentMode());
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
decrease(player);
|
|
||||||
}
|
@EventHandler(ignoreCancelled = true)
|
||||||
}
|
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
||||||
}
|
backend.logEnterExit(event.getPlayer());
|
||||||
|
}
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
@EventHandler(ignoreCancelled = true)
|
||||||
{
|
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
||||||
Player player = event.getPlayer();
|
backend.logEnterExit(event.getPlayer());
|
||||||
PlayerInventory inv = player.getInventory();
|
}
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
|
||||||
{
|
@EventHandler
|
||||||
Material m = inv.getItemInHand().getType();
|
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||||
if (m == Material.BOW)
|
Player player = event.getPlayer();
|
||||||
{
|
backend.logAnimation(player);
|
||||||
backend.logBowWindUp(player);
|
}
|
||||||
}
|
|
||||||
else if (Utilities.isFood(m))
|
@EventHandler
|
||||||
{
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
backend.logEatingStart(player);
|
Player player = event.getPlayer();
|
||||||
}
|
String section = "\u00a7";
|
||||||
}
|
if (checkManager.willCheck(player, CheckType.ZOMBE_FLY)) {
|
||||||
Block block = event.getClickedBlock();
|
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
||||||
|
}
|
||||||
if (block != null)
|
if (checkManager.willCheck(player, CheckType.ZOMBE_CHEAT)) {
|
||||||
{
|
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
}
|
||||||
backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
if (checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP)) {
|
||||||
}
|
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||||
}
|
}
|
||||||
|
backend.logJoin(player);
|
||||||
@EventHandler(ignoreCancelled = true)
|
if (getUserManager().getUser(player.getName()) == null) {
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
getUserManager().addUser(new User(player.getName()));
|
||||||
{
|
} else {
|
||||||
Player player = event.getPlayer();
|
getUserManager().addUserFromFile(player.getName());
|
||||||
if (checkManager.willCheck(player, CheckType.ITEM_SPAM) && backend.checkFastDrop(player))
|
}
|
||||||
{
|
if (player.hasMetadata(Anticheat.SPY_METADATA)) {
|
||||||
event.setCancelled(!config.silentMode());
|
for (Player p : player.getServer().getOnlinePlayers()) {
|
||||||
}
|
if (!Permission.SYSTEM_SPY.get(p)) {
|
||||||
}
|
p.hidePlayer(player);
|
||||||
|
}
|
||||||
@EventHandler(ignoreCancelled = true)
|
}
|
||||||
public void onPlayerEnterBed(PlayerBedEnterEvent event)
|
}
|
||||||
{
|
}
|
||||||
backend.logEnterExit(event.getPlayer());
|
|
||||||
}
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void checkExploit(PlayerMoveEvent event) {
|
||||||
@EventHandler(ignoreCancelled = true)
|
Player player = event.getPlayer();
|
||||||
public void onPlayerExitBed(PlayerBedLeaveEvent event)
|
Location from = event.getFrom();
|
||||||
{
|
Location to = event.getTo();
|
||||||
backend.logEnterExit(event.getPlayer());
|
Distance distance = new Distance(from, to);
|
||||||
}
|
double y = distance.getYDifference();
|
||||||
|
backend.logAscension(player, from.getY(), to.getY());
|
||||||
@EventHandler
|
if (checkManager.willCheck(player, CheckType.SPEED) && backend.checkFreeze(player, from.getY(), to.getY())) {
|
||||||
public void onPlayerAnimation(PlayerAnimationEvent event)
|
log("tried to freeze in mid-air.", player, CheckType.SPEED);
|
||||||
{
|
player.kickPlayer("Freezing client");
|
||||||
Player player = event.getPlayer();
|
}
|
||||||
backend.logAnimation(player);
|
if (checkManager.willCheck(player, CheckType.SPRINT)) {
|
||||||
}
|
if (backend.checkSprintStill(player, from, to)) {
|
||||||
|
event.setCancelled(!config.silentMode());
|
||||||
@EventHandler
|
log("tried to sprint while standing still.", player, CheckType.SPRINT);
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
}
|
||||||
{
|
}
|
||||||
Player player = event.getPlayer();
|
if (checkManager.willCheck(player, CheckType.FLY) && !player.isFlying() && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance)) {
|
||||||
String section = "\u00a7";
|
if (!config.silentMode()) {
|
||||||
if (checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
{
|
}
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
log("tried to fly.", player, CheckType.FLY);
|
||||||
}
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
if (checkManager.willCheck(player, CheckType.FLY) && !player.isFlying() && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player, from.getY(), to.getY()))) {
|
||||||
{
|
if (!config.silentMode()) {
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||||
{
|
}
|
||||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
if (checkManager.willCheck(player, CheckType.VCLIP) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && event.getFrom().getY() > event.getTo().getY()) {
|
||||||
}
|
int result = backend.checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
||||||
backend.logJoin(player);
|
|
||||||
if (getUserManager().getUser(player.getName()) == null)
|
if (result > 0) {
|
||||||
{
|
if (!config.silentMode()) {
|
||||||
getUserManager().addUser(new User(player.getName()));
|
// You come back up, and you suddenly feel sick from trying to stick yourself through the blocks..
|
||||||
}
|
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + result, event.getFrom().getZ());
|
||||||
else
|
if (result > 3) {
|
||||||
{
|
result = 3; // prevents players from using AC as a way to teleport to sky islands.
|
||||||
getUserManager().addUserFromFile(player.getName());
|
}
|
||||||
}
|
if (newloc.getBlock().getTypeId() == 0) {
|
||||||
if (player.hasMetadata(Anticheat.SPY_METADATA))
|
event.setTo(newloc);
|
||||||
{
|
} else {
|
||||||
for (Player p : player.getServer().getOnlinePlayers())
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
{
|
}
|
||||||
if (!Permission.SYSTEM_SPY.get(p))
|
player.damage(3);
|
||||||
{
|
}
|
||||||
p.hidePlayer(player);
|
log("tried to move down through a block.", player, CheckType.VCLIP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (checkManager.willCheck(player, CheckType.NOFALL) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY() && backend.checkNoFall(player, y)) {
|
||||||
}
|
if (!config.silentMode()) {
|
||||||
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
player.damage(2); // I added this in here so the player(s) would still receive damage.
|
||||||
public void checkExploit(PlayerMoveEvent event)
|
}
|
||||||
{
|
log("tried to avoid fall damage.", player, CheckType.NOFALL);
|
||||||
Player player = event.getPlayer();
|
}
|
||||||
Location from = event.getFrom();
|
}
|
||||||
Location to = event.getTo();
|
|
||||||
Distance distance = new Distance(from, to);
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
double y = distance.getYDifference();
|
public void checkSpeed(PlayerMoveEvent event) {
|
||||||
backend.logAscension(player, from.getY(), to.getY());
|
Player player = event.getPlayer();
|
||||||
if (checkManager.willCheck(player, CheckType.SPEED) && backend.checkFreeze(player, from.getY(), to.getY()))
|
Location from = event.getFrom();
|
||||||
{
|
Location to = event.getTo();
|
||||||
log("tried to freeze in mid-air.", player, CheckType.SPEED);
|
boolean changed = false;
|
||||||
player.kickPlayer("Freezing client");
|
|
||||||
}
|
if (event.getTo() != event.getFrom()) {
|
||||||
if (checkManager.willCheck(player, CheckType.SPRINT))
|
Distance distance = new Distance(from, to);
|
||||||
{
|
double x = distance.getXDifference();
|
||||||
if (backend.checkSprintStill(player, from, to))
|
double y = distance.getYDifference();
|
||||||
{
|
double z = distance.getZDifference();
|
||||||
event.setCancelled(!config.silentMode());
|
if (checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY)) {
|
||||||
log("tried to sprint while standing still.", player, CheckType.SPRINT);
|
if (event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y)) {
|
||||||
}
|
if (!config.silentMode()) {
|
||||||
}
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
if (checkManager.willCheck(player, CheckType.FLY) && !player.isFlying() && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
}
|
||||||
{
|
log("tried to ascend too fast.", player, CheckType.SPEED);
|
||||||
if (!config.silentMode())
|
changed = true;
|
||||||
{
|
}
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
if (backend.checkXZSpeed(player, x, z)) {
|
||||||
}
|
if (!config.silentMode()) {
|
||||||
log("tried to fly.", player, CheckType.FLY);
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
if (checkManager.willCheck(player, CheckType.FLY) && !player.isFlying() && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player, from.getY(), to.getY())))
|
log("tried to move too fast.", player, CheckType.SPEED);
|
||||||
{
|
changed = true;
|
||||||
if (!config.silentMode())
|
}
|
||||||
{
|
if ((event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) && backend.checkTimer(player)) {
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
if (!config.silentMode()) {
|
||||||
}
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
}
|
||||||
}
|
log("tried to alter their timer.", player, CheckType.SPEED);
|
||||||
if (checkManager.willCheck(player, CheckType.VCLIP) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && event.getFrom().getY() > event.getTo().getY())
|
changed = true;
|
||||||
{
|
}
|
||||||
int result = backend.checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
}
|
||||||
|
if (checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player, x, y, z)) {
|
||||||
if (result > 0)
|
if (!config.silentMode()) {
|
||||||
{
|
player.teleport(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(player.getLocation().add(0, -1, 0)));
|
||||||
if (!config.silentMode())
|
}
|
||||||
{
|
log("tried to walk on water.", player, CheckType.WATER_WALK);
|
||||||
// You come back up, and you suddenly feel sick from trying to stick yourself through the blocks..
|
changed = true;
|
||||||
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + result, event.getFrom().getZ());
|
}
|
||||||
if (result > 3)
|
if (checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player, x, z)) {
|
||||||
{
|
if (!config.silentMode()) {
|
||||||
result = 3; // prevents players from using AC as a way to teleport to sky islands.
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
}
|
player.setSneaking(false);
|
||||||
if (newloc.getBlock().getTypeId() == 0)
|
}
|
||||||
{
|
log("tried to sneak too fast.", player, CheckType.SNEAK);
|
||||||
event.setTo(newloc);
|
changed = true;
|
||||||
}
|
}
|
||||||
else
|
if (checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y)) {
|
||||||
{
|
if (!config.silentMode()) {
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
||||||
}
|
}
|
||||||
player.damage(3);
|
log("tried to climb a wall.", player, CheckType.SPIDER);
|
||||||
}
|
changed = true;
|
||||||
log("tried to move down through a block.", player, CheckType.VCLIP);
|
}
|
||||||
}
|
|
||||||
}
|
if (!changed) {
|
||||||
if (checkManager.willCheck(player, CheckType.NOFALL) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY() && backend.checkNoFall(player, y))
|
Anticheat.getManager().getUserManager().getUser(player.getName()).setGoodLocation(event.getFrom());
|
||||||
{
|
}
|
||||||
if (!config.silentMode())
|
}
|
||||||
{
|
}
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
|
||||||
player.damage(2); // I added this in here so the player(s) would still receive damage.
|
|
||||||
}
|
|
||||||
log("tried to avoid fall damage.", player, CheckType.NOFALL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
|
||||||
public void checkSpeed(PlayerMoveEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
Location from = event.getFrom();
|
|
||||||
Location to = event.getTo();
|
|
||||||
boolean changed = false;
|
|
||||||
|
|
||||||
if (event.getTo() != event.getFrom())
|
|
||||||
{
|
|
||||||
Distance distance = new Distance(from, to);
|
|
||||||
double x = distance.getXDifference();
|
|
||||||
double y = distance.getYDifference();
|
|
||||||
double z = distance.getZDifference();
|
|
||||||
if (checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
|
||||||
{
|
|
||||||
if (event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
|
|
||||||
{
|
|
||||||
if (!config.silentMode())
|
|
||||||
{
|
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log("tried to ascend too fast.", player, CheckType.SPEED);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if (backend.checkXZSpeed(player, x, z))
|
|
||||||
{
|
|
||||||
if (!config.silentMode())
|
|
||||||
{
|
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log("tried to move too fast.", player, CheckType.SPEED);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if ((event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) && backend.checkTimer(player))
|
|
||||||
{
|
|
||||||
if (!config.silentMode())
|
|
||||||
{
|
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log("tried to alter their timer.", player, CheckType.SPEED);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player, x, y, z))
|
|
||||||
{
|
|
||||||
if (!config.silentMode())
|
|
||||||
{
|
|
||||||
player.teleport(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(player.getLocation().add(0, -1, 0)));
|
|
||||||
}
|
|
||||||
log("tried to walk on water.", player, CheckType.WATER_WALK);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if (checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player, x, z))
|
|
||||||
{
|
|
||||||
if (!config.silentMode())
|
|
||||||
{
|
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
|
||||||
player.setSneaking(false);
|
|
||||||
}
|
|
||||||
log("tried to sneak too fast.", player, CheckType.SNEAK);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
if (checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
|
||||||
{
|
|
||||||
if (!config.silentMode())
|
|
||||||
{
|
|
||||||
event.setTo(Anticheat.getManager().getUserManager().getUser(player.getName()).getGoodLocation(from.clone()));
|
|
||||||
}
|
|
||||||
log("tried to climb a wall.", player, CheckType.SPIDER);
|
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!changed)
|
|
||||||
{
|
|
||||||
Anticheat.getManager().getUserManager().getUser(player.getName()).setGoodLocation(event.getFrom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -24,25 +24,20 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
|
|
||||||
public class VehicleListener extends EventListener
|
public class VehicleListener extends EventListener {
|
||||||
{
|
private final Backend backend = getBackend();
|
||||||
private final Backend backend = getBackend();
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
@EventHandler(ignoreCancelled = true)
|
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||||
public void onVehicleEnter(VehicleEnterEvent event)
|
if (event.getEntered() instanceof Player) {
|
||||||
{
|
backend.logEnterExit((Player) event.getEntered());
|
||||||
if (event.getEntered() instanceof Player)
|
}
|
||||||
{
|
}
|
||||||
backend.logEnterExit((Player) event.getEntered());
|
|
||||||
}
|
@EventHandler(ignoreCancelled = true)
|
||||||
}
|
public void onVehicleExit(VehicleExitEvent event) {
|
||||||
|
if (event.getExited() instanceof Player) {
|
||||||
@EventHandler(ignoreCancelled = true)
|
backend.logEnterExit((Player) event.getExited());
|
||||||
public void onVehicleExit(VehicleExitEvent event)
|
}
|
||||||
{
|
}
|
||||||
if (event.getExited() instanceof Player)
|
|
||||||
{
|
|
||||||
backend.logEnterExit((Player) event.getExited());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -37,121 +37,98 @@ import org.bukkit.ChatColor;
|
|||||||
* The internal hub for all managers.
|
* The internal hub for all managers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AnticheatManager
|
public class AnticheatManager {
|
||||||
{
|
private Anticheat plugin = null;
|
||||||
private Anticheat plugin = null;
|
private Configuration configuration;
|
||||||
private Configuration configuration;
|
private XRayTracker xrayTracker = null;
|
||||||
private XRayTracker xrayTracker = null;
|
private UserManager userManager = null;
|
||||||
private UserManager userManager = null;
|
private CheckManager checkManager = null;
|
||||||
private CheckManager checkManager = null;
|
private Backend backend = null;
|
||||||
private Backend backend = null;
|
private final Logger fileLogger;
|
||||||
private final Logger fileLogger;
|
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
||||||
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
private static Handler fileHandler;
|
||||||
private static Handler fileHandler;
|
private static final int LOG_LEVEL_HIGH = 3;
|
||||||
private static final int LOG_LEVEL_HIGH = 3;
|
|
||||||
|
public AnticheatManager(Anticheat instance, Logger logger) {
|
||||||
public AnticheatManager(Anticheat instance, Logger logger)
|
plugin = instance;
|
||||||
{
|
// now load all the others!!!!!
|
||||||
plugin = instance;
|
fileLogger = Logger.getLogger("net.h31ix.anticheat.Anticheat");
|
||||||
// now load all the others!!!!!
|
configuration = new Configuration(this);
|
||||||
fileLogger = Logger.getLogger("net.h31ix.anticheat.Anticheat");
|
xrayTracker = new XRayTracker();
|
||||||
configuration = new Configuration(this);
|
userManager = new UserManager(configuration);
|
||||||
xrayTracker = new XRayTracker();
|
checkManager = new CheckManager(this);
|
||||||
userManager = new UserManager(configuration);
|
backend = new Backend(this);
|
||||||
checkManager = new CheckManager(this);
|
try {
|
||||||
backend = new Backend(this);
|
File file = new File(plugin.getDataFolder() + "/log");
|
||||||
try
|
if (!file.exists()) {
|
||||||
{
|
file.mkdir();
|
||||||
File file = new File(plugin.getDataFolder() + "/log");
|
}
|
||||||
if (!file.exists())
|
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
||||||
{
|
fileHandler.setFormatter(new FileFormatter());
|
||||||
file.mkdir();
|
} catch (Exception ex) {
|
||||||
}
|
logger.log(Level.SEVERE, null, ex);
|
||||||
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
}
|
||||||
fileHandler.setFormatter(new FileFormatter());
|
fileLogger.setUseParentHandlers(false);
|
||||||
}
|
fileLogger.addHandler(fileHandler);
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
|
||||||
logger.log(Level.SEVERE, null, ex);
|
public void log(String message) {
|
||||||
}
|
log(message, 0);
|
||||||
fileLogger.setUseParentHandlers(false);
|
}
|
||||||
fileLogger.addHandler(fileHandler);
|
|
||||||
}
|
public void log(String message, int i) {
|
||||||
|
if (getConfiguration().logConsole()) {
|
||||||
public void log(String message)
|
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + message);
|
||||||
{
|
}
|
||||||
log(message, 0);
|
if (i == 0 && getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH) // Not an alert, normal log message
|
||||||
}
|
{
|
||||||
|
fileLog(message);
|
||||||
public void log(String message, int i)
|
} else if (getConfiguration().getFileLogLevel() != 0)// alert
|
||||||
{
|
{
|
||||||
if (getConfiguration().logConsole())
|
fileLog(message);
|
||||||
{
|
}
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED+message);
|
logs.add(ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
if(i == 0 && getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH) // Not an alert, normal log message
|
|
||||||
{
|
public void fileLog(String message) {
|
||||||
fileLog(message);
|
fileLogger.info(message);
|
||||||
}
|
}
|
||||||
else if(getConfiguration().getFileLogLevel() != 0)// alert
|
|
||||||
{
|
public List<String> getLastLogs() {
|
||||||
fileLog(message);
|
List<String> log = new CopyOnWriteArrayList<String>();
|
||||||
}
|
if (logs.size() < 30) { return logs; }
|
||||||
logs.add(ChatColor.stripColor(message));
|
for (int i = logs.size() - 1; i >= 0; i--) {
|
||||||
}
|
log.add(logs.get(i));
|
||||||
|
}
|
||||||
public void fileLog(String message)
|
logs.clear();
|
||||||
{
|
return log;
|
||||||
fileLogger.info(message);
|
}
|
||||||
}
|
|
||||||
|
public Anticheat getPlugin() {
|
||||||
public List<String> getLastLogs()
|
return plugin;
|
||||||
{
|
}
|
||||||
List<String> log = new CopyOnWriteArrayList<String>();
|
|
||||||
if (logs.size() < 30)
|
public Configuration getConfiguration() {
|
||||||
{
|
return configuration;
|
||||||
return logs;
|
}
|
||||||
}
|
|
||||||
for(int i = logs.size()-1; i >= 0; i--)
|
public XRayTracker getXRayTracker() {
|
||||||
{
|
return xrayTracker;
|
||||||
log.add(logs.get(i));
|
}
|
||||||
}
|
|
||||||
logs.clear();
|
public UserManager getUserManager() {
|
||||||
return log;
|
return userManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Anticheat getPlugin()
|
public CheckManager getCheckManager() {
|
||||||
{
|
return checkManager;
|
||||||
return plugin;
|
}
|
||||||
}
|
|
||||||
|
public Backend getBackend() {
|
||||||
public Configuration getConfiguration()
|
return backend;
|
||||||
{
|
}
|
||||||
return configuration;
|
|
||||||
}
|
public static void close() {
|
||||||
|
fileHandler.close();
|
||||||
public XRayTracker getXRayTracker()
|
}
|
||||||
{
|
|
||||||
return xrayTracker;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserManager getUserManager()
|
|
||||||
{
|
|
||||||
return userManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CheckManager getCheckManager()
|
|
||||||
{
|
|
||||||
return checkManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Backend getBackend()
|
|
||||||
{
|
|
||||||
return backend;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void close()
|
|
||||||
{
|
|
||||||
fileHandler.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -27,109 +27,86 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The manager that AntiCheat will check with to see if it should watch certain
|
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
||||||
* checks and certain players.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CheckManager
|
public class CheckManager {
|
||||||
{
|
private AnticheatManager manager = null;
|
||||||
private AnticheatManager manager = null;
|
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<CheckType>>();
|
||||||
private static Map<String, List<CheckType>> exemptList = new HashMap<String, List<CheckType>>();
|
private static int disabled = 0;
|
||||||
private static int disabled = 0;
|
private static int exempt = 0;
|
||||||
private static int exempt = 0;
|
|
||||||
|
public CheckManager(AnticheatManager instance) {
|
||||||
public CheckManager(AnticheatManager instance)
|
manager = instance;
|
||||||
{
|
}
|
||||||
manager = instance;
|
|
||||||
}
|
public void activateCheck(CheckType type) {
|
||||||
|
if (isActive(type)) {
|
||||||
public void activateCheck(CheckType type)
|
manager.log("The " + type.toString() + " check was activated.");
|
||||||
{
|
checkIgnoreList.remove(type);
|
||||||
if (isActive(type))
|
}
|
||||||
{
|
}
|
||||||
manager.log("The " + type.toString() + " check was activated.");
|
|
||||||
checkIgnoreList.remove(type);
|
public void deactivateCheck(CheckType type) {
|
||||||
}
|
if (!isActive(type)) {
|
||||||
}
|
manager.log("The " + type.toString() + " check was deactivated.");
|
||||||
|
checkIgnoreList.add(type);
|
||||||
public void deactivateCheck(CheckType type)
|
disabled++;
|
||||||
{
|
}
|
||||||
if (!isActive(type))
|
}
|
||||||
{
|
|
||||||
manager.log("The " + type.toString() + " check was deactivated.");
|
public boolean isActive(CheckType type) {
|
||||||
checkIgnoreList.add(type);
|
return !checkIgnoreList.contains(type);
|
||||||
disabled++;
|
}
|
||||||
}
|
|
||||||
}
|
public void exemptPlayer(Player player, CheckType type) {
|
||||||
|
if (!isExempt(player, type)) {
|
||||||
public boolean isActive(CheckType type)
|
if (!exemptList.containsKey(player.getName())) {
|
||||||
{
|
exemptList.put(player.getName(), new ArrayList<CheckType>());
|
||||||
return !checkIgnoreList.contains(type);
|
}
|
||||||
}
|
manager.log(player.getName() + " was exempted from the " + type.toString() + " check.");
|
||||||
|
exemptList.get(player.getName()).add(type);
|
||||||
public void exemptPlayer(Player player, CheckType type)
|
exempt++;
|
||||||
{
|
}
|
||||||
if (!isExempt(player, type))
|
}
|
||||||
{
|
|
||||||
if(!exemptList.containsKey(player.getName()))
|
public void unexemptPlayer(Player player, CheckType type) {
|
||||||
{
|
if (isExempt(player, type)) {
|
||||||
exemptList.put(player.getName(), new ArrayList<CheckType>());
|
manager.log(player.getName() + " was re-added to the " + type.toString() + " check.");
|
||||||
}
|
exemptList.get(player.getName()).remove(type);
|
||||||
manager.log(player.getName() + " was exempted from the " + type.toString() + " check.");
|
}
|
||||||
exemptList.get(player.getName()).add(type);
|
}
|
||||||
exempt++;
|
|
||||||
}
|
public boolean isExempt(Player player, CheckType type) {
|
||||||
}
|
return exemptList.containsKey(player.getName()) ? exemptList.get(player.getName()).contains(type) : false;
|
||||||
|
}
|
||||||
public void unexemptPlayer(Player player, CheckType type)
|
|
||||||
{
|
public boolean isOpExempt(Player player) {
|
||||||
if (isExempt(player, type))
|
return (this.manager.getConfiguration().opExempt() && player.isOp());
|
||||||
{
|
}
|
||||||
manager.log(player.getName() + " was re-added to the " + type.toString() + " check.");
|
|
||||||
exemptList.get(player.getName()).remove(type);
|
public boolean willCheck(Player player, CheckType type) {
|
||||||
}
|
return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) && !type.checkPermission(player) && isOnline(player) && !isOpExempt(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExempt(Player player, CheckType type)
|
public boolean isOnline(Player player) {
|
||||||
{
|
// Check if the player is on the user list, e.g. is not an NPC
|
||||||
return exemptList.containsKey(player.getName()) ? exemptList.get(player.getName()).contains(type) : false;
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
}
|
if (p.getName().equals(player.getName())) { return true; }
|
||||||
|
}
|
||||||
public boolean isOpExempt(Player player)
|
return false;
|
||||||
{
|
}
|
||||||
return (this.manager.getConfiguration().opExempt() && player.isOp());
|
|
||||||
}
|
public int getExempt() {
|
||||||
|
int x = exempt;
|
||||||
public boolean willCheck(Player player, CheckType type)
|
exempt = 0;
|
||||||
{
|
return x;
|
||||||
return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) && !type.checkPermission(player) && isOnline(player) && !isOpExempt(player);
|
}
|
||||||
}
|
|
||||||
|
public int getDisabled() {
|
||||||
public boolean isOnline(Player player)
|
int x = disabled;
|
||||||
{
|
disabled = 0;
|
||||||
// Check if the player is on the user list, e.g. is not an NPC
|
return x;
|
||||||
for(Player p : Bukkit.getOnlinePlayers())
|
}
|
||||||
{
|
|
||||||
if(p.getName().equals(player.getName()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getExempt()
|
|
||||||
{
|
|
||||||
int x = exempt;
|
|
||||||
exempt = 0;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDisabled()
|
|
||||||
{
|
|
||||||
int x = disabled;
|
|
||||||
disabled = 0;
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -28,67 +28,60 @@ import org.bukkit.entity.Player;
|
|||||||
* 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),
|
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
||||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
||||||
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
FLY(Permission.CHECK_FLY),
|
||||||
FLY(Permission.CHECK_FLY),
|
WATER_WALK(Permission.CHECK_WATERWALK),
|
||||||
WATER_WALK(Permission.CHECK_WATERWALK),
|
NO_SWING(Permission.CHECK_NOSWING),
|
||||||
NO_SWING(Permission.CHECK_NOSWING),
|
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
||||||
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
||||||
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
SPAM(Permission.CHECK_SPAM),
|
||||||
SPAM(Permission.CHECK_SPAM),
|
SPRINT(Permission.CHECK_SPRINT),
|
||||||
SPRINT(Permission.CHECK_SPRINT),
|
SNEAK(Permission.CHECK_SNEAK),
|
||||||
SNEAK(Permission.CHECK_SNEAK),
|
SPEED(Permission.CHECK_SPEED),
|
||||||
SPEED(Permission.CHECK_SPEED),
|
VCLIP(Permission.CHECK_VCLIP),
|
||||||
VCLIP(Permission.CHECK_VCLIP),
|
SPIDER(Permission.CHECK_SPIDER),
|
||||||
SPIDER(Permission.CHECK_SPIDER),
|
NOFALL(Permission.CHECK_NOFALL),
|
||||||
NOFALL(Permission.CHECK_NOFALL),
|
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
FAST_EAT(Permission.CHECK_FASTEAT),
|
||||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
||||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
||||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
XRAY(Permission.CHECK_XRAY),
|
||||||
XRAY(Permission.CHECK_XRAY),
|
LONG_REACH(Permission.CHECK_LONGREACH),
|
||||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
|
||||||
|
private final Permission permission;
|
||||||
private final Permission permission;
|
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
|
||||||
|
private CheckType(Permission perm) {
|
||||||
private CheckType(Permission perm)
|
this.permission = perm;
|
||||||
{
|
}
|
||||||
this.permission = perm;
|
|
||||||
}
|
public boolean checkPermission(Player player) {
|
||||||
|
return permission.get(player);
|
||||||
public boolean checkPermission(Player player)
|
}
|
||||||
{
|
|
||||||
return permission.get(player);
|
public void logUse(String name) {
|
||||||
}
|
int amount = level.get(name) == null ? 1 : level.get(name) + 1;
|
||||||
|
level.put(name, amount);
|
||||||
public void logUse(String name)
|
}
|
||||||
{
|
|
||||||
int amount = level.get(name) == null ? 1 : level.get(name) + 1;
|
public void clearUse(String name) {
|
||||||
level.put(name, amount);
|
level.put(name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearUse(String name)
|
public int getUses(String name) {
|
||||||
{
|
return level.get(name) != null ? level.get(name) : 0;
|
||||||
level.put(name, 0);
|
}
|
||||||
}
|
|
||||||
|
public static String getName(CheckType type) {
|
||||||
public int getUses(String name)
|
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||||
{
|
chars[0] = Character.toUpperCase(chars[0]);
|
||||||
return level.get(name) != null ? level.get(name) : 0;
|
return new String(chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName(CheckType type)
|
|
||||||
{
|
|
||||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
|
||||||
chars[0] = Character.toUpperCase(chars[0]);
|
|
||||||
return new String(chars);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -21,137 +21,102 @@ package net.h31ix.anticheat.manage;
|
|||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import net.h31ix.anticheat.util.Configuration;
|
import net.h31ix.anticheat.util.Configuration;
|
||||||
import net.h31ix.anticheat.util.Utilities;
|
import net.h31ix.anticheat.util.Utilities;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class User
|
public class User {
|
||||||
{
|
private final String name;
|
||||||
private final String name;
|
private int level = 0;
|
||||||
private int level = 0;
|
private int high;
|
||||||
private int high;
|
private int med;
|
||||||
private int med;
|
private Location goodLocation;
|
||||||
private Location goodLocation;
|
private boolean silentMode;
|
||||||
private boolean silentMode;
|
|
||||||
|
public User(String name) {
|
||||||
public User(String name)
|
this.name = name;
|
||||||
{
|
getConfigInfo();
|
||||||
this.name = name;
|
}
|
||||||
getConfigInfo();
|
|
||||||
}
|
public User(String name, int level) {
|
||||||
|
this.name = name;
|
||||||
public User(String name, int level)
|
this.level = level;
|
||||||
{
|
getConfigInfo();
|
||||||
this.name = name;
|
}
|
||||||
this.level = level;
|
|
||||||
getConfigInfo();
|
private void getConfigInfo() {
|
||||||
}
|
Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
|
silentMode = config.silentMode();
|
||||||
private void getConfigInfo()
|
med = config.medThreshold();
|
||||||
{
|
high = config.highThreshold();
|
||||||
Configuration config = Anticheat.getManager().getConfiguration();
|
}
|
||||||
silentMode = config.silentMode();
|
|
||||||
med = config.medThreshold();
|
public String getName() {
|
||||||
high = config.highThreshold();
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public Player getPlayer() {
|
||||||
{
|
return Bukkit.getPlayer(name);
|
||||||
return name;
|
}
|
||||||
}
|
|
||||||
|
public int getLevel() {
|
||||||
public Player getPlayer()
|
return level;
|
||||||
{
|
}
|
||||||
return Bukkit.getPlayer(name);
|
|
||||||
}
|
public boolean increaseLevel(CheckType type) {
|
||||||
|
if (getPlayer() != null && getPlayer().isOnline()) {
|
||||||
public int getLevel()
|
if (silentMode && type.getUses(name) % 4 != 0) {
|
||||||
{
|
// Prevent silent mode from increasing the level way too fast
|
||||||
return level;
|
return false;
|
||||||
}
|
} else {
|
||||||
|
level++;
|
||||||
public boolean increaseLevel(CheckType type)
|
if (level == med) {
|
||||||
{
|
Anticheat.getManager().getUserManager().alertMed(this, type);
|
||||||
if(getPlayer() != null && getPlayer().isOnline())
|
} else if (level == high) {
|
||||||
{
|
Anticheat.getManager().getUserManager().alertHigh(this, type);
|
||||||
if(silentMode && type.getUses(name) % 4 != 0)
|
// Prevent the player from going over the high limit
|
||||||
{
|
level = high - 10;
|
||||||
// Prevent silent mode from increasing the level way too fast
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
{
|
return false;
|
||||||
level++;
|
}
|
||||||
if(level == med)
|
}
|
||||||
{
|
|
||||||
Anticheat.getManager().getUserManager().alertMed(this, type);
|
public void decreaseLevel() {
|
||||||
}
|
level = level != 0 ? level - 1 : 0;
|
||||||
else if(level == high)
|
}
|
||||||
{
|
|
||||||
Anticheat.getManager().getUserManager().alertHigh(this, type);
|
public void setLevel(int level) {
|
||||||
// Prevent the player from going over the high limit
|
if (level > 0 && level <= high) {
|
||||||
level = high-10;
|
this.level = level;
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
}
|
public void resetLevel() {
|
||||||
else
|
level = 0;
|
||||||
{
|
for (CheckType type : CheckType.values()) {
|
||||||
return false;
|
type.clearUse(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decreaseLevel()
|
public Location getGoodLocation(Location e) {
|
||||||
{
|
if (goodLocation == null) { return e; }
|
||||||
level = level != 0 ? level-1 : 0;
|
|
||||||
}
|
return goodLocation;
|
||||||
|
}
|
||||||
public void setLevel(int level)
|
|
||||||
{
|
public boolean hasGoodLocation() {
|
||||||
if(level > 0 && level <= high)
|
return goodLocation != null;
|
||||||
{
|
}
|
||||||
this.level = level;
|
|
||||||
}
|
public void setGoodLocation(Location e) {
|
||||||
}
|
if (Utilities.cantStandAtExp(e)) { return; }
|
||||||
|
|
||||||
public void resetLevel()
|
if (e.getBlock().isLiquid() && !Utilities.isFullyInWater(e)) { return; }
|
||||||
{
|
|
||||||
level = 0;
|
goodLocation = e;
|
||||||
for (CheckType type : CheckType.values())
|
}
|
||||||
{
|
|
||||||
type.clearUse(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getGoodLocation(Location e)
|
|
||||||
{
|
|
||||||
if(goodLocation == null)
|
|
||||||
{
|
|
||||||
return e;
|
|
||||||
}
|
|
||||||
|
|
||||||
return goodLocation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasGoodLocation()
|
|
||||||
{
|
|
||||||
return goodLocation != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGoodLocation(Location e)
|
|
||||||
{
|
|
||||||
if(Utilities.cantStandAtExp(e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(e.getBlock().isLiquid() && !Utilities.isFullyInWater(e))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
goodLocation = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,174 +26,133 @@ import net.h31ix.anticheat.util.Utilities;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class UserManager
|
public class UserManager {
|
||||||
{
|
private List<User> users = new ArrayList<User>();
|
||||||
private List<User> users = new ArrayList<User>();
|
private static Configuration config;
|
||||||
private static Configuration config;
|
private static Language lang;
|
||||||
private static Language lang;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private static final ChatColor GOLD = ChatColor.GOLD;
|
||||||
private static final ChatColor GOLD = ChatColor.GOLD;
|
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||||
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
private static final ChatColor RED = ChatColor.RED;
|
||||||
private static final ChatColor RED = ChatColor.RED;
|
|
||||||
|
public UserManager(Configuration conf) {
|
||||||
public UserManager(Configuration conf)
|
config = conf;
|
||||||
{
|
lang = conf.getLang();
|
||||||
config = conf;
|
}
|
||||||
lang = conf.getLang();
|
|
||||||
}
|
public User getUser(String name) {
|
||||||
|
for (User user : users) {
|
||||||
public User getUser(String name)
|
if (user.getName().equalsIgnoreCase(name)) { return user; }
|
||||||
{
|
}
|
||||||
for(User user : users)
|
// Otherwise try to load them
|
||||||
{
|
return loadUserFromFile(name);
|
||||||
if(user.getName().equalsIgnoreCase(name))
|
}
|
||||||
{
|
|
||||||
return user;
|
public List<User> getUsers() {
|
||||||
}
|
return users;
|
||||||
}
|
}
|
||||||
// Otherwise try to load them
|
|
||||||
return loadUserFromFile(name);
|
public void addUser(User user) {
|
||||||
}
|
users.add(user);
|
||||||
|
}
|
||||||
public List<User> getUsers()
|
|
||||||
{
|
public void remove(User user) {
|
||||||
return users;
|
config.saveLevel(user.getName(), user.getLevel());
|
||||||
}
|
users.remove(user);
|
||||||
|
}
|
||||||
public void addUser(User user)
|
|
||||||
{
|
public int safeGetLevel(String name) {
|
||||||
users.add(user);
|
User user = getUser(name);
|
||||||
}
|
if (user == null) {
|
||||||
|
return 0;
|
||||||
public void remove(User user)
|
} else {
|
||||||
{
|
return user.getLevel();
|
||||||
config.saveLevel(user.getName(), user.getLevel());
|
}
|
||||||
users.remove(user);
|
}
|
||||||
}
|
|
||||||
|
public void safeSetLevel(String name, int level) {
|
||||||
public int safeGetLevel(String name)
|
User user = getUser(name);
|
||||||
{
|
if (user != null) {
|
||||||
User user = getUser(name);
|
user.setLevel(level);
|
||||||
if(user == null)
|
}
|
||||||
{
|
}
|
||||||
return 0;
|
|
||||||
}
|
public void safeReset(String name) {
|
||||||
else
|
User user = getUser(name);
|
||||||
{
|
if (user != null) {
|
||||||
return user.getLevel();
|
user.resetLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void safeSetLevel(String name, int level)
|
public boolean addUserFromFile(String name) {
|
||||||
{
|
User user = loadUserFromFile(name);
|
||||||
User user = getUser(name);
|
if (user != null) {
|
||||||
if(user != null)
|
users.add(user);
|
||||||
{
|
return true;
|
||||||
user.setLevel(level);
|
} else {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void safeReset(String name)
|
|
||||||
{
|
public User loadUserFromFile(String name) {
|
||||||
User user = getUser(name);
|
int level = config.getLevel(name);
|
||||||
if(user != null)
|
if (level == -1) {
|
||||||
{
|
return null;
|
||||||
user.resetLevel();
|
} else {
|
||||||
}
|
return new User(name, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public boolean addUserFromFile(String name)
|
|
||||||
{
|
public void alertMed(User user, CheckType type) {
|
||||||
User user = loadUserFromFile(name);
|
List<String> messageArray = lang.getMediumAlert();
|
||||||
if(user != null)
|
for (int i = 0; i < messageArray.size(); i++) {
|
||||||
{
|
String message = messageArray.get(i);
|
||||||
users.add(user);
|
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
||||||
return true;
|
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
||||||
}
|
message = message.replaceAll("medium", YELLOW + "medium" + GRAY);
|
||||||
else
|
messageArray.set(i, message);
|
||||||
{
|
}
|
||||||
return false;
|
Utilities.alert(messageArray);
|
||||||
}
|
execute(user, config.mediumEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public User loadUserFromFile(String name)
|
public void alertHigh(User user, CheckType type) {
|
||||||
{
|
List<String> messageArray = lang.getHighAlert();
|
||||||
int level = config.getLevel(name);
|
for (int i = 0; i < messageArray.size(); i++) {
|
||||||
if(level == -1)
|
String message = messageArray.get(i);
|
||||||
{
|
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
||||||
return null;
|
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
||||||
}
|
message = message.replaceAll("high", RED + "high" + GRAY);
|
||||||
else
|
messageArray.set(i, message);
|
||||||
{
|
}
|
||||||
return new User(name, level);
|
Utilities.alert(messageArray);
|
||||||
}
|
execute(user, config.highEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alertMed(User user, CheckType type)
|
public void execute(User user, String event) {
|
||||||
{
|
final String name = user.getName();
|
||||||
List<String> messageArray = lang.getMediumAlert();
|
if (event.startsWith("COMMAND[")) {
|
||||||
for(int i=0;i<messageArray.size();i++)
|
String command = event.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName());
|
||||||
{
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||||
String message = messageArray.get(i);
|
} else if (event.equalsIgnoreCase("KICK")) {
|
||||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
user.getPlayer().kickPlayer(RED + lang.getKickReason());
|
||||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
String msg = RED + lang.getKickBroadcast().replaceAll("&player", name);
|
||||||
message = message.replaceAll("medium", YELLOW + "medium" + GRAY);
|
if (!msg.equals("")) {
|
||||||
messageArray.set(i, message);
|
Bukkit.broadcastMessage(msg);
|
||||||
}
|
}
|
||||||
Utilities.alert(messageArray);
|
} else if (event.equalsIgnoreCase("WARN")) {
|
||||||
execute(user, config.mediumEvent());
|
List<String> message = lang.getWarning();
|
||||||
}
|
for (String string : message) {
|
||||||
|
user.getPlayer().sendMessage(RED + string);
|
||||||
public void alertHigh(User user, CheckType type)
|
}
|
||||||
{
|
} else if (event.equalsIgnoreCase("BAN")) {
|
||||||
List<String> messageArray = lang.getHighAlert();
|
user.getPlayer().setBanned(true);
|
||||||
for(int i=0;i<messageArray.size();i++)
|
user.getPlayer().kickPlayer(RED + lang.getBanReason());
|
||||||
{
|
String msg = RED + lang.getBanBroadcast().replaceAll("&player", name);
|
||||||
String message = messageArray.get(i);
|
if (!msg.equals("")) {
|
||||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
Bukkit.broadcastMessage(msg);
|
||||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
}
|
||||||
message = message.replaceAll("high", RED + "high" + GRAY);
|
}
|
||||||
messageArray.set(i, message);
|
}
|
||||||
}
|
|
||||||
Utilities.alert(messageArray);
|
|
||||||
execute(user, config.highEvent());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute(User user, String event)
|
|
||||||
{
|
|
||||||
final String name = user.getName();
|
|
||||||
if (event.startsWith("COMMAND["))
|
|
||||||
{
|
|
||||||
String command = event.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName());
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
|
||||||
}
|
|
||||||
else if (event.equalsIgnoreCase("KICK"))
|
|
||||||
{
|
|
||||||
user.getPlayer().kickPlayer(RED + lang.getKickReason());
|
|
||||||
String msg = RED + lang.getKickBroadcast().replaceAll("&player", name);
|
|
||||||
if(!msg.equals(""))
|
|
||||||
{
|
|
||||||
Bukkit.broadcastMessage(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.equalsIgnoreCase("WARN"))
|
|
||||||
{
|
|
||||||
List<String> message = lang.getWarning();
|
|
||||||
for (String string : message)
|
|
||||||
{
|
|
||||||
user.getPlayer().sendMessage(RED + string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (event.equalsIgnoreCase("BAN"))
|
|
||||||
{
|
|
||||||
user.getPlayer().setBanned(true);
|
|
||||||
user.getPlayer().kickPlayer(RED + lang.getBanReason());
|
|
||||||
String msg = RED + lang.getBanBroadcast().replaceAll("&player", name);
|
|
||||||
if(!msg.equals(""))
|
|
||||||
{
|
|
||||||
Bukkit.broadcastMessage(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -41,8 +41,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The metrics class obtains data about a plugin and submits statistics about it
|
* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend.
|
||||||
* to the metrics backend.
|
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Public methods provided by this class:
|
* Public methods provided by this class:
|
||||||
@@ -53,489 +52,413 @@ 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
|
*/
|
||||||
*/
|
private static final int REVISION = 5;
|
||||||
private static final int REVISION = 5;
|
|
||||||
|
/**
|
||||||
/**
|
* The base url of the metrics domain
|
||||||
* The base url of the metrics domain
|
*/
|
||||||
*/
|
private static final String BASE_URL = "http://metrics.griefcraft.com";
|
||||||
private static final String BASE_URL = "http://metrics.griefcraft.com";
|
|
||||||
|
/**
|
||||||
/**
|
* The url used to report a server's status
|
||||||
* The url used to report a server's status
|
*/
|
||||||
*/
|
private static final String REPORT_URL = "/report/%s";
|
||||||
private static final String REPORT_URL = "/report/%s";
|
|
||||||
|
/**
|
||||||
/**
|
* The file where guid and opt out is stored in
|
||||||
* The file where guid and opt out is stored in
|
*/
|
||||||
*/
|
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 version of metrics and want to change it.
|
||||||
* The separator to use for custom data. This MUST NOT change unless you are
|
*/
|
||||||
* 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 = "~~";
|
/**
|
||||||
|
* Interval of time to ping (in minutes)
|
||||||
/**
|
*/
|
||||||
* Interval of time to ping (in minutes)
|
private static final int PING_INTERVAL = 10;
|
||||||
*/
|
|
||||||
private static final int PING_INTERVAL = 10;
|
/**
|
||||||
|
* The plugin this metrics submits for
|
||||||
/**
|
*/
|
||||||
* The plugin this metrics submits for
|
private final Plugin plugin;
|
||||||
*/
|
|
||||||
private final Plugin plugin;
|
/**
|
||||||
|
* All of the custom graphs to submit to metrics
|
||||||
/**
|
*/
|
||||||
* All of the custom graphs to submit to 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
|
private final Graph defaultGraph = new Graph("Default");
|
||||||
* graph
|
|
||||||
*/
|
/**
|
||||||
private final Graph defaultGraph = new Graph("Default");
|
* The plugin configuration file
|
||||||
|
*/
|
||||||
/**
|
private final YamlConfiguration configuration;
|
||||||
* The plugin configuration file
|
|
||||||
*/
|
/**
|
||||||
private final YamlConfiguration configuration;
|
* Unique server id
|
||||||
|
*/
|
||||||
/**
|
private final String guid;
|
||||||
* Unique server id
|
|
||||||
*/
|
public Metrics(Plugin plugin) throws IOException {
|
||||||
private final String guid;
|
if (plugin == null) { throw new IllegalArgumentException("Plugin cannot be null"); }
|
||||||
|
|
||||||
public Metrics(Plugin plugin) throws IOException
|
this.plugin = plugin;
|
||||||
{
|
|
||||||
if (plugin == null)
|
// load the config
|
||||||
{
|
File file = new File(CONFIG_FILE);
|
||||||
throw new IllegalArgumentException("Plugin cannot be null");
|
configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
}
|
|
||||||
|
// add some defaults
|
||||||
this.plugin = plugin;
|
configuration.addDefault("opt-out", false);
|
||||||
|
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||||
// load the config
|
|
||||||
File file = new File(CONFIG_FILE);
|
// Do we need to create the file?
|
||||||
configuration = YamlConfiguration.loadConfiguration(file);
|
if (configuration.get("guid", null) == null) {
|
||||||
|
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
||||||
// add some defaults
|
configuration.save(file);
|
||||||
configuration.addDefault("opt-out", false);
|
}
|
||||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
|
||||||
|
// Load the guid then
|
||||||
// Do we need to create the file?
|
guid = configuration.getString("guid");
|
||||||
if (configuration.get("guid", null) == null)
|
}
|
||||||
{
|
|
||||||
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
/**
|
||||||
configuration.save(file);
|
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics website. Plotters can be added to the graph object returned.
|
||||||
}
|
*
|
||||||
|
* @param name
|
||||||
// Load the guid then
|
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||||
guid = configuration.getString("guid");
|
*/
|
||||||
}
|
public Graph createGraph(String name) {
|
||||||
|
if (name == null) { throw new IllegalArgumentException("Graph name cannot be null"); }
|
||||||
/**
|
|
||||||
* Construct and create a Graph that can be used to separate specific
|
// Construct the graph object
|
||||||
* plotters to their own graphs on the metrics website. Plotters can be
|
Graph graph = new Graph(name);
|
||||||
* added to the graph object returned.
|
|
||||||
*
|
// Now we can add our graph
|
||||||
* @param name
|
graphs.add(graph);
|
||||||
* @return Graph object created. Will never return NULL under normal
|
|
||||||
* circumstances unless bad parameters are given
|
// and return back
|
||||||
*/
|
return graph;
|
||||||
public Graph createGraph(String name)
|
}
|
||||||
{
|
|
||||||
if (name == null)
|
/**
|
||||||
{
|
* Adds a custom data plotter to the default graph
|
||||||
throw new IllegalArgumentException("Graph name cannot be null");
|
*
|
||||||
}
|
* @param plotter
|
||||||
|
*/
|
||||||
// Construct the graph object
|
public void addCustomData(Plotter plotter) {
|
||||||
Graph graph = new Graph(name);
|
if (plotter == null) { throw new IllegalArgumentException("Plotter cannot be null"); }
|
||||||
|
|
||||||
// Now we can add our graph
|
// Add the plotter to the graph o/
|
||||||
graphs.add(graph);
|
defaultGraph.addPlotter(plotter);
|
||||||
|
|
||||||
// and return back
|
// Ensure the default graph is included in the submitted graphs
|
||||||
return graph;
|
graphs.add(defaultGraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a custom data plotter to the default graph
|
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 ticks.
|
||||||
*
|
*/
|
||||||
* @param plotter
|
public void start() {
|
||||||
*/
|
// Did we opt out?
|
||||||
public void addCustomData(Plotter plotter)
|
if (configuration.getBoolean("opt-out", false)) { return; }
|
||||||
{
|
|
||||||
if (plotter == null)
|
// Begin hitting the server with glorious data
|
||||||
{
|
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
||||||
throw new IllegalArgumentException("Plotter cannot be null");
|
private boolean firstPost = true;
|
||||||
}
|
|
||||||
|
@Override
|
||||||
// Add the plotter to the graph o/
|
public void run() {
|
||||||
defaultGraph.addPlotter(plotter);
|
try {
|
||||||
|
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||||
// Ensure the default graph is included in the submitted graphs
|
// it is not a interval ping, so it evaluates to FALSE
|
||||||
graphs.add(defaultGraph);
|
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||||
}
|
postPlugin(!firstPost);
|
||||||
|
|
||||||
/**
|
// After the first post we set firstPost to false
|
||||||
* Start measuring statistics. This will immediately create an async
|
// Each post thereafter will be a ping
|
||||||
* repeating task as the plugin and send the initial data to the metrics
|
firstPost = false;
|
||||||
* backend, and then after that it will post in increments of PING_INTERVAL
|
} catch (IOException e) {
|
||||||
* * 1200 ticks.
|
System.err.println("[Metrics] " + e.getMessage());
|
||||||
*/
|
}
|
||||||
public void start()
|
}
|
||||||
{
|
}, 0, PING_INTERVAL * 1200);
|
||||||
// Did we opt out?
|
}
|
||||||
if (configuration.getBoolean("opt-out", false))
|
|
||||||
{
|
/**
|
||||||
return;
|
* Generic method that posts a plugin to the metrics website
|
||||||
}
|
*/
|
||||||
|
private void postPlugin(boolean isPing) throws IOException {
|
||||||
// Begin hitting the server with glorious data
|
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
{
|
|
||||||
private boolean firstPost = true;
|
// Construct the post data
|
||||||
|
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));
|
||||||
@Override
|
|
||||||
public void run()
|
// If we're pinging, append it
|
||||||
{
|
if (isPing) {
|
||||||
try
|
data += encodeDataPair("ping", "true");
|
||||||
{
|
}
|
||||||
// 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
|
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
// inside of the graph (e.g plotters)
|
||||||
postPlugin(!firstPost);
|
synchronized (graphs) {
|
||||||
|
Iterator<Graph> iter = graphs.iterator();
|
||||||
// After the first post we set firstPost to false
|
|
||||||
// Each post thereafter will be a ping
|
while (iter.hasNext()) {
|
||||||
firstPost = false;
|
Graph graph = iter.next();
|
||||||
}
|
|
||||||
catch (IOException e)
|
// 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.
|
||||||
System.err.println("[Metrics] " + e.getMessage());
|
// 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.
|
||||||
}
|
for (Plotter plotter : graph.getPlotters()) {
|
||||||
}, 0, PING_INTERVAL * 1200);
|
// The key name to send to the metrics server
|
||||||
}
|
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||||
|
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||||
/**
|
String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
|
||||||
* Generic method that posts a plugin to the metrics website
|
|
||||||
*/
|
// The value to send, which for the foreseeable future is just the string
|
||||||
private void postPlugin(boolean isPing) throws IOException
|
// value of plotter.getValue()
|
||||||
{
|
String value = Integer.toString(plotter.getValue());
|
||||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
|
||||||
PluginDescriptionFile description = plugin.getDescription();
|
// Add it to the http post data :)
|
||||||
|
data += encodeDataPair(key, value);
|
||||||
// Construct the post data
|
}
|
||||||
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));
|
}
|
||||||
|
}
|
||||||
// If we're pinging, append it
|
|
||||||
if (isPing)
|
// Create the url
|
||||||
{
|
URL url = new URL(BASE_URL + String.format(REPORT_URL, description.getName()));
|
||||||
data += encodeDataPair("ping", "true");
|
|
||||||
}
|
// Connect to the website
|
||||||
|
URLConnection connection;
|
||||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
|
||||||
// inside of the graph (e.g plotters)
|
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||||
synchronized (graphs)
|
// It does not reroute POST requests so we need to go around it
|
||||||
{
|
if (isMineshafterPresent()) {
|
||||||
Iterator<Graph> iter = graphs.iterator();
|
connection = url.openConnection(Proxy.NO_PROXY);
|
||||||
|
} else {
|
||||||
while (iter.hasNext())
|
connection = url.openConnection();
|
||||||
{
|
}
|
||||||
Graph graph = iter.next();
|
|
||||||
|
connection.setDoOutput(true);
|
||||||
// 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.
|
// Write the data
|
||||||
// Because our methods are private, no one but us can reasonably access this list
|
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
||||||
// without reflection so this is a safe assumption without adding more code.
|
writer.write(data);
|
||||||
for (Plotter plotter : graph.getPlotters())
|
writer.flush();
|
||||||
{
|
|
||||||
// The key name to send to the metrics server
|
// Now read the response
|
||||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
String response = reader.readLine();
|
||||||
String key = String.format("C%s%s%s%s", CUSTOM_DATA_SEPARATOR, graph.getName(), CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
|
|
||||||
|
// close resources
|
||||||
// The value to send, which for the foreseeable future is just the string
|
writer.close();
|
||||||
// value of plotter.getValue()
|
reader.close();
|
||||||
String value = Integer.toString(plotter.getValue());
|
|
||||||
|
if (response.startsWith("ERR")) {
|
||||||
// Add it to the http post data :)
|
throw new IOException(response); // Throw the exception
|
||||||
data += encodeDataPair(key, value);
|
} else {
|
||||||
}
|
// Is this the first update this hour?
|
||||||
}
|
if (response.contains("OK This is your first update this hour")) {
|
||||||
}
|
synchronized (graphs) {
|
||||||
|
Iterator<Graph> iter = graphs.iterator();
|
||||||
// Create the url
|
|
||||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, description.getName()));
|
while (iter.hasNext()) {
|
||||||
|
Graph graph = iter.next();
|
||||||
// Connect to the website
|
|
||||||
URLConnection connection;
|
for (Plotter plotter : graph.getPlotters()) {
|
||||||
|
plotter.reset();
|
||||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
}
|
||||||
// It does not reroute POST requests so we need to go around it
|
}
|
||||||
if (isMineshafterPresent())
|
}
|
||||||
{
|
}
|
||||||
connection = url.openConnection(Proxy.NO_PROXY);
|
}
|
||||||
}
|
// if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
|
||||||
else
|
}
|
||||||
{
|
|
||||||
connection = url.openConnection();
|
/**
|
||||||
}
|
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||||
|
*
|
||||||
connection.setDoOutput(true);
|
* @return
|
||||||
|
*/
|
||||||
// Write the data
|
private boolean isMineshafterPresent() {
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
|
try {
|
||||||
writer.write(data);
|
Class.forName("mineshafter.MineServer");
|
||||||
writer.flush();
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
// Now read the response
|
return false;
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
}
|
||||||
String response = reader.readLine();
|
}
|
||||||
|
|
||||||
// close resources
|
/**
|
||||||
writer.close();
|
* <p>
|
||||||
reader.close();
|
* 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>
|
||||||
if (response.startsWith("ERR"))
|
* <code>
|
||||||
{
|
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
||||||
throw new IOException(response); //Throw the exception
|
* </code>
|
||||||
}
|
*
|
||||||
else
|
* @param key
|
||||||
{
|
* @param value
|
||||||
// Is this the first update this hour?
|
* @return
|
||||||
if (response.contains("OK This is your first update this hour"))
|
*/
|
||||||
{
|
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException {
|
||||||
synchronized (graphs)
|
return '&' + encode(key) + '=' + encode(value);
|
||||||
{
|
}
|
||||||
Iterator<Graph> iter = graphs.iterator();
|
|
||||||
|
/**
|
||||||
while (iter.hasNext())
|
* Encode text as UTF-8
|
||||||
{
|
*
|
||||||
Graph graph = iter.next();
|
* @param text
|
||||||
|
* @return
|
||||||
for (Plotter plotter : graph.getPlotters())
|
*/
|
||||||
{
|
private static String encode(String text) throws UnsupportedEncodingException {
|
||||||
plotter.reset();
|
return URLEncoder.encode(text, "UTF-8");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
}
|
* Represents a custom graph on the website
|
||||||
}
|
*/
|
||||||
//if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
|
public static class Graph {
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is rejected
|
||||||
* Check if mineshafter is present. If it is, we need to bypass it to send
|
*/
|
||||||
* POST requests
|
private final String name;
|
||||||
*
|
|
||||||
* @return
|
/**
|
||||||
*/
|
* The set of plotters that are contained within this graph
|
||||||
private boolean isMineshafterPresent()
|
*/
|
||||||
{
|
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||||
try
|
|
||||||
{
|
private Graph(String name) {
|
||||||
Class.forName("mineshafter.MineServer");
|
this.name = name;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
/**
|
||||||
{
|
* Gets the graph's name
|
||||||
return false;
|
*
|
||||||
}
|
* @return
|
||||||
}
|
*/
|
||||||
|
public String getName() {
|
||||||
/**
|
return name;
|
||||||
* <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>
|
* Add a plotter to the graph, which will be used to plot entries
|
||||||
* <code>
|
*
|
||||||
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
* @param plotter
|
||||||
* </code>
|
*/
|
||||||
*
|
public void addPlotter(Plotter plotter) {
|
||||||
* @param key
|
plotters.add(plotter);
|
||||||
* @param value
|
}
|
||||||
* @return
|
|
||||||
*/
|
/**
|
||||||
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException
|
* Remove a plotter from the graph
|
||||||
{
|
*
|
||||||
return '&' + encode(key) + '=' + encode(value);
|
* @param plotter
|
||||||
}
|
*/
|
||||||
|
public void removePlotter(Plotter plotter) {
|
||||||
/**
|
plotters.remove(plotter);
|
||||||
* Encode text as UTF-8
|
}
|
||||||
*
|
|
||||||
* @param text
|
/**
|
||||||
* @return
|
* Gets an <strong>unmodifiable</strong> set of the plotter objects in the graph
|
||||||
*/
|
*
|
||||||
private static String encode(String text) throws UnsupportedEncodingException
|
* @return
|
||||||
{
|
*/
|
||||||
return URLEncoder.encode(text, "UTF-8");
|
public Set<Plotter> getPlotters() {
|
||||||
}
|
return Collections.unmodifiableSet(plotters);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Represents a custom graph on the website
|
@Override
|
||||||
*/
|
public int hashCode() {
|
||||||
public static class Graph
|
return name.hashCode();
|
||||||
{
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* The graph's name, alphanumeric and spaces only :) If it does not
|
public boolean equals(Object object) {
|
||||||
* comply to the above when submitted, it is rejected
|
if (!(object instanceof Graph)) { return false; }
|
||||||
*/
|
|
||||||
private final String name;
|
Graph graph = (Graph) object;
|
||||||
|
return graph.name.equals(name);
|
||||||
/**
|
}
|
||||||
* The set of plotters that are contained within this graph
|
|
||||||
*/
|
}
|
||||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
|
||||||
|
/**
|
||||||
private Graph(String name)
|
* Interface used to collect custom data for a plugin
|
||||||
{
|
*/
|
||||||
this.name = name;
|
public static abstract class Plotter {
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* The plot's name
|
||||||
* Gets the graph's name
|
*/
|
||||||
*
|
private final String name;
|
||||||
* @return
|
|
||||||
*/
|
/**
|
||||||
public String getName()
|
* Construct a plotter with the default plot name
|
||||||
{
|
*/
|
||||||
return name;
|
public Plotter() {
|
||||||
}
|
this("Default");
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Add a plotter to the graph, which will be used to plot entries
|
/**
|
||||||
*
|
* Construct a plotter with a specific plot name
|
||||||
* @param plotter
|
*
|
||||||
*/
|
* @param name
|
||||||
public void addPlotter(Plotter plotter)
|
*/
|
||||||
{
|
public Plotter(String name) {
|
||||||
plotters.add(plotter);
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a plotter from the graph
|
* Get the current value for the plotted point
|
||||||
*
|
*
|
||||||
* @param plotter
|
* @return
|
||||||
*/
|
*/
|
||||||
public void removePlotter(Plotter plotter)
|
public abstract int getValue();
|
||||||
{
|
|
||||||
plotters.remove(plotter);
|
/**
|
||||||
}
|
* Get the column name for the plotted point
|
||||||
|
*
|
||||||
/**
|
* @return the plotted point's column name
|
||||||
* Gets an <strong>unmodifiable</strong> set of the plotter objects in the graph
|
*/
|
||||||
*
|
public String getColumnName() {
|
||||||
* @return
|
return name;
|
||||||
*/
|
}
|
||||||
public Set<Plotter> getPlotters()
|
|
||||||
{
|
/**
|
||||||
return Collections.unmodifiableSet(plotters);
|
* Called after the website graphs have been updated
|
||||||
}
|
*/
|
||||||
|
public void reset() {
|
||||||
@Override
|
}
|
||||||
public int hashCode()
|
|
||||||
{
|
@Override
|
||||||
return name.hashCode();
|
public int hashCode() {
|
||||||
}
|
return getColumnName().hashCode() + getValue();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
@Override
|
||||||
{
|
public boolean equals(Object object) {
|
||||||
if (!(object instanceof Graph))
|
if (!(object instanceof Plotter)) { return false; }
|
||||||
{
|
|
||||||
return false;
|
Plotter plotter = (Plotter) object;
|
||||||
}
|
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
||||||
|
}
|
||||||
Graph graph = (Graph) object;
|
|
||||||
return graph.name.equals(name);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Interface used to collect custom data for a plugin
|
|
||||||
*/
|
|
||||||
public static abstract class Plotter
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The plot's name
|
|
||||||
*/
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a plotter with the default plot name
|
|
||||||
*/
|
|
||||||
public Plotter()
|
|
||||||
{
|
|
||||||
this("Default");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a plotter with a specific plot name
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public Plotter(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current value for the plotted point
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract int getValue();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the column name for the plotted point
|
|
||||||
*
|
|
||||||
* @return the plotted point's column name
|
|
||||||
*/
|
|
||||||
public String getColumnName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after the website graphs have been updated
|
|
||||||
*/
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
return getColumnName().hashCode() + getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object object)
|
|
||||||
{
|
|
||||||
if (!(object instanceof Plotter))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plotter plotter = (Plotter) object;
|
|
||||||
return plotter.name.equals(name) && plotter.getValue() == getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -2,136 +2,131 @@ package net.h31ix.anticheat.util;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public enum BlockHardness
|
public enum BlockHardness {
|
||||||
{
|
STONE(Material.STONE, 1.50D),
|
||||||
STONE(Material.STONE, 1.50D),
|
GRASS(Material.GRASS, 0.60D),
|
||||||
GRASS(Material.GRASS, 0.60D),
|
DIRT(Material.DIRT, 0.50D),
|
||||||
DIRT(Material.DIRT, 0.50D),
|
COBBLESTONE(Material.COBBLESTONE, 2.00D),
|
||||||
COBBLESTONE(Material.COBBLESTONE, 2.00D),
|
WOOD(Material.WOOD, 2.00D),
|
||||||
WOOD(Material.WOOD, 2.00D),
|
SAPLING(Material.SAPLING, 0.00D),
|
||||||
SAPLING(Material.SAPLING, 0.00D),
|
WATER(Material.WATER, 100.00D),
|
||||||
WATER(Material.WATER, 100.00D),
|
STATIONARY_WATER(Material.STATIONARY_WATER, 100.00D),
|
||||||
STATIONARY_WATER(Material.STATIONARY_WATER, 100.00D),
|
LAVA(Material.LAVA, 0.00D),
|
||||||
LAVA(Material.LAVA, 0.00D),
|
STATIONARY_LAVA(Material.STATIONARY_LAVA, 100.00D),
|
||||||
STATIONARY_LAVA(Material.STATIONARY_LAVA, 100.00D),
|
SAND(Material.SAND, 0.50D),
|
||||||
SAND(Material.SAND, 0.50D),
|
GRAVEL(Material.GRAVEL, 0.60D),
|
||||||
GRAVEL(Material.GRAVEL, 0.60D),
|
GOLD_ORE(Material.GOLD_ORE, 3.00D),
|
||||||
GOLD_ORE(Material.GOLD_ORE, 3.00D),
|
IRON_ORE(Material.IRON_ORE, 3.00D),
|
||||||
IRON_ORE(Material.IRON_ORE, 3.00D),
|
COAL_ORE(Material.COAL_ORE, 3.00D),
|
||||||
COAL_ORE(Material.COAL_ORE, 3.00D),
|
LOG(Material.LOG, 2.00D),
|
||||||
LOG(Material.LOG, 2.00D),
|
LEAVES(Material.LEAVES, 0.20D),
|
||||||
LEAVES(Material.LEAVES, 0.20D),
|
SPONGE(Material.SPONGE, 0.60D),
|
||||||
SPONGE(Material.SPONGE, 0.60D),
|
GLASS(Material.GLASS, 0.30D),
|
||||||
GLASS(Material.GLASS, 0.30D),
|
LAPIS_ORE(Material.LAPIS_ORE, 3.00D),
|
||||||
LAPIS_ORE(Material.LAPIS_ORE, 3.00D),
|
LAPIS_BLOCK(Material.LAPIS_BLOCK, 3.00D),
|
||||||
LAPIS_BLOCK(Material.LAPIS_BLOCK, 3.00D),
|
DISPENSER(Material.DISPENSER, 3.50D),
|
||||||
DISPENSER(Material.DISPENSER, 3.50D),
|
SANDSTONE(Material.SANDSTONE, 0.80D),
|
||||||
SANDSTONE(Material.SANDSTONE, 0.80D),
|
NOTE_BLOCK(Material.NOTE_BLOCK, 0.80D),
|
||||||
NOTE_BLOCK(Material.NOTE_BLOCK, 0.80D),
|
BED(Material.BED, 0.20D),
|
||||||
BED(Material.BED, 0.20D),
|
DETECTOR_RAIL(Material.DETECTOR_RAIL, 0.70D),
|
||||||
DETECTOR_RAIL(Material.DETECTOR_RAIL, 0.70D),
|
WEB(Material.WEB, 4.00D),
|
||||||
WEB(Material.WEB, 4.00D),
|
LONG_GRASS(Material.LONG_GRASS, 0.00D),
|
||||||
LONG_GRASS(Material.LONG_GRASS, 0.00D),
|
DEAD_BUSH(Material.DEAD_BUSH, 0.00D),
|
||||||
DEAD_BUSH(Material.DEAD_BUSH, 0.00D),
|
WOOL(Material.WOOL, 0.80D),
|
||||||
WOOL(Material.WOOL, 0.80D),
|
YELLOW_FLOWER(Material.YELLOW_FLOWER, 0.00D),
|
||||||
YELLOW_FLOWER(Material.YELLOW_FLOWER, 0.00D),
|
RED_ROSE(Material.RED_ROSE, 0.00D),
|
||||||
RED_ROSE(Material.RED_ROSE, 0.00D),
|
BROWN_MUSHROOM(Material.BROWN_MUSHROOM, 0.00D),
|
||||||
BROWN_MUSHROOM(Material.BROWN_MUSHROOM, 0.00D),
|
RED_MUSHROOM(Material.RED_MUSHROOM, 0.00D),
|
||||||
RED_MUSHROOM(Material.RED_MUSHROOM, 0.00D),
|
GOLD_BLOCK(Material.GOLD_BLOCK, 3.00D),
|
||||||
GOLD_BLOCK(Material.GOLD_BLOCK, 3.00D),
|
IRON_BLOCK(Material.IRON_BLOCK, 5.00D),
|
||||||
IRON_BLOCK(Material.IRON_BLOCK, 5.00D),
|
DOUBLE_STEP(Material.DOUBLE_STEP, 2.00D),
|
||||||
DOUBLE_STEP(Material.DOUBLE_STEP, 2.00D),
|
STEP(Material.STEP, 2.00D),
|
||||||
STEP(Material.STEP, 2.00D),
|
BRICK(Material.BRICK, 2.00D),
|
||||||
BRICK(Material.BRICK, 2.00D),
|
TNT(Material.TNT, 0.00D),
|
||||||
TNT(Material.TNT, 0.00D),
|
BOOKSHELF(Material.BOOKSHELF, 1.50D),
|
||||||
BOOKSHELF(Material.BOOKSHELF, 1.50D),
|
MOSSY_COBBLESTONE(Material.MOSSY_COBBLESTONE, 2.00D),
|
||||||
MOSSY_COBBLESTONE(Material.MOSSY_COBBLESTONE, 2.00D),
|
OBSIDIAN(Material.OBSIDIAN, 50.00D),
|
||||||
OBSIDIAN(Material.OBSIDIAN, 50.00D),
|
TORCH(Material.TORCH, 0.00D),
|
||||||
TORCH(Material.TORCH, 0.00D),
|
FIRE(Material.FIRE, 0.00D),
|
||||||
FIRE(Material.FIRE, 0.00D),
|
MOB_SPAWNER(Material.MOB_SPAWNER, 5.00D),
|
||||||
MOB_SPAWNER(Material.MOB_SPAWNER, 5.00D),
|
CHEST(Material.CHEST, 2.50D),
|
||||||
CHEST(Material.CHEST, 2.50D),
|
REDSTONE_WIRE(Material.REDSTONE_WIRE, 0.00D),
|
||||||
REDSTONE_WIRE(Material.REDSTONE_WIRE, 0.00D),
|
DIAMOND_ORE(Material.DIAMOND_ORE, 3.00D),
|
||||||
DIAMOND_ORE(Material.DIAMOND_ORE, 3.00D),
|
DIAMOND_BLOCK(Material.DIAMOND_BLOCK, 5.00D),
|
||||||
DIAMOND_BLOCK(Material.DIAMOND_BLOCK, 5.00D),
|
WORKBENCH(Material.WORKBENCH, 2.50D),
|
||||||
WORKBENCH(Material.WORKBENCH, 2.50D),
|
SOIL(Material.SOIL, 0.60D),
|
||||||
SOIL(Material.SOIL, 0.60D),
|
FURNACE(Material.FURNACE, 3.50D),
|
||||||
FURNACE(Material.FURNACE, 3.50D),
|
BURNING_FURNACE(Material.BURNING_FURNACE, 3.50D),
|
||||||
BURNING_FURNACE(Material.BURNING_FURNACE, 3.50D),
|
WOODEN_DOOR(Material.WOODEN_DOOR, 3.00D),
|
||||||
WOODEN_DOOR(Material.WOODEN_DOOR, 3.00D),
|
LADDER(Material.LADDER, 0.40D),
|
||||||
LADDER(Material.LADDER, 0.40D),
|
RAILS(Material.RAILS, 0.70D),
|
||||||
RAILS(Material.RAILS, 0.70D),
|
LEVER(Material.LEVER, 0.50D),
|
||||||
LEVER(Material.LEVER, 0.50D),
|
STONE_PLATE(Material.STONE_PLATE, 0.50D),
|
||||||
STONE_PLATE(Material.STONE_PLATE, 0.50D),
|
IRON_DOOR_BLOCK(Material.IRON_DOOR_BLOCK, 5.00D),
|
||||||
IRON_DOOR_BLOCK(Material.IRON_DOOR_BLOCK, 5.00D),
|
WOOD_PLATE(Material.WOOD_PLATE, 0.50D),
|
||||||
WOOD_PLATE(Material.WOOD_PLATE, 0.50D),
|
REDSTONE_ORE(Material.REDSTONE_ORE, 3.00D),
|
||||||
REDSTONE_ORE(Material.REDSTONE_ORE, 3.00D),
|
GLOWING_REDSTONE_ORE(Material.GLOWING_REDSTONE_ORE, 3.00D),
|
||||||
GLOWING_REDSTONE_ORE(Material.GLOWING_REDSTONE_ORE, 3.00D),
|
REDSTONE_TORCH_OFF(Material.REDSTONE_TORCH_OFF, 0.00D),
|
||||||
REDSTONE_TORCH_OFF(Material.REDSTONE_TORCH_OFF, 0.00D),
|
REDSTONE_TORCH_ON(Material.REDSTONE_TORCH_ON, 0.00D),
|
||||||
REDSTONE_TORCH_ON(Material.REDSTONE_TORCH_ON, 0.00D),
|
STONE_BUTTON(Material.STONE_BUTTON, 0.50D),
|
||||||
STONE_BUTTON(Material.STONE_BUTTON, 0.50D),
|
SNOW(Material.SNOW, 0.10D),
|
||||||
SNOW(Material.SNOW, 0.10D),
|
ICE(Material.ICE, 0.50D),
|
||||||
ICE(Material.ICE, 0.50D),
|
SNOW_BLOCK(Material.SNOW_BLOCK, 0.20D),
|
||||||
SNOW_BLOCK(Material.SNOW_BLOCK, 0.20D),
|
CACTUS(Material.CACTUS, 0.40D),
|
||||||
CACTUS(Material.CACTUS, 0.40D),
|
CLAY(Material.CLAY, 0.60D),
|
||||||
CLAY(Material.CLAY, 0.60D),
|
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, 0.00D),
|
||||||
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, 0.00D),
|
JUKEBOX(Material.JUKEBOX, 2.00D),
|
||||||
JUKEBOX(Material.JUKEBOX, 2.00D),
|
FENCE(Material.FENCE, 2.00D),
|
||||||
FENCE(Material.FENCE, 2.00D),
|
NETHERRACK(Material.NETHERRACK, 0.40D),
|
||||||
NETHERRACK(Material.NETHERRACK, 0.40D),
|
SOUL_SAND(Material.SOUL_SAND, 0.50D),
|
||||||
SOUL_SAND(Material.SOUL_SAND, 0.50D),
|
GLOWSTONE(Material.GLOWSTONE, 0.30D),
|
||||||
GLOWSTONE(Material.GLOWSTONE, 0.30D),
|
PORTAL(Material.PORTAL, -1.00D),
|
||||||
PORTAL(Material.PORTAL, -1.00D),
|
CAKE_BLOCK(Material.CAKE_BLOCK, 0.50D),
|
||||||
CAKE_BLOCK(Material.CAKE_BLOCK, 0.50D),
|
LOCKED_CHEST(Material.LOCKED_CHEST, 0.00D),
|
||||||
LOCKED_CHEST(Material.LOCKED_CHEST, 0.00D),
|
TRAP_DOOR(Material.TRAP_DOOR, 3.00D),
|
||||||
TRAP_DOOR(Material.TRAP_DOOR, 3.00D),
|
MONSTER_EGGS(Material.MONSTER_EGGS, 0.750D),
|
||||||
MONSTER_EGGS(Material.MONSTER_EGGS, 0.750D),
|
SMOOTH_BRICK(Material.SMOOTH_BRICK, 1.50D),
|
||||||
SMOOTH_BRICK(Material.SMOOTH_BRICK, 1.50D),
|
IRON_FENCE(Material.IRON_FENCE, 5.00D),
|
||||||
IRON_FENCE(Material.IRON_FENCE, 5.00D),
|
THIN_GLASS(Material.THIN_GLASS, 0.30D),
|
||||||
THIN_GLASS(Material.THIN_GLASS, 0.30D),
|
PUMPKIN_STEM(Material.PUMPKIN_STEM, 0.00D),
|
||||||
PUMPKIN_STEM(Material.PUMPKIN_STEM, 0.00D),
|
MELON_STEM(Material.MELON_STEM, 0.00D),
|
||||||
MELON_STEM(Material.MELON_STEM, 0.00D),
|
VINE(Material.VINE, 0.20D),
|
||||||
VINE(Material.VINE, 0.20D),
|
FENCE_GATE(Material.FENCE_GATE, 2.00D),
|
||||||
FENCE_GATE(Material.FENCE_GATE, 2.00D),
|
MYCEL(Material.MYCEL, 0.60D),
|
||||||
MYCEL(Material.MYCEL, 0.60D),
|
WATER_LILY(Material.WATER_LILY, 0.00D),
|
||||||
WATER_LILY(Material.WATER_LILY, 0.00D),
|
NETHER_BRICK(Material.NETHER_BRICK, 2.00D),
|
||||||
NETHER_BRICK(Material.NETHER_BRICK, 2.00D),
|
NETHER_FENCE(Material.NETHER_FENCE, 2.00D),
|
||||||
NETHER_FENCE(Material.NETHER_FENCE, 2.00D),
|
ENCHANTMENT_TABLE(Material.ENCHANTMENT_TABLE, 5.00D),
|
||||||
ENCHANTMENT_TABLE(Material.ENCHANTMENT_TABLE, 5.00D),
|
BREWING_STAND(Material.BREWING_STAND, 0.50D),
|
||||||
BREWING_STAND(Material.BREWING_STAND, 0.50D),
|
CAULDRON(Material.CAULDRON, 2.00D),
|
||||||
CAULDRON(Material.CAULDRON, 2.00D),
|
ENDER_PORTAL(Material.ENDER_PORTAL, -1.00D),
|
||||||
ENDER_PORTAL(Material.ENDER_PORTAL, -1.00D),
|
ENDER_PORTAL_FRAME(Material.ENDER_PORTAL_FRAME, -1.00D),
|
||||||
ENDER_PORTAL_FRAME(Material.ENDER_PORTAL_FRAME, -1.00D),
|
DRAGON_EGG(Material.DRAGON_EGG, 3.00D),
|
||||||
DRAGON_EGG(Material.DRAGON_EGG, 3.00D),
|
REDSTONE_LAMP_OFF(Material.REDSTONE_LAMP_OFF, 0.30D),
|
||||||
REDSTONE_LAMP_OFF(Material.REDSTONE_LAMP_OFF, 0.30D),
|
REDSTONE_LAMP_ON(Material.REDSTONE_LAMP_ON, 0.30D),
|
||||||
REDSTONE_LAMP_ON(Material.REDSTONE_LAMP_ON, 0.30D),
|
WOOD_DOUBLE_STEP(Material.WOOD_DOUBLE_STEP, 2.00D),
|
||||||
WOOD_DOUBLE_STEP(Material.WOOD_DOUBLE_STEP, 2.00D),
|
WOOD_STEP(Material.WOOD_STEP, 2.00D),
|
||||||
WOOD_STEP(Material.WOOD_STEP, 2.00D),
|
COCOA(Material.COCOA, 0.20D),
|
||||||
COCOA(Material.COCOA, 0.20D),
|
EMERALD_ORE(Material.EMERALD_ORE, 3.00D),
|
||||||
EMERALD_ORE(Material.EMERALD_ORE, 3.00D),
|
ENDER_CHEST(Material.ENDER_CHEST, 22.50D),
|
||||||
ENDER_CHEST(Material.ENDER_CHEST, 22.50D),
|
EMERALD_BLOCK(Material.EMERALD_BLOCK, 5.00D),
|
||||||
EMERALD_BLOCK(Material.EMERALD_BLOCK, 5.00D),
|
FLOWER_POT(Material.FLOWER_POT, 0.00D),
|
||||||
FLOWER_POT(Material.FLOWER_POT, 0.00D),
|
WOOD_BUTTON(Material.WOOD_BUTTON, 0.50D),
|
||||||
WOOD_BUTTON(Material.WOOD_BUTTON, 0.50D),
|
ANVIL(Material.ANVIL, 5.00D);
|
||||||
ANVIL(Material.ANVIL, 5.00D);
|
|
||||||
|
Material mat;
|
||||||
Material mat;
|
double hardness;
|
||||||
double hardness;
|
|
||||||
|
BlockHardness(Material m, double hard) {
|
||||||
BlockHardness(Material m, double hard)
|
mat = m;
|
||||||
{
|
hardness = hard;
|
||||||
mat = m;
|
}
|
||||||
hardness = hard;
|
|
||||||
}
|
public static double getBlockHardness(Material m) {
|
||||||
|
for (BlockHardness e : BlockHardness.values()) {
|
||||||
public static double getBlockHardness(Material m)
|
if (e.mat.equals(m)) return e.hardness;
|
||||||
{
|
}
|
||||||
for (BlockHardness e : BlockHardness.values())
|
|
||||||
{
|
return 1.0D;
|
||||||
if (e.mat.equals(m))
|
}
|
||||||
return e.hardness;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1.0D;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -14,292 +14,226 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Calibrator implements Listener
|
public class Calibrator implements Listener {
|
||||||
{
|
private final Player player;
|
||||||
private final Player player;
|
private int step = 0;
|
||||||
private int step = 0;
|
private static final int TOTAL = 30;
|
||||||
private static final int TOTAL = 30;
|
private long lastLong;
|
||||||
private long lastLong;
|
private int lastInt;
|
||||||
private int lastInt;
|
private int lastDouble;
|
||||||
private int lastDouble;
|
private long[] longs = new long[10];
|
||||||
private long [] longs = new long[10];
|
private double[] doubles = new double[10];
|
||||||
private double [] doubles = new double[10];
|
private int[] ints = new int[10];
|
||||||
private int [] ints = new int[10];
|
private int times = 0;
|
||||||
private int times = 0;
|
|
||||||
|
// Value-specific calculations
|
||||||
// Value-specific calculations
|
private long projectileTime;
|
||||||
private long projectileTime;
|
private long dropItemTime;
|
||||||
private long dropItemTime;
|
private long punchAvg;
|
||||||
private long punchAvg;
|
private double blockBreakMax;
|
||||||
private double blockBreakMax;
|
private double blockPlaceMax;
|
||||||
private double blockPlaceMax;
|
|
||||||
|
public Calibrator(Player player) {
|
||||||
public Calibrator(Player player)
|
this.player = player;
|
||||||
{
|
player.sendMessage(ChatColor.GREEN + "----You have entered calibration mode.----");
|
||||||
this.player = player;
|
// Wait for listener to be registered and calibrate method called.
|
||||||
player.sendMessage(ChatColor.GREEN+"----You have entered calibration mode.----");
|
}
|
||||||
// Wait for listener to be registered and calibrate method called.
|
|
||||||
}
|
public void calibrate() {
|
||||||
|
switch (step) {
|
||||||
public void calibrate()
|
case 0:
|
||||||
{
|
sendStep();
|
||||||
switch(step)
|
player.getInventory().setItemInHand(new ItemStack(Material.BOW));
|
||||||
{
|
player.getInventory().addItem(new ItemStack(Material.ARROW, 64));
|
||||||
case 0:
|
player.sendMessage("Fire arrows as fast as possible (don't pull all the way back)");
|
||||||
sendStep();
|
break;
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.BOW));
|
case 2:
|
||||||
player.getInventory().addItem(new ItemStack(Material.ARROW, 64));
|
player.getInventory().clear();
|
||||||
player.sendMessage("Fire arrows as fast as possible (don't pull all the way back)");
|
player.getInventory().setItemInHand(new ItemStack(Material.DIRT, 64));
|
||||||
break;
|
player.sendMessage("Drop items as fast as possible.");
|
||||||
case 2:
|
/*
|
||||||
player.getInventory().clear();
|
* case 0: sendStep(); player.sendMessage("Spam the left mouse button as fast as possible."); break; case 2: player.setGameMode(GameMode.CREATIVE); player.sendMessage("Break blocks from as far away as you can possibly get from them."); break; case 3:
|
||||||
player.getInventory().setItemInHand(new ItemStack(Material.DIRT, 64));
|
* player.sendMessage("Place blocks from as far away as you can possibly get from them."); break;
|
||||||
player.sendMessage("Drop items as fast as possible.");
|
*/
|
||||||
/*case 0:
|
}
|
||||||
sendStep();
|
|
||||||
player.sendMessage("Spam the left mouse button as fast as possible.");
|
}
|
||||||
break;
|
|
||||||
case 2:
|
private int getLongCount() {
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
int fill = 0;
|
||||||
player.sendMessage("Break blocks from as far away as you can possibly get from them.");
|
for (long l : longs) {
|
||||||
break;
|
if (l != 0) {
|
||||||
case 3:
|
fill++;
|
||||||
player.sendMessage("Place blocks from as far away as you can possibly get from them.");
|
}
|
||||||
break;*/
|
}
|
||||||
}
|
return fill;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
private int getDoubleCount() {
|
||||||
private int getLongCount()
|
int fill = 0;
|
||||||
{
|
for (double d : doubles) {
|
||||||
int fill = 0;
|
if (d != 0) {
|
||||||
for(long l : longs)
|
fill++;
|
||||||
{
|
}
|
||||||
if(l != 0)
|
}
|
||||||
{
|
return fill;
|
||||||
fill++;
|
}
|
||||||
}
|
|
||||||
}
|
private void clear() {
|
||||||
return fill;
|
for (int i = 0; i < longs.length; i++) {
|
||||||
}
|
longs[i] = 0;
|
||||||
|
}
|
||||||
private int getDoubleCount()
|
for (int i = 0; i < ints.length; i++) {
|
||||||
{
|
ints[i] = 0;
|
||||||
int fill = 0;
|
}
|
||||||
for(double d : doubles)
|
for (int i = 0; i < doubles.length; i++) {
|
||||||
{
|
doubles[i] = 0;
|
||||||
if(d != 0)
|
}
|
||||||
{
|
lastInt = 0;
|
||||||
fill++;
|
lastDouble = 0;
|
||||||
}
|
lastLong = 0;
|
||||||
}
|
times = 0;
|
||||||
return fill;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clear()
|
private void sendStep() {
|
||||||
{
|
step++;
|
||||||
for(int i =0;i<longs.length;i++)
|
player.sendMessage(ChatColor.GREEN + "Step " + step + "/" + TOTAL);
|
||||||
{
|
}
|
||||||
longs[i] = 0;
|
|
||||||
}
|
// Find the average time it takes to do a task
|
||||||
for(int i =0;i<ints.length;i++)
|
private long getAvgLong() {
|
||||||
{
|
int count = getLongCount();
|
||||||
ints[i] = 0;
|
if (count < 10) {
|
||||||
}
|
if (lastLong == 0) {
|
||||||
for(int i =0;i<doubles.length;i++)
|
lastLong = System.currentTimeMillis();
|
||||||
{
|
} else {
|
||||||
doubles[i] = 0;
|
longs[count] = System.currentTimeMillis() - lastLong;
|
||||||
}
|
lastLong = System.currentTimeMillis();
|
||||||
lastInt = 0;
|
}
|
||||||
lastDouble = 0;
|
} else {
|
||||||
lastLong = 0;
|
long avg = 0;
|
||||||
times = 0;
|
for (long l : longs) {
|
||||||
|
avg += l;
|
||||||
}
|
}
|
||||||
|
clear();
|
||||||
private void sendStep()
|
avg /= 10;
|
||||||
{
|
player.sendMessage(ChatColor.AQUA + "Done. Average calculated at " + ChatColor.WHITE + avg);
|
||||||
step++;
|
sendStep();
|
||||||
player.sendMessage(ChatColor.GREEN+"Step "+step+"/"+TOTAL);
|
calibrate();
|
||||||
}
|
return avg;
|
||||||
|
}
|
||||||
// Find the average time it takes to do a task
|
return -1;
|
||||||
private long getAvgLong()
|
}
|
||||||
{
|
|
||||||
int count = getLongCount();
|
// Find the maximum time it takes to do a task
|
||||||
if(count < 10)
|
private double getMaxDouble(double length) {
|
||||||
{
|
int count = getDoubleCount();
|
||||||
if(lastLong == 0)
|
if (count < 10) {
|
||||||
{
|
doubles[count] = length;
|
||||||
lastLong = System.currentTimeMillis();
|
} else {
|
||||||
}
|
double max = 0;
|
||||||
else
|
for (double d : doubles) {
|
||||||
{
|
if (max == 0 || d > max) {
|
||||||
longs[count] = System.currentTimeMillis()-lastLong;
|
max = d;
|
||||||
lastLong = System.currentTimeMillis();
|
}
|
||||||
}
|
}
|
||||||
}
|
clear();
|
||||||
else
|
player.sendMessage(ChatColor.AQUA + "Done. Maximum calculated at " + ChatColor.WHITE + max);
|
||||||
{
|
sendStep();
|
||||||
long avg = 0;
|
calibrate();
|
||||||
for(long l : longs)
|
return max;
|
||||||
{
|
}
|
||||||
avg+=l;
|
return -1;
|
||||||
}
|
}
|
||||||
clear();
|
|
||||||
avg/=10;
|
// Get the absolute time it takes to do something X times
|
||||||
player.sendMessage(ChatColor.AQUA+"Done. Average calculated at "+ChatColor.WHITE+avg);
|
private long getAbsoluteLong() {
|
||||||
sendStep();
|
int count = getLongCount();
|
||||||
calibrate();
|
if (count < 10) {
|
||||||
return avg;
|
if (lastLong == 0) {
|
||||||
}
|
lastLong = System.currentTimeMillis();
|
||||||
return -1;
|
} else {
|
||||||
}
|
longs[count] = System.currentTimeMillis();
|
||||||
|
lastLong = System.currentTimeMillis();
|
||||||
// Find the maximum time it takes to do a task
|
}
|
||||||
private double getMaxDouble(double length)
|
} else {
|
||||||
{
|
long val = longs[9] - longs[0];
|
||||||
int count = getDoubleCount();
|
clear();
|
||||||
if(count < 10)
|
player.sendMessage(ChatColor.AQUA + "Done. Value calculated at " + ChatColor.WHITE + val);
|
||||||
{
|
sendStep();
|
||||||
doubles[count] = length;
|
calibrate();
|
||||||
}
|
return val;
|
||||||
else
|
}
|
||||||
{
|
return -1;
|
||||||
double max = 0;
|
}
|
||||||
for(double d : doubles)
|
|
||||||
{
|
|
||||||
if(max == 0 || d > max)
|
// Begin event listeners
|
||||||
{
|
|
||||||
max = d;
|
@EventHandler
|
||||||
}
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
}
|
if (event.getPlayer() == player) {
|
||||||
clear();
|
if (step == 2) {
|
||||||
player.sendMessage(ChatColor.AQUA+"Done. Maximum calculated at "+ChatColor.WHITE+max);
|
long v = getAbsoluteLong();
|
||||||
sendStep();
|
if (v != -1) {
|
||||||
calibrate();
|
dropItemTime = v;
|
||||||
return max;
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the absolute time it takes to do something X times
|
@EventHandler
|
||||||
private long getAbsoluteLong()
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||||
{
|
if (event.getEntity() instanceof Player && ((Player) event.getEntity()) == player) {
|
||||||
int count = getLongCount();
|
if (step == 1) {
|
||||||
if(count < 10)
|
long v = getAbsoluteLong();
|
||||||
{
|
if (v != -1) {
|
||||||
if(lastLong == 0)
|
projectileTime = v;
|
||||||
{
|
}
|
||||||
lastLong = System.currentTimeMillis();
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
longs[count] = System.currentTimeMillis();
|
@EventHandler
|
||||||
lastLong = System.currentTimeMillis();
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
}
|
if (event.getPlayer() == player) {
|
||||||
}
|
if (step == -1) {
|
||||||
else
|
long v = getAvgLong();
|
||||||
{
|
if (v != -1) {
|
||||||
long val = longs[9]-longs[0];
|
punchAvg = v;
|
||||||
clear();
|
}
|
||||||
player.sendMessage(ChatColor.AQUA+"Done. Value calculated at "+ChatColor.WHITE+val);
|
} else if (step == 1) {
|
||||||
sendStep();
|
|
||||||
calibrate();
|
}
|
||||||
return val;
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
|
||||||
}
|
@EventHandler
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (event.getPlayer() == player) {
|
||||||
|
if (step == -1) {
|
||||||
// Begin event listeners
|
double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
|
||||||
|
double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
|
||||||
@EventHandler
|
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
if (v != -1) {
|
||||||
{
|
blockBreakMax = v;
|
||||||
if(event.getPlayer() == player)
|
}
|
||||||
{
|
}
|
||||||
if(step == 2)
|
}
|
||||||
{
|
}
|
||||||
long v = getAbsoluteLong();
|
|
||||||
if(v != -1)
|
@EventHandler
|
||||||
{
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
dropItemTime = v;
|
if (event.getPlayer() == player) {
|
||||||
}
|
if (step == -1) {
|
||||||
}
|
double lengthX = Math.abs(event.getBlock().getX() - event.getPlayer().getLocation().getX());
|
||||||
}
|
double lengthZ = Math.abs(event.getBlock().getZ() - event.getPlayer().getLocation().getZ());
|
||||||
}
|
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
||||||
|
if (v != -1) {
|
||||||
@EventHandler
|
blockPlaceMax = v;
|
||||||
public void onEntityShootBow(EntityShootBowEvent event)
|
}
|
||||||
{
|
}
|
||||||
if(event.getEntity() instanceof Player && ((Player)event.getEntity()) == player)
|
}
|
||||||
{
|
}
|
||||||
if(step == 1)
|
|
||||||
{
|
|
||||||
long v = getAbsoluteLong();
|
|
||||||
if(v != -1)
|
|
||||||
{
|
|
||||||
projectileTime = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
if(event.getPlayer() == player)
|
|
||||||
{
|
|
||||||
if(step == -1)
|
|
||||||
{
|
|
||||||
long v = getAvgLong();
|
|
||||||
if(v != -1)
|
|
||||||
{
|
|
||||||
punchAvg = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(step == 1)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
|
||||||
{
|
|
||||||
if(event.getPlayer() == player)
|
|
||||||
{
|
|
||||||
if(step == -1)
|
|
||||||
{
|
|
||||||
double lengthX = Math.abs(event.getBlock().getX()-event.getPlayer().getLocation().getX());
|
|
||||||
double lengthZ = Math.abs(event.getBlock().getZ()-event.getPlayer().getLocation().getZ());
|
|
||||||
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
|
||||||
if(v != -1)
|
|
||||||
{
|
|
||||||
blockBreakMax = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
|
||||||
{
|
|
||||||
if(event.getPlayer() == player)
|
|
||||||
{
|
|
||||||
if(step == -1)
|
|
||||||
{
|
|
||||||
double lengthX = Math.abs(event.getBlock().getX()-event.getPlayer().getLocation().getX());
|
|
||||||
double lengthZ = Math.abs(event.getBlock().getZ()-event.getPlayer().getLocation().getZ());
|
|
||||||
double v = getMaxDouble(lengthX >= lengthZ ? lengthX : lengthZ);
|
|
||||||
if(v != -1)
|
|
||||||
{
|
|
||||||
blockPlaceMax = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -31,337 +31,272 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class Configuration
|
public class Configuration {
|
||||||
{
|
private AnticheatManager micromanage = null;
|
||||||
private AnticheatManager micromanage = null;
|
private File configFile = null;
|
||||||
private File configFile = null;
|
private File levelFile = null;
|
||||||
private File levelFile = null;
|
private File langFile = null;
|
||||||
private File langFile = null;
|
private File magicFile = null;
|
||||||
private File magicFile = null;
|
private CommentedConfiguration config;
|
||||||
private CommentedConfiguration config;
|
private FileConfiguration level;
|
||||||
private FileConfiguration level;
|
private FileConfiguration magic;
|
||||||
private FileConfiguration magic;
|
private boolean logConsole;
|
||||||
private boolean logConsole;
|
private boolean logXRay;
|
||||||
private boolean logXRay;
|
private boolean alertXRay;
|
||||||
private boolean alertXRay;
|
private boolean autoUpdate;
|
||||||
private boolean autoUpdate;
|
private boolean verboseStartup;
|
||||||
private boolean verboseStartup;
|
private boolean chatSpam;
|
||||||
private boolean chatSpam;
|
private boolean commandSpam;
|
||||||
private boolean commandSpam;
|
private boolean silentMode;
|
||||||
private boolean silentMode;
|
private boolean opExempt;
|
||||||
private boolean opExempt;
|
private boolean trackCreativeXRay;
|
||||||
private boolean trackCreativeXRay;
|
private int fileLogLevel = 0;
|
||||||
private int fileLogLevel = 0;
|
private int medThreshold = 0;
|
||||||
private int medThreshold = 0;
|
private int highThreshold = 0;
|
||||||
private int highThreshold = 0;
|
private String updateFolder;
|
||||||
private String updateFolder;
|
private String eventMed;
|
||||||
private String eventMed;
|
private String eventHigh;
|
||||||
private String eventHigh;
|
private String chatActionKick;
|
||||||
private String chatActionKick;
|
private String chatActionBan;
|
||||||
private String chatActionBan;
|
private static Language language;
|
||||||
private static Language language;
|
private List<String> exemptWorlds = new ArrayList<String>();
|
||||||
private List<String> exemptWorlds = new ArrayList<String>();
|
|
||||||
|
public Configuration(AnticheatManager instance) {
|
||||||
public Configuration(AnticheatManager instance)
|
micromanage = instance;
|
||||||
{
|
configFile = new File(micromanage.getPlugin().getDataFolder() + "/config.yml");
|
||||||
micromanage = instance;
|
levelFile = new File(micromanage.getPlugin().getDataFolder() + "/data/level.yml");
|
||||||
configFile = new File(micromanage.getPlugin().getDataFolder() + "/config.yml");
|
langFile = new File(micromanage.getPlugin().getDataFolder() + "/lang.yml");
|
||||||
levelFile = new File(micromanage.getPlugin().getDataFolder() + "/data/level.yml");
|
magicFile = new File(micromanage.getPlugin().getDataFolder() + "/magic.yml");
|
||||||
langFile = new File(micromanage.getPlugin().getDataFolder() + "/lang.yml");
|
load();
|
||||||
magicFile = new File(micromanage.getPlugin().getDataFolder() + "/magic.yml");
|
}
|
||||||
load();
|
|
||||||
}
|
private void save() {
|
||||||
|
try {
|
||||||
private void save()
|
config.save(configFile);
|
||||||
{
|
} catch (IOException ex) {
|
||||||
try
|
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
{
|
}
|
||||||
config.save(configFile);
|
}
|
||||||
}
|
|
||||||
catch (IOException ex)
|
public boolean logConsole() {
|
||||||
{
|
return logConsole;
|
||||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
}
|
||||||
}
|
|
||||||
}
|
public boolean logXRay() {
|
||||||
|
return logXRay;
|
||||||
public boolean logConsole()
|
}
|
||||||
{
|
|
||||||
return logConsole;
|
public boolean alertXRay() {
|
||||||
}
|
return alertXRay;
|
||||||
|
}
|
||||||
public boolean logXRay()
|
|
||||||
{
|
public boolean autoUpdate() {
|
||||||
return logXRay;
|
return autoUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean alertXRay()
|
public boolean verboseStartup() {
|
||||||
{
|
return verboseStartup;
|
||||||
return alertXRay;
|
}
|
||||||
}
|
|
||||||
|
public boolean chatSpam() {
|
||||||
public boolean autoUpdate()
|
return chatSpam;
|
||||||
{
|
}
|
||||||
return autoUpdate;
|
|
||||||
}
|
public boolean commandSpam() {
|
||||||
|
return commandSpam;
|
||||||
public boolean verboseStartup()
|
}
|
||||||
{
|
|
||||||
return verboseStartup;
|
public String updateFolder() {
|
||||||
}
|
return updateFolder;
|
||||||
|
}
|
||||||
public boolean chatSpam()
|
|
||||||
{
|
public boolean silentMode() {
|
||||||
return chatSpam;
|
return silentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean commandSpam()
|
public boolean opExempt() {
|
||||||
{
|
return opExempt;
|
||||||
return commandSpam;
|
}
|
||||||
}
|
|
||||||
|
public boolean trackCreativeXRay() {
|
||||||
public String updateFolder()
|
return trackCreativeXRay;
|
||||||
{
|
}
|
||||||
return updateFolder;
|
|
||||||
}
|
public int medThreshold() {
|
||||||
|
return medThreshold;
|
||||||
public boolean silentMode()
|
}
|
||||||
{
|
|
||||||
return silentMode;
|
public int highThreshold() {
|
||||||
}
|
return highThreshold;
|
||||||
|
}
|
||||||
public boolean opExempt()
|
|
||||||
{
|
public String mediumEvent() {
|
||||||
return opExempt;
|
return eventMed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean trackCreativeXRay()
|
public String highEvent() {
|
||||||
{
|
return eventHigh;
|
||||||
return trackCreativeXRay;
|
}
|
||||||
}
|
|
||||||
|
public String chatActionKick() {
|
||||||
public int medThreshold()
|
return chatActionKick;
|
||||||
{
|
}
|
||||||
return medThreshold;
|
|
||||||
}
|
public String chatActionBan() {
|
||||||
|
return chatActionBan;
|
||||||
public int highThreshold()
|
}
|
||||||
{
|
|
||||||
return highThreshold;
|
public int getFileLogLevel() {
|
||||||
}
|
return fileLogLevel;
|
||||||
|
}
|
||||||
public String mediumEvent()
|
|
||||||
{
|
public Language getLang() {
|
||||||
return eventMed;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String highEvent()
|
public final void load() {
|
||||||
{
|
micromanage.getPlugin().checkConfigs();
|
||||||
return eventHigh;
|
config = CommentedConfiguration.loadConfig(configFile);
|
||||||
}
|
level = YamlConfiguration.loadConfiguration(levelFile);
|
||||||
|
magic = YamlConfiguration.loadConfiguration(magicFile);
|
||||||
public String chatActionKick()
|
language = new Language(YamlConfiguration.loadConfiguration(langFile), langFile);
|
||||||
{
|
updateFolder = Bukkit.getUpdateFolder();
|
||||||
return chatActionKick;
|
|
||||||
}
|
// Begin pulling values from config.
|
||||||
|
logConsole = getBoolean("System.Log to console", false);
|
||||||
public String chatActionBan()
|
logXRay = getBoolean("XRay.Log xray stats", true);
|
||||||
{
|
autoUpdate = getBoolean("System.Auto update", true);
|
||||||
return chatActionBan;
|
verboseStartup = getBoolean("System.Verbose startup", false);
|
||||||
}
|
alertXRay = getBoolean("XRay.Alert when xray is found", false);
|
||||||
|
fileLogLevel = getInt("System.File log level", 1);
|
||||||
public int getFileLogLevel()
|
silentMode = getBoolean("System.Silent mode", false);
|
||||||
{
|
medThreshold = getInt("Events.Medium threshold", 20);
|
||||||
return fileLogLevel;
|
highThreshold = getInt("Events.High threshold", 50);
|
||||||
}
|
opExempt = getBoolean("System.Exempt op", false);
|
||||||
|
trackCreativeXRay = getBoolean("XRay.Track creative", true);
|
||||||
public Language getLang()
|
eventMed = getString("Events.Level Medium", "WARN");
|
||||||
{
|
eventHigh = getString("Events.Level High", "KICK");
|
||||||
return language;
|
chatActionKick = getString("Chat.Kick Action", "KICK");
|
||||||
}
|
chatActionBan = getString("Chat.Ban Action", "BAN");
|
||||||
|
chatSpam = getBoolean("Chat.Block chat spam", true);
|
||||||
public final void load()
|
commandSpam = getBoolean("Chat.Block command spam", false);
|
||||||
{
|
// Cleanup old values
|
||||||
micromanage.getPlugin().checkConfigs();
|
if (config.getString("System.Block command spam") != null) {
|
||||||
config = CommentedConfiguration.loadConfig(configFile);
|
config.set("System.Block command spam", null);
|
||||||
level = YamlConfiguration.loadConfiguration(levelFile);
|
}
|
||||||
magic = YamlConfiguration.loadConfiguration(magicFile);
|
if (config.getString("System.Block chat spam") != null) {
|
||||||
language = new Language(YamlConfiguration.loadConfiguration(langFile), langFile);
|
config.set("System.Block chat spam", null);
|
||||||
updateFolder = Bukkit.getUpdateFolder();
|
}
|
||||||
|
|
||||||
// Begin pulling values from config.
|
// Worlds
|
||||||
logConsole = getBoolean("System.Log to console", false);
|
List<String> list = new ArrayList<String>();
|
||||||
logXRay = getBoolean ("XRay.Log xray stats", true);
|
list.add("example-world");
|
||||||
autoUpdate = getBoolean ("System.Auto update", true);
|
list.add("example-world-2");
|
||||||
verboseStartup = getBoolean ("System.Verbose startup", false);
|
|
||||||
alertXRay = getBoolean("XRay.Alert when xray is found", false);
|
if (config.getList("Enable in") != null) {
|
||||||
fileLogLevel = getInt("System.File log level", 1);
|
List<String> list2 = config.getStringList("Enable in");
|
||||||
silentMode = getBoolean("System.Silent mode", false);
|
List<String> list3 = new ArrayList<String>();
|
||||||
medThreshold = getInt("Events.Medium threshold", 20);
|
for (World world : micromanage.getPlugin().getServer().getWorlds()) {
|
||||||
highThreshold = getInt("Events.High threshold", 50);
|
if (!list2.contains(world.getName())) {
|
||||||
opExempt = getBoolean("System.Exempt op", false);
|
list3.add(world.getName());
|
||||||
trackCreativeXRay = getBoolean("XRay.Track creative", true);
|
}
|
||||||
eventMed = getString("Events.Level Medium", "WARN");
|
}
|
||||||
eventHigh = getString("Events.Level High", "KICK");
|
if (!list3.isEmpty()) {
|
||||||
chatActionKick = getString("Chat.Kick Action", "KICK");
|
list = list3;
|
||||||
chatActionBan = getString("Chat.Ban Action", "BAN");
|
}
|
||||||
chatSpam = getBoolean("Chat.Block chat spam", true);
|
config.set("Enable in", null);
|
||||||
commandSpam = getBoolean("Chat.Block command spam", false);
|
}
|
||||||
// Cleanup old values
|
if (config.getList("Disable in") == null) {
|
||||||
if(config.getString("System.Block command spam") != null)
|
config.set("Disable in", list);
|
||||||
{
|
}
|
||||||
config.set("System.Block command spam", null);
|
|
||||||
}
|
exemptWorlds = config.getStringList("Disable in");
|
||||||
if(config.getString("System.Block chat spam") != null)
|
// End pulling values from config
|
||||||
{
|
save();
|
||||||
config.set("System.Block chat spam", null);
|
}
|
||||||
}
|
|
||||||
|
private boolean getBoolean(String entry, boolean d) {
|
||||||
// Worlds
|
if (config.getString(entry) == null) {
|
||||||
List<String> list = new ArrayList<String>();
|
config.set(entry, d);
|
||||||
list.add("example-world");
|
return d;
|
||||||
list.add("example-world-2");
|
} else {
|
||||||
|
return config.getBoolean(entry);
|
||||||
if (config.getList("Enable in") != null)
|
}
|
||||||
{
|
}
|
||||||
List<String> list2 = config.getStringList("Enable in");
|
|
||||||
List<String> list3 = new ArrayList<String>();
|
private int getInt(String entry, int d) {
|
||||||
for(World world : micromanage.getPlugin().getServer().getWorlds())
|
if (config.getString(entry) == null) {
|
||||||
{
|
config.set(entry, d);
|
||||||
if(!list2.contains(world.getName()))
|
return d;
|
||||||
{
|
} else {
|
||||||
list3.add(world.getName());
|
return config.getInt(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!list3.isEmpty())
|
|
||||||
{
|
private String getString(String entry, String d) {
|
||||||
list = list3;
|
if (config.getString(entry) == null) {
|
||||||
}
|
config.set(entry, d);
|
||||||
config.set("Enable in", null);
|
return d;
|
||||||
}
|
} else {
|
||||||
if (config.getList("Disable in") == null)
|
return config.getString(entry);
|
||||||
{
|
}
|
||||||
config.set("Disable in", list);
|
}
|
||||||
}
|
|
||||||
|
public void setLog(boolean b) {
|
||||||
exemptWorlds = config.getStringList("Disable in");
|
config.set("System.Log to console", b);
|
||||||
// End pulling values from config
|
this.logConsole = b;
|
||||||
save();
|
try {
|
||||||
}
|
config.save(configFile);
|
||||||
|
} catch (IOException ex) {
|
||||||
private boolean getBoolean(String entry, boolean d)
|
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
{
|
}
|
||||||
if (config.getString(entry) == null)
|
}
|
||||||
{
|
|
||||||
config.set(entry, d);
|
public List<String> getWorldsExempt() {
|
||||||
return d;
|
return exemptWorlds;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
public File getConfigFile() {
|
||||||
return config.getBoolean(entry);
|
return configFile;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public File getLevelFile() {
|
||||||
private int getInt(String entry, int d)
|
return levelFile;
|
||||||
{
|
}
|
||||||
if (config.getString(entry) == null)
|
|
||||||
{
|
public FileConfiguration getMagic() {
|
||||||
config.set(entry, d);
|
return magic;
|
||||||
return d;
|
}
|
||||||
}
|
|
||||||
else
|
public boolean checkInWorld(World world) {
|
||||||
{
|
return !exemptWorlds.contains(world.getName());
|
||||||
return config.getInt(entry);
|
}
|
||||||
}
|
|
||||||
}
|
public int getLevel(String player) {
|
||||||
|
int x = -1;
|
||||||
private String getString(String entry, String d)
|
if (level.getString(player) != null) {
|
||||||
{
|
x = level.getInt(player);
|
||||||
if (config.getString(entry) == null)
|
}
|
||||||
{
|
return x;
|
||||||
config.set(entry, d);
|
}
|
||||||
return d;
|
|
||||||
}
|
public void saveLevel(String user, int x) {
|
||||||
else
|
level.set(user, x);
|
||||||
{
|
}
|
||||||
return config.getString(entry);
|
|
||||||
}
|
public void saveLevels() {
|
||||||
}
|
try {
|
||||||
|
level.save(levelFile);
|
||||||
public void setLog(boolean b)
|
} catch (IOException ex) {
|
||||||
{
|
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
config.set("System.Log to console", b);
|
}
|
||||||
this.logConsole = b;
|
}
|
||||||
try
|
|
||||||
{
|
public void saveMagic(FileConfiguration newMagic) {
|
||||||
config.save(configFile);
|
try {
|
||||||
}
|
newMagic.save(magicFile);
|
||||||
catch (IOException ex)
|
} catch (IOException ex) {
|
||||||
{
|
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getWorldsExempt()
|
|
||||||
{
|
|
||||||
return exemptWorlds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getConfigFile()
|
|
||||||
{
|
|
||||||
return configFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public File getLevelFile()
|
|
||||||
{
|
|
||||||
return levelFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileConfiguration getMagic()
|
|
||||||
{
|
|
||||||
return magic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkInWorld(World world)
|
|
||||||
{
|
|
||||||
return !exemptWorlds.contains(world.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel(String player)
|
|
||||||
{
|
|
||||||
int x = -1;
|
|
||||||
if (level.getString(player) != null)
|
|
||||||
{
|
|
||||||
x = level.getInt(player);
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveLevel(String user, int x)
|
|
||||||
{
|
|
||||||
level.set(user, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveLevels()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
level.save(levelFile);
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveMagic(FileConfiguration newMagic)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
newMagic.save(magicFile);
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
Logger.getLogger(Configuration.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -21,13 +21,11 @@ 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)
|
StringBuilder output = new StringBuilder().append(record.getMessage()).append(' ');
|
||||||
{
|
return output.toString();
|
||||||
StringBuilder output = new StringBuilder().append(record.getMessage()).append(' ');
|
}
|
||||||
return output.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -20,38 +20,31 @@ package net.h31ix.anticheat.util;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class Distance
|
public class Distance {
|
||||||
{
|
private final Location l1, l2;
|
||||||
private final Location l1, l2;
|
|
||||||
|
public Distance(Location from, Location to) {
|
||||||
public Distance(Location from, Location to)
|
l1 = to;
|
||||||
{
|
l2 = from;
|
||||||
l1 = to;
|
}
|
||||||
l2 = from;
|
|
||||||
}
|
public double fromY() {
|
||||||
|
return l2.getY();
|
||||||
public double fromY()
|
}
|
||||||
{
|
|
||||||
return l2.getY();
|
public double toY() {
|
||||||
}
|
return l1.getY();
|
||||||
|
}
|
||||||
public double toY()
|
|
||||||
{
|
public double getXDifference() {
|
||||||
return l1.getY();
|
return Math.abs(l1.getX() - l2.getX());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getXDifference()
|
public double getZDifference() {
|
||||||
{
|
return Math.abs(l1.getZ() - l2.getZ());
|
||||||
return Math.abs(l1.getX() - l2.getX());
|
}
|
||||||
}
|
|
||||||
|
public double getYDifference() {
|
||||||
public double getZDifference()
|
return Math.abs(l1.getY() - l2.getY());
|
||||||
{
|
}
|
||||||
return Math.abs(l1.getZ() - l2.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getYDifference()
|
|
||||||
{
|
|
||||||
return Math.abs(l1.getY() - l2.getY());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -24,15 +24,13 @@ 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 LINE_SEP = System.getProperty("line.separator");
|
||||||
private static final String LINE_SEP = System.getProperty("line.separator");
|
|
||||||
|
@Override
|
||||||
@Override
|
public String format(LogRecord record) {
|
||||||
public String format(LogRecord record)
|
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP);
|
||||||
{
|
return output.toString();
|
||||||
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP);
|
}
|
||||||
return output.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -28,135 +28,112 @@ import java.util.logging.Logger;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
public class Language
|
public class Language {
|
||||||
{
|
private static String[] medAlert = null;
|
||||||
private static String[] medAlert = null;
|
private static String[] highAlert = null;
|
||||||
private static String[] highAlert = null;
|
private static String[] warning = null;
|
||||||
private static String[] warning = null;
|
private static String banReason = null;
|
||||||
private static String banReason = null;
|
private static String banBroadcast = null;
|
||||||
private static String banBroadcast = null;
|
private static String kickReason = null;
|
||||||
private static String kickReason = null;
|
private static String kickBroadcast = null;
|
||||||
private static String kickBroadcast = null;
|
private static String chatWarning = null;
|
||||||
private static String chatWarning = null;
|
private static String chatKickBroadcast = null;
|
||||||
private static String chatKickBroadcast = null;
|
private static String chatKickReason = null;
|
||||||
private static String chatKickReason = null;
|
private static String chatBanBroadcast = null;
|
||||||
private static String chatBanBroadcast = null;
|
private static String chatBanReason = null;
|
||||||
private static String chatBanReason = null;
|
|
||||||
|
private static final ChatColor GOLD = ChatColor.GOLD;
|
||||||
private static final ChatColor GOLD = ChatColor.GOLD;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private FileConfiguration file;
|
||||||
private FileConfiguration file;
|
|
||||||
|
public Language(FileConfiguration file, File f) {
|
||||||
public Language(FileConfiguration file, File f)
|
this.file = file;
|
||||||
{
|
String[] temp = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
||||||
this.file = file;
|
medAlert = new String[temp.length + 2];
|
||||||
String [] temp = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
medAlert[0] = GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------";
|
||||||
medAlert = new String [temp.length+2];
|
for (int i = 0; i < temp.length; i++) {
|
||||||
medAlert[0] = GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------";
|
medAlert[i + 1] = GRAY + temp[i];
|
||||||
for(int i=0;i<temp.length;i++)
|
}
|
||||||
{
|
medAlert[medAlert.length - 1] = GOLD + "-----------------------------------------------------";
|
||||||
medAlert[i+1] = GRAY + temp[i];
|
temp = file.getList("alert.high_alert").toArray(new String[file.getList("alert.high_alert").size()]);
|
||||||
}
|
highAlert = new String[temp.length + 2];
|
||||||
medAlert[medAlert.length-1] = GOLD + "-----------------------------------------------------";
|
highAlert[0] = GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------";
|
||||||
temp = file.getList("alert.high_alert").toArray(new String[file.getList("alert.high_alert").size()]);
|
for (int i = 0; i < temp.length; i++) {
|
||||||
highAlert = new String [temp.length+2];
|
highAlert[i + 1] = GRAY + temp[i];
|
||||||
highAlert[0] = GOLD + "----------------------[" + GRAY + "AntiCheat" + GOLD + "]----------------------";
|
}
|
||||||
for(int i=0;i<temp.length;i++)
|
highAlert[highAlert.length - 1] = GOLD + "-----------------------------------------------------";
|
||||||
{
|
|
||||||
highAlert[i+1] = GRAY + temp[i];
|
warning = file.getList("warning.player_warning").toArray(new String[file.getList("warning.player_warning").size()]);
|
||||||
}
|
banReason = getString("ban.ban_reason", "Banned by AntiCheat");
|
||||||
highAlert[highAlert.length-1] = GOLD + "-----------------------------------------------------";
|
banBroadcast = getString("ban.ban_broadcast", "[AntiCheat] &player was banned for hacking.");
|
||||||
|
kickReason = getString("kick.kick_reason", "Kicked by AntiCheat");
|
||||||
warning = file.getList("warning.player_warning").toArray(new String[file.getList("warning.player_warning").size()]);
|
kickBroadcast = getString("kick.kick_broadcast", "[AntiCheat] &player was kicked for hacking.");
|
||||||
banReason = getString("ban.ban_reason", "Banned by AntiCheat");
|
chatWarning = getString("chat.warning", "Stop spamming the server or you will be kicked!");
|
||||||
banBroadcast = getString("ban.ban_broadcast", "[AntiCheat] &player was banned for hacking.");
|
chatKickReason = getString("chat.kick_reason", "Kicked for spamming");
|
||||||
kickReason = getString("kick.kick_reason", "Kicked by AntiCheat");
|
chatBanReason = getString("chat.ban_reason", "Banned for spamming");
|
||||||
kickBroadcast = getString("kick.kick_broadcast", "[AntiCheat] &player was kicked for hacking.");
|
chatKickBroadcast = getString("chat.kick_broadcast", "[AntiCheat] &player was kicked for spamming");
|
||||||
chatWarning = getString("chat.warning", "Stop spamming the server or you will be kicked!");
|
chatBanBroadcast = getString("chat.ban_broadcast", "[AntiCheat] &player was banned for spamming");
|
||||||
chatKickReason = getString("chat.kick_reason", "Kicked for spamming");
|
try {
|
||||||
chatBanReason = getString("chat.ban_reason", "Banned for spamming");
|
file.save(f);
|
||||||
chatKickBroadcast = getString("chat.kick_broadcast", "[AntiCheat] &player was kicked for spamming");
|
} catch (IOException ex) {
|
||||||
chatBanBroadcast = getString("chat.ban_broadcast", "[AntiCheat] &player was banned for spamming");
|
Logger.getLogger(Language.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
try
|
}
|
||||||
{
|
}
|
||||||
file.save(f);
|
|
||||||
}
|
public List<String> getMediumAlert() {
|
||||||
catch (IOException ex)
|
return new ArrayList<String>(Arrays.asList(medAlert));
|
||||||
{
|
}
|
||||||
Logger.getLogger(Language.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
public List<String> getHighAlert() {
|
||||||
}
|
return new ArrayList<String>(Arrays.asList(highAlert));
|
||||||
|
}
|
||||||
public List<String> getMediumAlert()
|
|
||||||
{
|
public List<String> getWarning() {
|
||||||
return new ArrayList<String>(Arrays.asList(medAlert));
|
return new ArrayList<String>(Arrays.asList(warning));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getHighAlert()
|
public String getBanReason() {
|
||||||
{
|
return banReason;
|
||||||
return new ArrayList<String>(Arrays.asList(highAlert));
|
}
|
||||||
}
|
|
||||||
|
public String getBanBroadcast() {
|
||||||
public List<String> getWarning()
|
return banBroadcast;
|
||||||
{
|
}
|
||||||
return new ArrayList<String>(Arrays.asList(warning));
|
|
||||||
}
|
public String getKickReason() {
|
||||||
|
return kickReason;
|
||||||
public String getBanReason()
|
}
|
||||||
{
|
|
||||||
return banReason;
|
public String getKickBroadcast() {
|
||||||
}
|
return kickBroadcast;
|
||||||
|
}
|
||||||
public String getBanBroadcast()
|
|
||||||
{
|
public String getChatKickReason() {
|
||||||
return banBroadcast;
|
return chatKickReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKickReason()
|
public String getChatKickBroadcast() {
|
||||||
{
|
return chatKickBroadcast;
|
||||||
return kickReason;
|
}
|
||||||
}
|
|
||||||
|
public String getChatBanReason() {
|
||||||
public String getKickBroadcast()
|
return chatBanReason;
|
||||||
{
|
}
|
||||||
return kickBroadcast;
|
|
||||||
}
|
public String getChatBanBroadcast() {
|
||||||
|
return chatBanBroadcast;
|
||||||
public String getChatKickReason()
|
}
|
||||||
{
|
|
||||||
return chatKickReason;
|
public String getChatWarning() {
|
||||||
}
|
return chatWarning;
|
||||||
|
}
|
||||||
public String getChatKickBroadcast()
|
|
||||||
{
|
private String getString(String entry, String d) {
|
||||||
return chatKickBroadcast;
|
if (file.getString(entry) == null) {
|
||||||
}
|
file.set(entry, d);
|
||||||
|
return d;
|
||||||
public String getChatBanReason()
|
} else {
|
||||||
{
|
return file.getString(entry);
|
||||||
return chatBanReason;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChatBanBroadcast()
|
|
||||||
{
|
|
||||||
return chatBanBroadcast;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChatWarning()
|
|
||||||
{
|
|
||||||
return chatWarning;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getString(String entry, String d)
|
|
||||||
{
|
|
||||||
if (file.getString(entry) == null)
|
|
||||||
{
|
|
||||||
file.set(entry, d);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return file.getString(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -23,451 +23,431 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
/**
|
/**
|
||||||
* Magic number class. Modifications to values in magic.yml will be accepted here.
|
* Magic number class. Modifications to values in magic.yml will be accepted here.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that although each value is documented, changing it may have unintended side-effects. For instance, setting something to 0 that the plugin then uses as a dividend will result in an error.
|
* Note that although each value is documented, changing it may have unintended side-effects. For instance, setting something to 0 that the plugin then uses as a dividend will result in an error. <br>
|
||||||
* <br>
|
|
||||||
* Also realize that the smaller a value is, the less you should change it; it's probably small for a reason. The larger a value is, the safer it is to probably change it.
|
* Also realize that the smaller a value is, the less you should change it; it's probably small for a reason. The larger a value is, the safer it is to probably change it.
|
||||||
* <p>
|
* <p>
|
||||||
* <b>How to read the value documentation:</b>
|
* <b>How to read the value documentation:</b> <br>
|
||||||
* <br>
|
* First, you will see a description of the value. Then, you will see a type: <br>
|
||||||
* First, you will see a description of the value. Then, you will see a type:
|
* <b>Type SYSTEM:</b> This is a 'long' value, measured in milliseconds, used to compare past and future events with the current system time. Remember, 1000 ms = 1 second. <br>
|
||||||
* <br>
|
* <b>Type INTEGER:</b> This is a regular number. It's typically used as something trivial, such as how many times X event can occur. <br>
|
||||||
* <b>Type SYSTEM:</b> This is a 'long' value, measured in milliseconds, used to compare past and future events with the current system time. Remember, 1000 ms = 1 second.
|
|
||||||
* <br>
|
|
||||||
* <b>Type INTEGER:</b> This is a regular number. It's typically used as something trivial, such as how many times X event can occur.
|
|
||||||
* <br>
|
|
||||||
* <b>Type DOUBLE:</b> This is a number that has a decimal in it. It's typically used to evaluate speed or distance.
|
* <b>Type DOUBLE:</b> This is a number that has a decimal in it. It's typically used to evaluate speed or distance.
|
||||||
* <p>
|
* <p>
|
||||||
* After the type, you may see a recommendation labeled as '+Leniency'. This means 'In order to add leniency to this value, do X'
|
* After the type, you may see a recommendation labeled as '+Leniency'. This means 'In order to add leniency to this value, do X' <br>
|
||||||
* <br>
|
|
||||||
* The suggestion for adding leniency will either be to INCREASE or DECREASE the variable. Doing what it suggests will cause the system to not judge the people being checked so vigorously.
|
* The suggestion for adding leniency will either be to INCREASE or DECREASE the variable. Doing what it suggests will cause the system to not judge the people being checked so vigorously.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Magic
|
public class Magic {
|
||||||
{
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int ENTERED_EXITED_TIME;
|
||||||
public final int ENTERED_EXITED_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of entering/exiting sneak mode; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of entering/exiting sneak mode; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int SNEAK_TIME;
|
||||||
public final int SNEAK_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of teleporting; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of teleporting; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int TELEPORT_TIME;
|
||||||
public final int TELEPORT_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of exiting fly mode; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of exiting fly mode; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int EXIT_FLY_TIME;
|
||||||
public final int EXIT_FLY_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of joining the server; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of joining the server; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int JOIN_TIME;
|
||||||
public final int JOIN_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from fastbreak check because of using instant break; Type=seconds, +Leniency=Increase.
|
||||||
* Time to exempt a player from fastbreak check because of using instant break; Type=seconds, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int INSTANT_BREAK_TIME;
|
||||||
public final int INSTANT_BREAK_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of taking damage; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of taking damage; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final long DAMAGE_TIME;
|
||||||
public final long DAMAGE_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of taking damage with knockback effects; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of taking damage with knockback effects; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final long KNOCKBACK_DAMAGE_TIME;
|
||||||
public final long KNOCKBACK_DAMAGE_TIME;
|
/**
|
||||||
/**
|
* Time to exempt a player from moving because of taking damage from an explosion; Type=system, +Leniency=Increase.
|
||||||
* Time to exempt a player from moving because of taking damage from an explosion; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final long EXPLOSION_DAMAGE_TIME;
|
||||||
public final long EXPLOSION_DAMAGE_TIME;
|
/**
|
||||||
/**
|
* Minimum time it takes to fire X projectiles; Type=system, +Leniency=Decrease.
|
||||||
* Minimum time it takes to fire X projectiles; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final int PROJECTILE_TIME_MIN;
|
||||||
public final int PROJECTILE_TIME_MIN;
|
/**
|
||||||
/**
|
* Number of projectiles to wait for before checking how long they took to fire off; Type=integer.
|
||||||
* Number of projectiles to wait for before checking how long they took to fire off; Type=integer.
|
*/
|
||||||
*/
|
public final int PROJECTILE_CHECK;
|
||||||
public final int PROJECTILE_CHECK;
|
/**
|
||||||
/**
|
* Minimum time it takes to drop X items; Type=system, +Leniency=Decrease.
|
||||||
* Minimum time it takes to drop X items; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final int DROP_TIME_MIN;
|
||||||
public final int DROP_TIME_MIN;
|
/**
|
||||||
/**
|
* Number of item drops to wait for before checking how long they took to drop; Type=integer.
|
||||||
* Number of item drops to wait for before checking how long they took to drop; Type=integer.
|
*/
|
||||||
*/
|
public final int DROP_CHECK;
|
||||||
public final int DROP_CHECK;
|
/**
|
||||||
/**
|
* Max number of blocks that can be broken in a given time; Type=integer, +Leniency=Increase.
|
||||||
* Max number of blocks that can be broken in a given time; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTBREAK_LIMIT;
|
||||||
public final int FASTBREAK_LIMIT;
|
/**
|
||||||
/**
|
* Time to wait before checking block breaks; Type=system, +Leniency=Increase.
|
||||||
* Time to wait before checking block breaks; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTBREAK_TIMEMAX;
|
||||||
public final int FASTBREAK_TIMEMAX;
|
/**
|
||||||
/**
|
* Time to wait before checking block breaks in creative mode; Type=system, +Leniency=Increase.
|
||||||
* Time to wait before checking block breaks in creative mode; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTBREAK_TIMEMAX_CREATIVE;
|
||||||
public final int FASTBREAK_TIMEMAX_CREATIVE;
|
/**
|
||||||
/**
|
* Number of times fastbreak can be observed before taking action; Type=integer, +Leniency=Increase.
|
||||||
* Number of times fastbreak can be observed before taking action; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTBREAK_MAXVIOLATIONS;
|
||||||
public final int FASTBREAK_MAXVIOLATIONS;
|
/**
|
||||||
/**
|
* Number of times fastbreak can be observed before taking action in creative mode; Type=integer, +Leniency=Increase.
|
||||||
* Number of times fastbreak can be observed before taking action in creative mode; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTBREAK_MAXVIOLATIONS_CREATIVE;
|
||||||
public final int FASTBREAK_MAXVIOLATIONS_CREATIVE;
|
/**
|
||||||
/**
|
* Time a player is forced to wait after fastbreak has been detected; Type=system, +Leniency=Decrease.
|
||||||
* Time a player is forced to wait after fastbreak has been detected; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final int FASTBREAK_MAXVIOLATIONTIME;
|
||||||
public final int FASTBREAK_MAXVIOLATIONTIME;
|
/**
|
||||||
/**
|
* Number of blocks that can be broken without being hit before taking action; Type=integer, +Leniency=Increase.
|
||||||
* Number of blocks that can be broken without being hit before taking action; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTPLACE_ZEROLIMIT;
|
||||||
public final int FASTPLACE_ZEROLIMIT;
|
/**
|
||||||
/**
|
* Time to wait before checking block places; Type=system, +Leniency=Increase.
|
||||||
* Time to wait before checking block places; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTPLACE_TIMEMAX;
|
||||||
public final int FASTPLACE_TIMEMAX;
|
/**
|
||||||
/**
|
* Number of times fastplace can be observed before taking action; Type=integer, +Leniency=Increase.
|
||||||
* Number of times fastplace can be observed before taking action; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTPLACE_MAXVIOLATIONS;
|
||||||
public final int FASTPLACE_MAXVIOLATIONS;
|
/**
|
||||||
/**
|
* Number of times fastplace can be observed before taking action in creative mode; Type=integer, +Leniency=Increase.
|
||||||
* Number of times fastplace can be observed before taking action in creative mode; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FASTPLACE_MAXVIOLATIONS_CREATIVE;
|
||||||
public final int FASTPLACE_MAXVIOLATIONS_CREATIVE;
|
/**
|
||||||
/**
|
* Time a player is forced to wait after fastplace has been detected; Type=system, +Leniency=Decrease.
|
||||||
* Time a player is forced to wait after fastplace has been detected; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final int FASTPLACE_MAXVIOLATIONTIME;
|
||||||
public final int FASTPLACE_MAXVIOLATIONTIME;
|
/**
|
||||||
/**
|
* Number of times required to punch a block before it breaks; Type=integer, +Leniency=Decrease.
|
||||||
* Number of times required to punch a block before it breaks; Type=integer, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final int BLOCK_PUNCH_MIN;
|
||||||
public final int BLOCK_PUNCH_MIN;
|
/**
|
||||||
/**
|
* Number of chat spam violations before a player is warned; Type=integer, +Leniency=Increase.
|
||||||
* Number of chat spam violations before a player is warned; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int CHAT_WARN_LEVEL;
|
||||||
public final int CHAT_WARN_LEVEL;
|
/**
|
||||||
/**
|
* Number of chat spam violations before a player is kicked; Type=integer, +Leniency=Increase.
|
||||||
* Number of chat spam violations before a player is kicked; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int CHAT_KICK_LEVEL;
|
||||||
public final int CHAT_KICK_LEVEL;
|
/**
|
||||||
/**
|
* Number of kicks for chat violation before a player is banned; Type=integer, +Leniency=Increase.
|
||||||
* Number of kicks for chat violation before a player is banned; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int CHAT_BAN_LEVEL;
|
||||||
public final int CHAT_BAN_LEVEL;
|
/**
|
||||||
/**
|
* Number of times a player can be caught in-flight before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can be caught in-flight before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int FLIGHT_LIMIT;
|
||||||
public final int FLIGHT_LIMIT;
|
/**
|
||||||
/**
|
* How many blocks you can travel before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* How many blocks you can travel before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double FLIGHT_BLOCK_LIMIT;
|
||||||
public final double FLIGHT_BLOCK_LIMIT;
|
/**
|
||||||
/**
|
* Maximum speed that a player can climb a waterfall; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed that a player can climb a waterfall; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double WATER_CLIMB_MAX;
|
||||||
public final double WATER_CLIMB_MAX;
|
/**
|
||||||
/**
|
* Number of times a player can fly on the y-axis before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can fly on the y-axis before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int Y_MAXVIOLATIONS;
|
||||||
public final int Y_MAXVIOLATIONS;
|
/**
|
||||||
/**
|
* Time a player is forced to wait after flying on the y-axis; Type=system, +Leniency=Decrease.
|
||||||
* Time a player is forced to wait after flying on the y-axis; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final int Y_MAXVIOTIME;
|
||||||
public final int Y_MAXVIOTIME;
|
/**
|
||||||
/**
|
* Number of times a player can fail a velocity check before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can fail a velocity check before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int VELOCITY_TIME;
|
||||||
public final int VELOCITY_TIME;
|
/**
|
||||||
/**
|
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=integer.
|
||||||
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=integer.
|
*/
|
||||||
*/
|
public final long VELOCITY_SCHETIME;
|
||||||
public final long VELOCITY_SCHETIME;
|
/**
|
||||||
/**
|
* Maximum time a player is considered to have a change in velocity; Type=system, +Leniency=Increase.
|
||||||
* Maximum time a player is considered to have a change in velocity; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final long VELOCITY_CHECKTIME;
|
||||||
public final long VELOCITY_CHECKTIME;
|
/**
|
||||||
/**
|
* Time to extend a player's velocity count by; Type=system, +Leniency=Increase.
|
||||||
* Time to extend a player's velocity count by; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final long VELOCITY_PREVENT;
|
||||||
public final long VELOCITY_PREVENT;
|
/**
|
||||||
/**
|
* Number of times a player can fail the velocity check before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can fail the velocity check before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int VELOCITY_MAXTIMES;
|
||||||
public final int VELOCITY_MAXTIMES;
|
/**
|
||||||
/**
|
* Number of times a player can fail the nofall check before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can fail the nofall check before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int NOFALL_LIMIT;
|
||||||
public final int NOFALL_LIMIT;
|
/**
|
||||||
/**
|
* Number of times a player can fail the ascension check before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can fail the ascension check before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int ASCENSION_COUNT_MAX;
|
||||||
public final int ASCENSION_COUNT_MAX;
|
/**
|
||||||
/**
|
* Number of times a player can fail the ascension check while in water before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can fail the ascension check while in water before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int WATER_ASCENSION_VIOLATION_MAX;
|
||||||
public final int WATER_ASCENSION_VIOLATION_MAX;
|
/**
|
||||||
/**
|
* Number of times a player can be caught speeding in water before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can be caught speeding in water before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int WATER_SPEED_VIOLATION_MAX;
|
||||||
public final int WATER_SPEED_VIOLATION_MAX;
|
/**
|
||||||
/**
|
* Number of times a player can sprint without proper food level before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Number of times a player can sprint without proper food level before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int SPRINT_FOOD_MIN;
|
||||||
public final int SPRINT_FOOD_MIN;
|
/**
|
||||||
/**
|
* Minimum time between animations; Type=system, +Leniency=Increase.
|
||||||
* Minimum time between animations; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int ANIMATION_MIN;
|
||||||
public final int ANIMATION_MIN;
|
/**
|
||||||
/**
|
* Minimum time between chats; Type=system, +Leniency=Increase.
|
||||||
* Minimum time between chats; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int CHAT_MIN;
|
||||||
public final int CHAT_MIN;
|
/**
|
||||||
/**
|
* Minimum time between repeating yourself in the chat; Type=system, +Leniency=Increase.
|
||||||
* Minimum time between repeating yourself in the chat; Type=system, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int CHAT_REPEAT_MIN;
|
||||||
public final int CHAT_REPEAT_MIN;
|
/**
|
||||||
/**
|
* Maximum speed you can travel while sprinting; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed you can travel while sprinting; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double SPRINT_MIN;
|
||||||
public final double SPRINT_MIN;
|
/**
|
||||||
/**
|
* Minimum time in between block breaks; Type=seconds, +Leniency=Decrease.
|
||||||
* Minimum time in between block breaks; Type=seconds, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final double BLOCK_BREAK_MIN;
|
||||||
public final double BLOCK_BREAK_MIN;
|
/**
|
||||||
/**
|
* Minimum time in between block placing; Type=seconds, +Leniency=Decrease.
|
||||||
* Minimum time in between block placing; Type=seconds, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final double BLOCK_PLACE_MIN;
|
||||||
public final double BLOCK_PLACE_MIN;
|
/**
|
||||||
/**
|
* Minimum time in between healing; Type=system, +Leniency=Decrease.
|
||||||
* Minimum time in between healing; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final long HEAL_TIME_MIN;
|
||||||
public final long HEAL_TIME_MIN;
|
/**
|
||||||
/**
|
* Minimum time in between eating; Type=system, +Leniency=Decrease.
|
||||||
* Minimum time in between eating; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final long EAT_TIME_MIN;
|
||||||
public final long EAT_TIME_MIN;
|
/**
|
||||||
/**
|
* Maximum percent error between predicted bow force and actual bow force; Type=double, +Leniency=Increase.
|
||||||
* Maximum percent error between predicted bow force and actual bow force; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double BOW_ERROR;
|
||||||
public final double BOW_ERROR;
|
/**
|
||||||
/**
|
* Minimum distance a player can break a block from; Type=double, +Leniency=Increase.
|
||||||
* Minimum distance a player can break a block from; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double BLOCK_MAX_DISTANCE;
|
||||||
public final double BLOCK_MAX_DISTANCE;
|
/**
|
||||||
/**
|
* Minimum distance a player can damage an entity from; Type=double, +Leniency=Increase.
|
||||||
* Minimum distance a player can damage an entity from; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double ENTITY_MAX_DISTANCE;
|
||||||
public final double ENTITY_MAX_DISTANCE;
|
/**
|
||||||
/**
|
* Maximum speed a player on a ladder can travel; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player on a ladder can travel; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double LADDER_Y_MAX;
|
||||||
public final double LADDER_Y_MAX;
|
/**
|
||||||
/**
|
* Minimum speed a player on a ladder can travel; Type=double, +Leniency=Decrease.
|
||||||
* Minimum speed a player on a ladder can travel; Type=double, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final double LADDER_Y_MIN;
|
||||||
public final double LADDER_Y_MIN;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel up; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel up; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double Y_SPEED_MAX;
|
||||||
public final double Y_SPEED_MAX;
|
/**
|
||||||
/**
|
* Maximum difference between the player's last 2 Y values when traveling up; Type=double, +Leniency=Increase.
|
||||||
* Maximum difference between the player's last 2 Y values when traveling up; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double Y_MAXDIFF;
|
||||||
public final double Y_MAXDIFF;
|
/**
|
||||||
/**
|
* Time in between Y difference measures; Type=system, +Leniency=Decrease.
|
||||||
* Time in between Y difference measures; Type=system, +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final long Y_TIME;
|
||||||
public final long Y_TIME;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX;
|
||||||
public final double XZ_SPEED_MAX;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards while sprinting; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards while sprinting; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_SPRINT;
|
||||||
public final double XZ_SPEED_MAX_SPRINT;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards while flying; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards while flying; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_FLY;
|
||||||
public final double XZ_SPEED_MAX_FLY;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards while under the influence; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards while under the influence; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_POTION;
|
||||||
public final double XZ_SPEED_MAX_POTION;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards while sneaking; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards while sneaking; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_SNEAK;
|
||||||
public final double XZ_SPEED_MAX_SNEAK;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards in water; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards in water; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_WATER;
|
||||||
public final double XZ_SPEED_MAX_WATER;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards in water while sprinting; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards in water while sprinting; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_WATER_SPRINT;
|
||||||
public final double XZ_SPEED_MAX_WATER_SPRINT;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards on soul sand; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards on soul sand; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_SOULSAND;
|
||||||
public final double XZ_SPEED_MAX_SOULSAND;
|
/**
|
||||||
/**
|
* Maximum speed a player can travel forwards or backwards on soul sand while sprinting; Type=double, +Leniency=Increase.
|
||||||
* Maximum speed a player can travel forwards or backwards on soul sand while sprinting; Type=double, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final double XZ_SPEED_MAX_SOULSAND_SPRINT;
|
||||||
public final double XZ_SPEED_MAX_SOULSAND_SPRINT;
|
/**
|
||||||
/**
|
* Maximum times a player can fail the speed check before action is taken; Type=integer, +Leniency=Increase.
|
||||||
* Maximum times a player can fail the speed check before action is taken; Type=integer, +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int SPEED_MAX;
|
||||||
public final int SPEED_MAX;
|
/**
|
||||||
/**
|
* The number of clicks we should wait before checking if the player has used fast inventory; Type=integer; +Leniency=Increase.
|
||||||
* The number of clicks we should wait before checking if the player has used fast inventory; Type=integer; +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int INVENTORY_CHECK;
|
||||||
public final int INVENTORY_CHECK;
|
/**
|
||||||
/**
|
* The minimum time it should have taken for the player to click X times; Type=integer; +Leniency=Increase.
|
||||||
* The minimum time it should have taken for the player to click X times; Type=integer; +Leniency=Increase.
|
*/
|
||||||
*/
|
public final long INVENTORY_TIMEMIN;
|
||||||
public final long INVENTORY_TIMEMIN;
|
/**
|
||||||
/**
|
* The number of steps we should wait before checking if the player has used timer cheating; Type=integer; +Leniency=Increase.
|
||||||
* The number of steps we should wait before checking if the player has used timer cheating; Type=integer; +Leniency=Increase.
|
*/
|
||||||
*/
|
public final int TIMER_STEP_CHECK;
|
||||||
public final int TIMER_STEP_CHECK;
|
/**
|
||||||
/**
|
* The minimum time it should have taken for the player to travel X steps; Type=system; +Leniency=Decrease.
|
||||||
* The minimum time it should have taken for the player to travel X steps; Type=system; +Leniency=Decrease.
|
*/
|
||||||
*/
|
public final long TIMER_TIMEMIN;
|
||||||
public final long TIMER_TIMEMIN;
|
|
||||||
|
private FileConfiguration defaults;
|
||||||
private FileConfiguration defaults;
|
private FileConfiguration magic;
|
||||||
private FileConfiguration magic;
|
private Configuration config;
|
||||||
private Configuration config;
|
|
||||||
|
public Magic(FileConfiguration magic, Configuration config, FileConfiguration defaults) {
|
||||||
public Magic(FileConfiguration magic, Configuration config, FileConfiguration defaults)
|
this.magic = magic;
|
||||||
{
|
this.config = config;
|
||||||
this.magic = magic;
|
this.defaults = defaults;
|
||||||
this.config = config;
|
|
||||||
this.defaults = defaults;
|
//
|
||||||
|
|
||||||
//
|
ENTERED_EXITED_TIME = getInt("ENTERED_EXITED_TIME");
|
||||||
|
SNEAK_TIME = getInt("SNEAK_TIME");
|
||||||
ENTERED_EXITED_TIME = getInt("ENTERED_EXITED_TIME");
|
TELEPORT_TIME = getInt("TELEPORT_TIME");
|
||||||
SNEAK_TIME = getInt("SNEAK_TIME");
|
EXIT_FLY_TIME = getInt("EXIT_FLY_TIME");
|
||||||
TELEPORT_TIME = getInt("TELEPORT_TIME");
|
JOIN_TIME = getInt("JOIN_TIME");
|
||||||
EXIT_FLY_TIME = getInt("EXIT_FLY_TIME");
|
INSTANT_BREAK_TIME = getInt("INSTANT_BREAK_TIME");
|
||||||
JOIN_TIME = getInt("JOIN_TIME");
|
DAMAGE_TIME = getLong("DAMAGE_TIME");
|
||||||
INSTANT_BREAK_TIME = getInt("INSTANT_BREAK_TIME");
|
KNOCKBACK_DAMAGE_TIME = getLong("KNOCKBACK_DAMAGE_TIME");
|
||||||
DAMAGE_TIME = getLong("DAMAGE_TIME");
|
EXPLOSION_DAMAGE_TIME = getLong("EXPLOSION_DAMAGE_TIME");
|
||||||
KNOCKBACK_DAMAGE_TIME = getLong("KNOCKBACK_DAMAGE_TIME");
|
PROJECTILE_TIME_MIN = getInt("PROJECTILE_TIME_MIN");
|
||||||
EXPLOSION_DAMAGE_TIME = getLong("EXPLOSION_DAMAGE_TIME");
|
PROJECTILE_CHECK = getInt("PROJECTILE_CHECK");
|
||||||
PROJECTILE_TIME_MIN = getInt("PROJECTILE_TIME_MIN");
|
DROP_TIME_MIN = getInt("DROP_TIME_MIN");
|
||||||
PROJECTILE_CHECK = getInt("PROJECTILE_CHECK");
|
DROP_CHECK = getInt("DROP_CHECK");
|
||||||
DROP_TIME_MIN = getInt("DROP_TIME_MIN");
|
FASTBREAK_LIMIT = getInt("FASTBREAK_LIMIT");
|
||||||
DROP_CHECK = getInt("DROP_CHECK");
|
FASTBREAK_TIMEMAX = getInt("FASTBREAK_TIMEMAX");
|
||||||
FASTBREAK_LIMIT = getInt("FASTBREAK_LIMIT");
|
FASTBREAK_TIMEMAX_CREATIVE = getInt("FASTBREAK_TIMEMAX_CREATIVE");
|
||||||
FASTBREAK_TIMEMAX = getInt("FASTBREAK_TIMEMAX");
|
FASTBREAK_MAXVIOLATIONS = getInt("FASTBREAK_MAXVIOLATIONS");
|
||||||
FASTBREAK_TIMEMAX_CREATIVE = getInt("FASTBREAK_TIMEMAX_CREATIVE");
|
FASTBREAK_MAXVIOLATIONS_CREATIVE = getInt("FASTBREAK_MAXVIOLATIONS_CREATIVE");
|
||||||
FASTBREAK_MAXVIOLATIONS = getInt("FASTBREAK_MAXVIOLATIONS");
|
FASTBREAK_MAXVIOLATIONTIME = getInt("FASTBREAK_MAXVIOLATIONTIME");
|
||||||
FASTBREAK_MAXVIOLATIONS_CREATIVE = getInt("FASTBREAK_MAXVIOLATIONS_CREATIVE");
|
FASTPLACE_ZEROLIMIT = getInt("FASTPLACE_ZEROLIMIT");
|
||||||
FASTBREAK_MAXVIOLATIONTIME = getInt("FASTBREAK_MAXVIOLATIONTIME");
|
FASTPLACE_TIMEMAX = getInt("FASTPLACE_TIMEMAX");
|
||||||
FASTPLACE_ZEROLIMIT = getInt("FASTPLACE_ZEROLIMIT");
|
FASTPLACE_MAXVIOLATIONS = getInt("FASTPLACE_MAXVIOLATIONS");
|
||||||
FASTPLACE_TIMEMAX = getInt("FASTPLACE_TIMEMAX");
|
FASTPLACE_MAXVIOLATIONS_CREATIVE = getInt("FASTPLACE_MAXVIOLATIONS_CREATIVE");
|
||||||
FASTPLACE_MAXVIOLATIONS = getInt("FASTPLACE_MAXVIOLATIONS");
|
FASTPLACE_MAXVIOLATIONTIME = getInt("FASTPLACE_MAXVIOLATIONTIME");
|
||||||
FASTPLACE_MAXVIOLATIONS_CREATIVE = getInt("FASTPLACE_MAXVIOLATIONS_CREATIVE");
|
BLOCK_PUNCH_MIN = getInt("BLOCK_PUNCH_MIN");
|
||||||
FASTPLACE_MAXVIOLATIONTIME = getInt("FASTPLACE_MAXVIOLATIONTIME");
|
CHAT_WARN_LEVEL = getInt("CHAT_WARN_LEVEL");
|
||||||
BLOCK_PUNCH_MIN = getInt("BLOCK_PUNCH_MIN");
|
CHAT_KICK_LEVEL = getInt("CHAT_KICK_LEVEL");
|
||||||
CHAT_WARN_LEVEL = getInt("CHAT_WARN_LEVEL");
|
CHAT_BAN_LEVEL = getInt("CHAT_BAN_LEVEL");
|
||||||
CHAT_KICK_LEVEL = getInt("CHAT_KICK_LEVEL");
|
FLIGHT_LIMIT = getInt("FLIGHT_LIMIT");
|
||||||
CHAT_BAN_LEVEL = getInt("CHAT_BAN_LEVEL");
|
FLIGHT_BLOCK_LIMIT = getDouble("FLIGHT_BLOCK_LIMIT");
|
||||||
FLIGHT_LIMIT = getInt("FLIGHT_LIMIT");
|
WATER_CLIMB_MAX = getDouble("WATER_CLIMB_MAX");
|
||||||
FLIGHT_BLOCK_LIMIT = getDouble("FLIGHT_BLOCK_LIMIT");
|
Y_MAXVIOLATIONS = getInt("Y_MAXVIOLATIONS");
|
||||||
WATER_CLIMB_MAX = getDouble("WATER_CLIMB_MAX");
|
Y_MAXVIOTIME = getInt("Y_MAXVIOTIME");
|
||||||
Y_MAXVIOLATIONS = getInt("Y_MAXVIOLATIONS");
|
VELOCITY_TIME = getInt("VELOCITY_TIME");
|
||||||
Y_MAXVIOTIME = getInt("Y_MAXVIOTIME");
|
VELOCITY_SCHETIME = getLong("VELOCITY_SCHETIME");
|
||||||
VELOCITY_TIME = getInt("VELOCITY_TIME");
|
VELOCITY_CHECKTIME = getLong("VELOCITY_CHECKTIME");
|
||||||
VELOCITY_SCHETIME = getLong("VELOCITY_SCHETIME");
|
VELOCITY_PREVENT = getLong("VELOCITY_PREVENT");
|
||||||
VELOCITY_CHECKTIME = getLong("VELOCITY_CHECKTIME");
|
VELOCITY_MAXTIMES = getInt("VELOCITY_MAXTIMES");
|
||||||
VELOCITY_PREVENT = getLong("VELOCITY_PREVENT");
|
NOFALL_LIMIT = getInt("NOFALL_LIMIT");
|
||||||
VELOCITY_MAXTIMES = getInt("VELOCITY_MAXTIMES");
|
ASCENSION_COUNT_MAX = getInt("ASCENSION_COUNT_MAX");
|
||||||
NOFALL_LIMIT = getInt("NOFALL_LIMIT");
|
WATER_ASCENSION_VIOLATION_MAX = getInt("WATER_ASCENSION_VIOLATION_MAX");
|
||||||
ASCENSION_COUNT_MAX = getInt("ASCENSION_COUNT_MAX");
|
WATER_SPEED_VIOLATION_MAX = getInt("WATER_SPEED_VIOLATION_MAX");
|
||||||
WATER_ASCENSION_VIOLATION_MAX = getInt("WATER_ASCENSION_VIOLATION_MAX");
|
SPRINT_FOOD_MIN = getInt("SPRINT_FOOD_MIN");
|
||||||
WATER_SPEED_VIOLATION_MAX = getInt("WATER_SPEED_VIOLATION_MAX");
|
ANIMATION_MIN = getInt("ANIMATION_MIN");
|
||||||
SPRINT_FOOD_MIN = getInt("SPRINT_FOOD_MIN");
|
CHAT_MIN = getInt("CHAT_MIN");
|
||||||
ANIMATION_MIN = getInt("ANIMATION_MIN");
|
CHAT_REPEAT_MIN = getInt("CHAT_REPEAT_MIN");
|
||||||
CHAT_MIN = getInt("CHAT_MIN");
|
SPRINT_MIN = getDouble("SPRINT_MIN");
|
||||||
CHAT_REPEAT_MIN = getInt("CHAT_REPEAT_MIN");
|
BLOCK_BREAK_MIN = getDouble("BLOCK_BREAK_MIN");
|
||||||
SPRINT_MIN = getDouble("SPRINT_MIN");
|
BLOCK_PLACE_MIN = getDouble("BLOCK_PLACE_MIN");
|
||||||
BLOCK_BREAK_MIN = getDouble("BLOCK_BREAK_MIN");
|
HEAL_TIME_MIN = getLong("HEAL_TIME_MIN");
|
||||||
BLOCK_PLACE_MIN = getDouble("BLOCK_PLACE_MIN");
|
EAT_TIME_MIN = getLong("EAT_TIME_MIN");
|
||||||
HEAL_TIME_MIN = getLong("HEAL_TIME_MIN");
|
BOW_ERROR = getDouble("BOW_ERROR");
|
||||||
EAT_TIME_MIN = getLong("EAT_TIME_MIN");
|
BLOCK_MAX_DISTANCE = getDouble("BLOCK_MAX_DISTANCE");
|
||||||
BOW_ERROR = getDouble("BOW_ERROR");
|
ENTITY_MAX_DISTANCE = getDouble("ENTITY_MAX_DISTANCE");
|
||||||
BLOCK_MAX_DISTANCE = getDouble("BLOCK_MAX_DISTANCE");
|
LADDER_Y_MAX = getDouble("LADDER_Y_MAX");
|
||||||
ENTITY_MAX_DISTANCE = getDouble("ENTITY_MAX_DISTANCE");
|
LADDER_Y_MIN = getDouble("LADDER_Y_MIN");
|
||||||
LADDER_Y_MAX = getDouble("LADDER_Y_MAX");
|
Y_SPEED_MAX = getDouble("Y_SPEED_MAX");
|
||||||
LADDER_Y_MIN = getDouble("LADDER_Y_MIN");
|
Y_MAXDIFF = getDouble("Y_MAXDIFF");
|
||||||
Y_SPEED_MAX = getDouble("Y_SPEED_MAX");
|
Y_TIME = getLong("Y_TIME");
|
||||||
Y_MAXDIFF = getDouble("Y_MAXDIFF");
|
XZ_SPEED_MAX = getDouble("XZ_SPEED_MAX");
|
||||||
Y_TIME = getLong("Y_TIME");
|
XZ_SPEED_MAX_SPRINT = getDouble("XZ_SPEED_MAX_SPRINT");
|
||||||
XZ_SPEED_MAX = getDouble("XZ_SPEED_MAX");
|
XZ_SPEED_MAX_FLY = getDouble("XZ_SPEED_MAX_FLY");
|
||||||
XZ_SPEED_MAX_SPRINT = getDouble("XZ_SPEED_MAX_SPRINT");
|
XZ_SPEED_MAX_POTION = getDouble("XZ_SPEED_MAX_POTION");
|
||||||
XZ_SPEED_MAX_FLY = getDouble("XZ_SPEED_MAX_FLY");
|
XZ_SPEED_MAX_SNEAK = getDouble("XZ_SPEED_MAX_SNEAK");
|
||||||
XZ_SPEED_MAX_POTION = getDouble("XZ_SPEED_MAX_POTION");
|
XZ_SPEED_MAX_WATER = getDouble("XZ_SPEED_MAX_WATER");
|
||||||
XZ_SPEED_MAX_SNEAK = getDouble("XZ_SPEED_MAX_SNEAK");
|
XZ_SPEED_MAX_SOULSAND = getDouble("XZ_SPEED_MAX_SOULSAND");
|
||||||
XZ_SPEED_MAX_WATER = getDouble("XZ_SPEED_MAX_WATER");
|
XZ_SPEED_MAX_SOULSAND_SPRINT = getDouble("XZ_SPEED_MAX_SOULSAND_SPRINT");
|
||||||
XZ_SPEED_MAX_SOULSAND = getDouble("XZ_SPEED_MAX_SOULSAND");
|
XZ_SPEED_MAX_WATER_SPRINT = getDouble("XZ_SPEED_MAX_WATER_SPRINT");
|
||||||
XZ_SPEED_MAX_SOULSAND_SPRINT = getDouble("XZ_SPEED_MAX_SOULSAND_SPRINT");
|
SPEED_MAX = getInt("SPEED_MAX");
|
||||||
XZ_SPEED_MAX_WATER_SPRINT = getDouble("XZ_SPEED_MAX_WATER_SPRINT");
|
INVENTORY_CHECK = getInt("INVENTORY_CHECK");
|
||||||
SPEED_MAX = getInt("SPEED_MAX");
|
INVENTORY_TIMEMIN = getInt("INVENTORY_TIMEMIN");
|
||||||
INVENTORY_CHECK = getInt("INVENTORY_CHECK");
|
TIMER_STEP_CHECK = getInt("TIMER_STEP_CHECK");
|
||||||
INVENTORY_TIMEMIN = getInt("INVENTORY_TIMEMIN");
|
TIMER_TIMEMIN = getLong("TIMER_TIMEMIN");
|
||||||
TIMER_STEP_CHECK = getInt("TIMER_STEP_CHECK");
|
}
|
||||||
TIMER_TIMEMIN = getLong("TIMER_TIMEMIN");
|
|
||||||
}
|
private int getInt(String path) {
|
||||||
|
if (magic.contains(path)) {
|
||||||
private int getInt(String path)
|
return magic.getInt(path);
|
||||||
{
|
} else {
|
||||||
if(magic.contains(path))
|
int i = defaults.getInt(path);
|
||||||
{
|
magic.set(path, i);
|
||||||
return magic.getInt(path);
|
config.saveMagic(magic);
|
||||||
}
|
return i;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
int i = defaults.getInt(path);
|
|
||||||
magic.set(path, i);
|
private double getDouble(String path) {
|
||||||
config.saveMagic(magic);
|
if (magic.contains(path)) {
|
||||||
return i;
|
return magic.getDouble(path);
|
||||||
}
|
} else {
|
||||||
}
|
double i = defaults.getDouble(path);
|
||||||
|
magic.set(path, i);
|
||||||
private double getDouble(String path)
|
config.saveMagic(magic);
|
||||||
{
|
return i;
|
||||||
if(magic.contains(path))
|
}
|
||||||
{
|
}
|
||||||
return magic.getDouble(path);
|
|
||||||
}
|
private long getLong(String path) {
|
||||||
else
|
if (magic.contains(path)) {
|
||||||
{
|
return magic.getLong(path);
|
||||||
double i = defaults.getDouble(path);
|
} else {
|
||||||
magic.set(path, i);
|
long i = defaults.getLong(path);
|
||||||
config.saveMagic(magic);
|
magic.set(path, i);
|
||||||
return i;
|
config.saveMagic(magic);
|
||||||
}
|
return i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
private long getLong(String path)
|
|
||||||
{
|
|
||||||
if(magic.contains(path))
|
|
||||||
{
|
|
||||||
return magic.getLong(path);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
long i = defaults.getLong(path);
|
|
||||||
magic.set(path, i);
|
|
||||||
config.saveMagic(magic);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -30,145 +30,115 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PastebinReport
|
public class PastebinReport {
|
||||||
{
|
private StringBuilder report = new StringBuilder();
|
||||||
private StringBuilder report = new StringBuilder();
|
private String url = "";
|
||||||
private String url = "";
|
private Date date = new Date();
|
||||||
private Date date = new Date();
|
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd kk:mm Z");
|
||||||
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd kk:mm Z");
|
|
||||||
|
public PastebinReport(CommandSender cs) {
|
||||||
public PastebinReport(CommandSender cs)
|
Player player = null;
|
||||||
{
|
try {
|
||||||
Player player = null;
|
player = (Player) cs;
|
||||||
try
|
} catch (Exception e) {
|
||||||
{
|
cs.sendMessage(ChatColor.RED + "We were unable to detect a player when making this report. Skipping permstester");
|
||||||
player = (Player) cs;
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
createReport(player);
|
||||||
{
|
try {
|
||||||
cs.sendMessage(ChatColor.RED + "We were unable to detect a player when making this report. Skipping permstester");
|
writeReport();
|
||||||
}
|
} catch (IOException e) {}
|
||||||
|
postReport();
|
||||||
createReport(player);
|
}
|
||||||
try
|
|
||||||
{
|
public String getURL() {
|
||||||
writeReport();
|
return url;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
|
||||||
{
|
private void appendPermissionsTester(Player player) {
|
||||||
}
|
if (player == null) { return; }
|
||||||
postReport();
|
|
||||||
}
|
// alrighty then noobs.
|
||||||
|
for (Permission node : Permission.values()) {
|
||||||
public String getURL()
|
report.append(player.getName() + ": " + node.toString() + " " + node.get(player) + '\n');
|
||||||
{
|
}
|
||||||
return url;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void appendPermissionsTester(Player player)
|
private void createReport(Player player) {
|
||||||
{
|
report.append("------------ AntiCheat Report - " + format.format(date) + " ------------" + '\n');
|
||||||
if (player == null)
|
report.append("Version: " + Anticheat.getVersion() + '\n');
|
||||||
{
|
report.append("CraftBukkit: " + Bukkit.getVersion() + '\n');
|
||||||
return;
|
report.append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length + '\n');
|
||||||
}
|
appendSystemInfo();
|
||||||
|
report.append("------------Last 30 logs------------" + '\n');
|
||||||
// alrighty then noobs.
|
for (String log : Anticheat.getManager().getLastLogs()) {
|
||||||
for(Permission node : Permission.values())
|
report.append("[AntiCheat] " + log + '\n');
|
||||||
{
|
}
|
||||||
report.append(player.getName() + ": " + node.toString() + " " + node.get(player) + '\n');
|
report.append("------------Permission Tester------------" + '\n');
|
||||||
}
|
appendPermissionsTester(player);
|
||||||
|
report.append("-----------End Of Report------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createReport(Player player)
|
private void appendSystemInfo() {
|
||||||
{
|
Runtime runtime = Runtime.getRuntime();
|
||||||
report.append("------------ AntiCheat Report - " + format.format(date) + " ------------" + '\n');
|
report.append("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version") + '\n');
|
||||||
report.append("Version: " + Anticheat.getVersion() + '\n');
|
report.append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + '\n');
|
||||||
report.append("CraftBukkit: " + Bukkit.getVersion() + '\n');
|
report.append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB" + '\n');
|
||||||
report.append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length + '\n');
|
report.append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB" + '\n');
|
||||||
appendSystemInfo();
|
report.append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB" + '\n');
|
||||||
report.append("------------Last 30 logs------------" + '\n');
|
report.append("Server ID + Name: " + Bukkit.getServerId() + " - " + Bukkit.getName() + '\n');
|
||||||
for (String log : Anticheat.getManager().getLastLogs())
|
report.append("Players: " + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers() + '\n');
|
||||||
{
|
}
|
||||||
report.append("[AntiCheat] " + log + '\n');
|
|
||||||
}
|
private void writeReport() throws IOException {
|
||||||
report.append("------------Permission Tester------------" + '\n');
|
File f = new File(Anticheat.getPlugin().getDataFolder() + "/report.txt");
|
||||||
appendPermissionsTester(player);
|
FileWriter r = new FileWriter(f);
|
||||||
report.append("-----------End Of Report------------");
|
BufferedWriter writer = new BufferedWriter(r);
|
||||||
}
|
writer.write(report.toString());
|
||||||
|
writer.close();
|
||||||
private void appendSystemInfo()
|
}
|
||||||
{
|
|
||||||
Runtime runtime = Runtime.getRuntime();
|
private void postReport() {
|
||||||
report.append("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version") + '\n');
|
try {
|
||||||
report.append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + '\n');
|
URL urls = new URL("http://pastebin.com/api/api_post.php");
|
||||||
report.append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB" + '\n');
|
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
|
||||||
report.append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB" + '\n');
|
conn.setConnectTimeout(5000);
|
||||||
report.append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB" + '\n');
|
conn.setReadTimeout(5000);
|
||||||
report.append("Server ID + Name: " + Bukkit.getServerId() + " - " + Bukkit.getName() + '\n');
|
conn.setRequestMethod("POST");
|
||||||
report.append("Players: " + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers() + '\n');
|
conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
|
||||||
}
|
conn.setInstanceFollowRedirects(false);
|
||||||
|
conn.setDoOutput(true);
|
||||||
private void writeReport() throws IOException
|
OutputStream out = conn.getOutputStream();
|
||||||
{
|
|
||||||
File f = new File(Anticheat.getPlugin().getDataFolder() + "/report.txt");
|
out.write(("api_option=paste" + "&api_dev_key=" + URLEncoder.encode("c0616def494dcb5b7632304f8c52c0f1", "utf-8") + "&api_paste_code=" + URLEncoder.encode(report.toString(), "utf-8") + "&api_paste_private=" + URLEncoder.encode("1", "utf-8") + "&api_paste_name=" + URLEncoder.encode("", "utf-8") + "&api_paste_expire_date=" + URLEncoder.encode("1M", "utf-8") + "&api_paste_format=" + URLEncoder.encode("text", "utf-8") + "&api_user_key=" + URLEncoder.encode("", "utf-8")).getBytes());
|
||||||
FileWriter r = new FileWriter(f);
|
out.flush();
|
||||||
BufferedWriter writer = new BufferedWriter(r);
|
out.close();
|
||||||
writer.write(report.toString());
|
|
||||||
writer.close();
|
if (conn.getResponseCode() == 200) {
|
||||||
}
|
InputStream receive = conn.getInputStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
|
||||||
private void postReport()
|
String line;
|
||||||
{
|
StringBuffer response = new StringBuffer();
|
||||||
try
|
while ((line = reader.readLine()) != null) {
|
||||||
{
|
response.append(line);
|
||||||
URL urls = new URL("http://pastebin.com/api/api_post.php");
|
response.append("\r\n");
|
||||||
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
|
}
|
||||||
conn.setConnectTimeout(5000);
|
reader.close();
|
||||||
conn.setReadTimeout(5000);
|
|
||||||
conn.setRequestMethod("POST");
|
String result = response.toString().trim();
|
||||||
conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
|
|
||||||
conn.setInstanceFollowRedirects(false);
|
if (!result.contains("http://")) {
|
||||||
conn.setDoOutput(true);
|
url = "Failed to post. Check report.txt";
|
||||||
OutputStream out = conn.getOutputStream();
|
} else {
|
||||||
|
url = result.trim();
|
||||||
out.write(("api_option=paste" + "&api_dev_key=" + URLEncoder.encode("c0616def494dcb5b7632304f8c52c0f1", "utf-8") + "&api_paste_code=" + URLEncoder.encode(report.toString(), "utf-8") + "&api_paste_private=" + URLEncoder.encode("1", "utf-8") + "&api_paste_name=" + URLEncoder.encode("", "utf-8") + "&api_paste_expire_date=" + URLEncoder.encode("1M", "utf-8") + "&api_paste_format=" + URLEncoder.encode("text", "utf-8") + "&api_user_key=" + URLEncoder.encode("", "utf-8")).getBytes());
|
}
|
||||||
out.flush();
|
} else {
|
||||||
out.close();
|
url = "Failed to post. Check report.txt";
|
||||||
|
}
|
||||||
if (conn.getResponseCode() == 200)
|
} catch (Exception e) {
|
||||||
{
|
url = "Failed to post. Check report.txt";
|
||||||
InputStream receive = conn.getInputStream();
|
}
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
|
}
|
||||||
String line;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
while ((line = reader.readLine()) != null)
|
|
||||||
{
|
|
||||||
response.append(line);
|
|
||||||
response.append("\r\n");
|
|
||||||
}
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
String result = response.toString().trim();
|
|
||||||
|
|
||||||
if (!result.contains("http://"))
|
|
||||||
{
|
|
||||||
url = "Failed to post. Check report.txt";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url = result.trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
url = "Failed to post. Check report.txt";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
url = "Failed to post. Check report.txt";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,57 +20,54 @@ package net.h31ix.anticheat.util;
|
|||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public enum Permission
|
public enum Permission {
|
||||||
{
|
/* Check Nodes */
|
||||||
/* Check Nodes */
|
CHECK_ZOMBE_FLY,
|
||||||
CHECK_ZOMBE_FLY,
|
CHECK_ZOMBE_NOCLIP,
|
||||||
CHECK_ZOMBE_NOCLIP,
|
CHECK_ZOMBE_CHEAT,
|
||||||
CHECK_ZOMBE_CHEAT,
|
CHECK_FLY,
|
||||||
CHECK_FLY,
|
CHECK_WATERWALK,
|
||||||
CHECK_WATERWALK,
|
CHECK_NOSWING,
|
||||||
CHECK_NOSWING,
|
CHECK_FASTBREAK,
|
||||||
CHECK_FASTBREAK,
|
CHECK_FASTPLACE,
|
||||||
CHECK_FASTPLACE,
|
CHECK_SPAM,
|
||||||
CHECK_SPAM,
|
CHECK_SPRINT,
|
||||||
CHECK_SPRINT,
|
CHECK_SNEAK,
|
||||||
CHECK_SNEAK,
|
CHECK_SPEED,
|
||||||
CHECK_SPEED,
|
CHECK_VCLIP,
|
||||||
CHECK_VCLIP,
|
CHECK_SPIDER,
|
||||||
CHECK_SPIDER,
|
CHECK_NOFALL,
|
||||||
CHECK_NOFALL,
|
CHECK_FASTBOW,
|
||||||
CHECK_FASTBOW,
|
CHECK_FASTEAT,
|
||||||
CHECK_FASTEAT,
|
CHECK_FASTHEAL,
|
||||||
CHECK_FASTHEAL,
|
CHECK_FORCEFIELD,
|
||||||
CHECK_FORCEFIELD,
|
CHECK_XRAY,
|
||||||
CHECK_XRAY,
|
CHECK_LONGREACH,
|
||||||
CHECK_LONGREACH,
|
CHECK_FASTPROJECTILE,
|
||||||
CHECK_FASTPROJECTILE,
|
CHECK_ITEMSPAM,
|
||||||
CHECK_ITEMSPAM,
|
CHECK_VISUAL,
|
||||||
CHECK_VISUAL,
|
CHECK_FASTINVENTORY,
|
||||||
CHECK_FASTINVENTORY,
|
CHECK_AUTOTOOL,
|
||||||
CHECK_AUTOTOOL,
|
|
||||||
|
/* System Nodes */
|
||||||
/* System Nodes */
|
SYSTEM_LOG,
|
||||||
SYSTEM_LOG,
|
SYSTEM_XRAY,
|
||||||
SYSTEM_XRAY,
|
SYSTEM_RESET,
|
||||||
SYSTEM_RESET,
|
SYSTEM_SPY,
|
||||||
SYSTEM_SPY,
|
SYSTEM_HELP,
|
||||||
SYSTEM_HELP,
|
SYSTEM_UPDATE,
|
||||||
SYSTEM_UPDATE,
|
SYSTEM_REPORT,
|
||||||
SYSTEM_REPORT,
|
SYSTEM_ALERT,
|
||||||
SYSTEM_ALERT,
|
SYSTEM_CALIBRATE,
|
||||||
SYSTEM_CALIBRATE,
|
SYSTEM_RELOAD;
|
||||||
SYSTEM_RELOAD;
|
|
||||||
|
public boolean get(CommandSender cs) {
|
||||||
public boolean get(CommandSender cs)
|
return cs.hasPermission(toString());
|
||||||
{
|
}
|
||||||
return cs.hasPermission(toString());
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
@Override
|
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
||||||
public String toString()
|
}
|
||||||
{
|
|
||||||
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,31 +20,26 @@ package net.h31ix.anticheat.util;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class SpyState
|
public class SpyState {
|
||||||
{
|
private boolean allowFlight;
|
||||||
private boolean allowFlight;
|
private boolean flying;
|
||||||
private boolean flying;
|
private Location location;
|
||||||
private Location location;
|
|
||||||
|
public SpyState(boolean allowFlight, boolean flying, Location location) {
|
||||||
public SpyState(boolean allowFlight, boolean flying, Location location)
|
this.allowFlight = allowFlight;
|
||||||
{
|
this.flying = flying;
|
||||||
this.allowFlight = allowFlight;
|
this.location = location;
|
||||||
this.flying = flying;
|
}
|
||||||
this.location = location;
|
|
||||||
}
|
public boolean getAllowFlight() {
|
||||||
|
return this.allowFlight;
|
||||||
public boolean getAllowFlight()
|
}
|
||||||
{
|
|
||||||
return this.allowFlight;
|
public boolean getFlying() {
|
||||||
}
|
return this.flying;
|
||||||
|
}
|
||||||
public boolean getFlying()
|
|
||||||
{
|
public Location getLocation() {
|
||||||
return this.flying;
|
return this.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLocation()
|
|
||||||
{
|
|
||||||
return this.location;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,34 +2,27 @@ package net.h31ix.anticheat.util;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public enum ToolHardness
|
public enum ToolHardness {
|
||||||
{
|
|
||||||
|
// NOTHING(null, 1.5)
|
||||||
//NOTHING(null, 1.5)
|
WOOD(0.75D),
|
||||||
WOOD(0.75D),
|
STONE(0.40D),
|
||||||
STONE(0.40D),
|
IRON(0.25D),
|
||||||
IRON(0.25D),
|
DIAMOND(0.20D),
|
||||||
DIAMOND(0.20D),
|
SHEARS(0.55D),
|
||||||
SHEARS(0.55D),
|
GOLD(0.15D);
|
||||||
GOLD(0.15D);
|
|
||||||
|
double hardness;
|
||||||
double hardness;
|
|
||||||
|
ToolHardness(double hard) {
|
||||||
ToolHardness(double hard)
|
hardness = hard;
|
||||||
{
|
}
|
||||||
hardness = hard;
|
|
||||||
}
|
public static double getToolHardness(Material tool) {
|
||||||
|
for (ToolHardness e : ToolHardness.values()) {
|
||||||
public static double getToolHardness(Material tool)
|
if (tool.name().contains(e.name())) { return e.hardness; }
|
||||||
{
|
}
|
||||||
for (ToolHardness e : ToolHardness.values())
|
|
||||||
{
|
return 1.50D;
|
||||||
if (tool.name().contains(e.name()))
|
}
|
||||||
{
|
|
||||||
return e.hardness;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1.50D;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -31,248 +31,205 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.util.NumberConversions;
|
import org.bukkit.util.NumberConversions;
|
||||||
|
|
||||||
public final class Utilities
|
public final class Utilities {
|
||||||
{
|
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
||||||
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
private static final List<Material> INTERACTABLE = new ArrayList<Material>();
|
||||||
private static final List<Material> INTERACTABLE = new ArrayList<Material>();
|
private static final List<Material> AXES = new ArrayList<Material>();
|
||||||
private static final List<Material> AXES = new ArrayList<Material>();
|
private static final List<Material> PICKAXES = new ArrayList<Material>();
|
||||||
private static final List<Material> PICKAXES = new ArrayList<Material>();
|
private static final List<Material> SHEARS = new ArrayList<Material>();
|
||||||
private static final List<Material> SHEARS = new ArrayList<Material>();
|
private static final List<Material> SHOVELS = new ArrayList<Material>();
|
||||||
private static final List<Material> SHOVELS = new ArrayList<Material>();
|
private static final List<Material> ANY = new ArrayList<Material>();
|
||||||
private static final List<Material> ANY = new ArrayList<Material>();
|
|
||||||
|
public static void alert(List<String> message) {
|
||||||
public static void alert(List<String> message)
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
{
|
if (Permission.SYSTEM_ALERT.get(player)) {
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (String msg : message) {
|
||||||
{
|
player.sendMessage(msg);
|
||||||
if (Permission.SYSTEM_ALERT.get(player))
|
}
|
||||||
{
|
}
|
||||||
for (String msg : message)
|
}
|
||||||
{
|
if (Anticheat.getManager().getConfiguration().logConsole()) {
|
||||||
player.sendMessage(msg);
|
for (String msg : message) {
|
||||||
}
|
Anticheat.getManager().log(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Anticheat.getManager().getConfiguration().logConsole())
|
if (Anticheat.getManager().getConfiguration().getFileLogLevel() != 0) {
|
||||||
{
|
for (String msg : message) {
|
||||||
for (String msg : message)
|
Anticheat.getManager().log(msg, 1);
|
||||||
{
|
}
|
||||||
Anticheat.getManager().log(msg);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() != 0)
|
public static boolean cantStandAt(Block block) {
|
||||||
{
|
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
||||||
for (String msg : message)
|
}
|
||||||
{
|
|
||||||
Anticheat.getManager().log(msg, 1);
|
public static boolean cantStandAtExp(Location block) {
|
||||||
}
|
// This is a experimental check for checking whether you can't stand at or whatever.
|
||||||
}
|
Block nblock = new Location(block.getWorld(), fixXAxis(block.getX()), block.getY() - 0.01D, block.getBlockZ()).getBlock();
|
||||||
}
|
return cantStandAt(nblock);
|
||||||
|
}
|
||||||
public static boolean cantStandAt(Block block)
|
|
||||||
{
|
public static boolean cantStandClose(Block block) {
|
||||||
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandAtExp(Location 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));
|
||||||
// This is a experimental check for checking whether you can't stand at or whatever.
|
}
|
||||||
Block nblock = new Location(block.getWorld(), fixXAxis(block.getX()), block.getY() - 0.01D, block.getBlockZ()).getBlock();
|
|
||||||
return cantStandAt(nblock);
|
public static boolean canStand(Block block) {
|
||||||
}
|
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||||
|
}
|
||||||
public static boolean cantStandClose(Block block)
|
|
||||||
{
|
public static boolean isFullyInWater(Location player) {
|
||||||
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
double touchedX = fixXAxis(player.getX());
|
||||||
}
|
|
||||||
|
// Yes, this doesn't make sense, but it's supposed to fix some false positives in water walk.
|
||||||
public static boolean cantStandFar(Block block)
|
// Think of it as 2 negatives = a positive :)
|
||||||
{
|
if (!(new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid() && !(new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock()).isLiquid()) { return true; }
|
||||||
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 (new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid() && (new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock()).isLiquid();
|
||||||
|
}
|
||||||
public static boolean canStand(Block block)
|
|
||||||
{
|
public static double fixXAxis(double x) {
|
||||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
/* Really really really useful function for those who are on the edges of blocks */
|
||||||
}
|
/* For Z axis, just use Math.round(xaxis); */
|
||||||
|
double touchedX = x;
|
||||||
public static boolean isFullyInWater(Location player)
|
double rem = touchedX - Math.round(touchedX) + 0.01D;
|
||||||
{
|
if (rem < 0.30D) {
|
||||||
double touchedX = fixXAxis(player.getX());
|
touchedX = NumberConversions.floor(x) - 1;
|
||||||
|
}
|
||||||
// Yes, this doesn't make sense, but it's supposed to fix some false positives in water walk.
|
return touchedX;
|
||||||
// Think of it as 2 negatives = a positive :)
|
}
|
||||||
if(!(new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid() && !(new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock()).isLiquid())
|
|
||||||
{
|
public static boolean isHoveringOverWater(Location player, int blocks) {
|
||||||
return true;
|
for (int i = player.getBlockY(); i > player.getBlockY() - blocks; i--) {
|
||||||
}
|
Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
|
||||||
|
if (newloc.getTypeId() != 0 && newloc.isLiquid())
|
||||||
return (new Location(player.getWorld(), touchedX, player.getY(), player.getBlockZ()).getBlock()).isLiquid() && (new Location(player.getWorld(), touchedX, Math.round(player.getY()), player.getBlockZ()).getBlock()).isLiquid();
|
return true;
|
||||||
}
|
else if (newloc.getTypeId() != 0) return false;
|
||||||
|
}
|
||||||
public static double fixXAxis(double x)
|
|
||||||
{
|
return false;
|
||||||
/* Really really really useful function for those who are on the edges of blocks */
|
}
|
||||||
/* For Z axis, just use Math.round(xaxis); */
|
|
||||||
double touchedX = x;
|
public static boolean isHoveringOverWater(Location player) {
|
||||||
double rem = touchedX - Math.round(touchedX) + 0.01D;
|
return isHoveringOverWater(player, 25);
|
||||||
if (rem < 0.30D)
|
}
|
||||||
{
|
|
||||||
touchedX = NumberConversions.floor(x) - 1;
|
public static boolean isInstantBreak(Material m) {
|
||||||
}
|
return INSTANT_BREAK.contains(m);
|
||||||
return touchedX;
|
}
|
||||||
}
|
|
||||||
|
public static boolean isFood(Material m) {
|
||||||
public static boolean isHoveringOverWater(Location player, int blocks)
|
return FOOD.contains(m);
|
||||||
{
|
}
|
||||||
for(int i = player.getBlockY(); i > player.getBlockY() - blocks; i--)
|
|
||||||
{
|
public static boolean isSlab(Block block) {
|
||||||
Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
|
int id = block.getTypeId();
|
||||||
if(newloc.getTypeId() != 0 && newloc.isLiquid())
|
return id == 43 || id == 44 || id == 125 || id == 126;
|
||||||
return true;
|
}
|
||||||
else if (newloc.getTypeId() != 0)
|
|
||||||
return false;
|
public static boolean isStair(Block block) {
|
||||||
}
|
int id = block.getTypeId();
|
||||||
|
return id == 53 || id == 67 || id == 108 || id == 109 || id == 114 || id == 128 || id == 134 || id == 135 || id == 136;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
public static boolean isInteractable(Material m) {
|
||||||
public static boolean isHoveringOverWater(Location player)
|
return INTERACTABLE.contains(m);
|
||||||
{
|
}
|
||||||
return isHoveringOverWater(player, 25);
|
|
||||||
}
|
public static boolean sprintFly(Player player) {
|
||||||
|
return player.isSprinting() || player.isFlying();
|
||||||
public static boolean isInstantBreak(Material m)
|
}
|
||||||
{
|
|
||||||
return INSTANT_BREAK.contains(m);
|
public static boolean isOnLilyPad(Player player) {
|
||||||
}
|
Block block = player.getLocation().getBlock();
|
||||||
|
Material lily = Material.WATER_LILY;
|
||||||
public static boolean isFood(Material m)
|
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 FOOD.contains(m);
|
|
||||||
}
|
public static boolean isSubmersed(Player player) {
|
||||||
|
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
public static boolean isSlab(Block block)
|
}
|
||||||
{
|
|
||||||
int id = block.getTypeId();
|
public static boolean isInWater(Player player) {
|
||||||
return id == 43 || id == 44 || id == 125 || id == 126;
|
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isStair(Block block)
|
public static boolean isClimbableBlock(Block block) {
|
||||||
{
|
return block.getType() == Material.VINE || block.getType() == Material.LADDER;
|
||||||
int id = block.getTypeId();
|
}
|
||||||
return id == 53 || id == 67 || id == 108 || id == 109 || id == 114 || id == 128 || id == 134 || id == 135 || id == 136;
|
|
||||||
}
|
public static boolean isOnVine(Player player) {
|
||||||
|
return player.getLocation().getBlock().getType() == Material.VINE;
|
||||||
public static boolean isInteractable(Material m)
|
}
|
||||||
{
|
|
||||||
return INTERACTABLE.contains(m);
|
public static boolean isInt(String string) {
|
||||||
}
|
boolean x = false;
|
||||||
|
try {
|
||||||
public static boolean sprintFly(Player player)
|
Integer.parseInt(string);
|
||||||
{
|
x = true;
|
||||||
return player.isSprinting() || player.isFlying();
|
} catch (Exception ex) {}
|
||||||
}
|
return x;
|
||||||
|
}
|
||||||
public static boolean isOnLilyPad(Player player)
|
|
||||||
{
|
public static long calcSurvivalFastBreak(ItemStack tool, Material block) {
|
||||||
Block block = player.getLocation().getBlock();
|
double bhardness = BlockHardness.getBlockHardness(block);
|
||||||
Material lily = Material.WATER_LILY;
|
double thardness = ToolHardness.getToolHardness(tool.getType());
|
||||||
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;
|
|
||||||
}
|
long result = (long) ((long) Math.round((bhardness * thardness) * 0.10 * 10000));
|
||||||
|
result += 150;
|
||||||
public static boolean isSubmersed(Player player)
|
|
||||||
{
|
if (result > 25000)
|
||||||
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
result = 25000;
|
||||||
}
|
else if (result < 0) result = 0;
|
||||||
|
|
||||||
public static boolean isInWater(Player player)
|
return result;
|
||||||
{
|
}
|
||||||
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
|
||||||
}
|
static {
|
||||||
|
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||||
public static boolean isClimbableBlock(Block block)
|
INSTANT_BREAK.add(Material.RED_ROSE);
|
||||||
{
|
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||||
return block.getType() == Material.VINE || block.getType() == Material.LADDER;
|
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
|
||||||
}
|
INSTANT_BREAK.add(Material.REDSTONE);
|
||||||
|
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
|
||||||
public static boolean isOnVine(Player player)
|
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
|
||||||
{
|
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
||||||
return player.getLocation().getBlock().getType() == Material.VINE;
|
INSTANT_BREAK.add(Material.LONG_GRASS);
|
||||||
}
|
INSTANT_BREAK.add(Material.PAINTING);
|
||||||
|
INSTANT_BREAK.add(Material.WHEAT);
|
||||||
public static boolean isInt(String string)
|
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
||||||
{
|
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
|
||||||
boolean x = false;
|
INSTANT_BREAK.add(Material.DIODE);
|
||||||
try
|
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
|
||||||
{
|
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
|
||||||
Integer.parseInt(string);
|
INSTANT_BREAK.add(Material.SAPLING);
|
||||||
x = true;
|
INSTANT_BREAK.add(Material.TORCH);
|
||||||
}
|
INSTANT_BREAK.add(Material.CROPS);
|
||||||
catch (Exception ex)
|
INSTANT_BREAK.add(Material.SNOW);
|
||||||
{
|
INSTANT_BREAK.add(Material.TNT);
|
||||||
}
|
INTERACTABLE.add(Material.STONE_BUTTON);
|
||||||
return x;
|
INTERACTABLE.add(Material.LEVER);
|
||||||
}
|
INTERACTABLE.add(Material.CHEST);
|
||||||
|
FOOD.add(Material.COOKED_BEEF);
|
||||||
public static long calcSurvivalFastBreak(ItemStack tool, Material block)
|
FOOD.add(Material.COOKED_CHICKEN);
|
||||||
{
|
FOOD.add(Material.COOKED_FISH);
|
||||||
double bhardness = BlockHardness.getBlockHardness(block);
|
FOOD.add(Material.GRILLED_PORK);
|
||||||
double thardness = ToolHardness.getToolHardness(tool.getType());
|
FOOD.add(Material.PORK);
|
||||||
|
FOOD.add(Material.MUSHROOM_SOUP);
|
||||||
long result = (long) ((long) Math.round((bhardness * thardness) * 0.10 * 10000));
|
FOOD.add(Material.RAW_BEEF);
|
||||||
result += 150;
|
FOOD.add(Material.RAW_CHICKEN);
|
||||||
|
FOOD.add(Material.RAW_FISH);
|
||||||
if (result > 25000)
|
FOOD.add(Material.APPLE);
|
||||||
result = 25000;
|
FOOD.add(Material.GOLDEN_APPLE);
|
||||||
else if (result < 0)
|
FOOD.add(Material.MELON);
|
||||||
result = 0;
|
FOOD.add(Material.COOKIE);
|
||||||
|
FOOD.add(Material.BREAD);
|
||||||
return result;
|
FOOD.add(Material.SPIDER_EYE);
|
||||||
}
|
FOOD.add(Material.ROTTEN_FLESH);
|
||||||
|
}
|
||||||
static
|
|
||||||
{
|
|
||||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
|
||||||
INSTANT_BREAK.add(Material.RED_ROSE);
|
|
||||||
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
|
||||||
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
|
|
||||||
INSTANT_BREAK.add(Material.REDSTONE);
|
|
||||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
|
|
||||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
|
|
||||||
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
|
||||||
INSTANT_BREAK.add(Material.LONG_GRASS);
|
|
||||||
INSTANT_BREAK.add(Material.PAINTING);
|
|
||||||
INSTANT_BREAK.add(Material.WHEAT);
|
|
||||||
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
|
||||||
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
|
|
||||||
INSTANT_BREAK.add(Material.DIODE);
|
|
||||||
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
|
|
||||||
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
|
|
||||||
INSTANT_BREAK.add(Material.SAPLING);
|
|
||||||
INSTANT_BREAK.add(Material.TORCH);
|
|
||||||
INSTANT_BREAK.add(Material.CROPS);
|
|
||||||
INSTANT_BREAK.add(Material.SNOW);
|
|
||||||
INSTANT_BREAK.add(Material.TNT);
|
|
||||||
INTERACTABLE.add(Material.STONE_BUTTON);
|
|
||||||
INTERACTABLE.add(Material.LEVER);
|
|
||||||
INTERACTABLE.add(Material.CHEST);
|
|
||||||
FOOD.add(Material.COOKED_BEEF);
|
|
||||||
FOOD.add(Material.COOKED_CHICKEN);
|
|
||||||
FOOD.add(Material.COOKED_FISH);
|
|
||||||
FOOD.add(Material.GRILLED_PORK);
|
|
||||||
FOOD.add(Material.PORK);
|
|
||||||
FOOD.add(Material.MUSHROOM_SOUP);
|
|
||||||
FOOD.add(Material.RAW_BEEF);
|
|
||||||
FOOD.add(Material.RAW_CHICKEN);
|
|
||||||
FOOD.add(Material.RAW_FISH);
|
|
||||||
FOOD.add(Material.APPLE);
|
|
||||||
FOOD.add(Material.GOLDEN_APPLE);
|
|
||||||
FOOD.add(Material.MELON);
|
|
||||||
FOOD.add(Material.COOKIE);
|
|
||||||
FOOD.add(Material.BREAD);
|
|
||||||
FOOD.add(Material.SPIDER_EYE);
|
|
||||||
FOOD.add(Material.ROTTEN_FLESH);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -33,115 +33,105 @@ import org.yaml.snakeyaml.DumperOptions;
|
|||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
import org.yaml.snakeyaml.representer.Representer;
|
import org.yaml.snakeyaml.representer.Representer;
|
||||||
|
|
||||||
public class CommentedConfiguration extends YamlConfiguration
|
public class CommentedConfiguration extends YamlConfiguration {
|
||||||
{
|
private Map<String, String> comments = new HashMap<String, String>();
|
||||||
private Map<String, String> comments = new HashMap<String, String>();
|
|
||||||
|
private final DumperOptions yamlOptions = new DumperOptions();
|
||||||
private final DumperOptions yamlOptions = new DumperOptions();
|
private final Representer yamlRepresenter = new YamlRepresenter();
|
||||||
private final Representer yamlRepresenter = new YamlRepresenter();
|
private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
||||||
private final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
private String lastLine = null;
|
||||||
private String lastLine = null;
|
|
||||||
|
public CommentedConfiguration() {
|
||||||
public CommentedConfiguration()
|
// Val 1 = line comment should be under
|
||||||
{
|
// Val 2 = comment
|
||||||
// Val 1 = line comment should be under
|
comments.put("XRay:", " # Should AntiCheat use calculations to try and find xrayers?");
|
||||||
// Val 2 = comment
|
comments.put("Log xray stats:", " # Should a warning be sent to admins when a person is found that could be xraying?");
|
||||||
comments.put("XRay:", " # Should AntiCheat use calculations to try and find xrayers?");
|
comments.put("Alert when xray is found:", " # Should players in creative mode be tracked for possible xray usage?");
|
||||||
comments.put("Log xray stats:", " # Should a warning be sent to admins when a person is found that could be xraying?");
|
comments.put("Chat:", " # Should AntiCheat block players spamming messages in chat?");
|
||||||
comments.put("Alert when xray is found:", " # Should players in creative mode be tracked for possible xray usage?");
|
comments.put("Block chat spam:", " # Should AntiCheat block players spamming commands in chat?");
|
||||||
comments.put("Chat:", " # Should AntiCheat block players spamming messages in chat?");
|
comments.put("Block command spam:", " # Valid actions = NONE,KICK,BAN,COMMAND[command]");
|
||||||
comments.put("Block chat spam:", " # Should AntiCheat block players spamming commands in chat?");
|
comments.put("Ban Action:", "# Events occur when a player's hack level changes. You may configure reactions to these events here.");
|
||||||
comments.put("Block command spam:", " # Valid actions = NONE,KICK,BAN,COMMAND[command]");
|
comments.put("# Events occur when a player's hack level changes. You may configure reactions to these events here.", "# Valid events = NONE,WARN,KICK,BAN,COMMAND[command]");
|
||||||
comments.put("Ban Action:", "# Events occur when a player's hack level changes. You may configure reactions to these events here.");
|
comments.put("# Valid events = NONE,WARN,KICK,BAN,COMMAND[command]", "# Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]");
|
||||||
comments.put("# Events occur when a player's hack level changes. You may configure reactions to these events here.", "# Valid events = NONE,WARN,KICK,BAN,COMMAND[command]");
|
comments.put("# Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]", "# &player will be replaced with player's name, and &world will be replaced with the player's world");
|
||||||
comments.put("# Valid events = NONE,WARN,KICK,BAN,COMMAND[command]", "# Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]");
|
comments.put("Level High:", " # How many warnings should the player get before entering medium?");
|
||||||
comments.put("# Use commands like so: COMMAND[ban &player 30] or COMMAND[kick &player hacking] or COMMAND[jail &player 10]", "# &player will be replaced with player's name, and &world will be replaced with the player's world");
|
comments.put("Medium threshold:", " # How many warnings should the player get before entering high?");
|
||||||
comments.put("Level High:", " # How many warnings should the player get before entering medium?");
|
comments.put("System:", " # Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.");
|
||||||
comments.put("Medium threshold:", " # How many warnings should the player get before entering high?");
|
comments.put("# Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.", " # Should AntiCheat log ALL failed checks to console?");
|
||||||
comments.put("System:", " # Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.");
|
comments.put("Log to console:", " # Should AntiCheat log to files?");
|
||||||
comments.put("# Turning auto-update off is a _BAD_ idea. You will no longer be protected by the latest hacks/cheats if you do so, and will have to update manually.", " # Should AntiCheat log ALL failed checks to console?");
|
comments.put("# Should AntiCheat log to files?", " # 0 = off, 1 = log only when an event takes place, 2 = more detailed logs, 3 = most detailed logs");
|
||||||
comments.put("Log to console:", " # Should AntiCheat log to files?");
|
comments.put("File log level:", " # Should AntiCheat display extra debug information when starting?");
|
||||||
comments.put("# Should AntiCheat log to files?", " # 0 = off, 1 = log only when an event takes place, 2 = more detailed logs, 3 = most detailed logs");
|
comments.put("Verbose startup:", " # If silent mode is on, players will not be stopped when they try to hack, and AntiCheat will do everything possible to keep them unaware of their rising hack level.");
|
||||||
comments.put("File log level:", " # Should AntiCheat display extra debug information when starting?");
|
comments.put("# If silent mode is on, players will not be stopped when they try to hack, and AntiCheat will do everything possible to keep them unaware of their rising hack level.", " # However, alerts will still be sent to console and to admins online, and events will still take place.");
|
||||||
comments.put("Verbose startup:", " # If silent mode is on, players will not be stopped when they try to hack, and AntiCheat will do everything possible to keep them unaware of their rising hack level.");
|
comments.put("Silent mode:", " # Should ops be exempt from all checks?");
|
||||||
comments.put("# If silent mode is on, players will not be stopped when they try to hack, and AntiCheat will do everything possible to keep them unaware of their rising hack level.", " # However, alerts will still be sent to console and to admins online, and events will still take place.");
|
}
|
||||||
comments.put("Silent mode:", " # Should ops be exempt from all checks?");
|
|
||||||
}
|
@Override
|
||||||
|
public String saveToString() {
|
||||||
@Override
|
yamlOptions.setIndent(options().indent());
|
||||||
public String saveToString() {
|
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
yamlOptions.setIndent(options().indent());
|
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
|
||||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
String dump = yaml.dump(getValues(false));
|
||||||
|
|
||||||
String dump = yaml.dump(getValues(false));
|
if (dump.equals(BLANK_CONFIG)) {
|
||||||
|
dump = "";
|
||||||
if (dump.equals(BLANK_CONFIG)) {
|
} else {
|
||||||
dump = "";
|
StringBuilder builder = new StringBuilder();
|
||||||
} else {
|
String[] lines = dump.split("\n");
|
||||||
StringBuilder builder = new StringBuilder();
|
int i = 0;
|
||||||
String [] lines = dump.split("\n");
|
|
||||||
int i =0;
|
while (i < lines.length) {
|
||||||
|
if (containsLine(lines[i])) {
|
||||||
while(i < lines.length) {
|
builder.append(lines[i]);
|
||||||
if(containsLine(lines[i])) {
|
builder.append("\n");
|
||||||
builder.append(lines[i]);
|
builder.append(getComment(lines[i]));
|
||||||
builder.append("\n");
|
builder.append("\n");
|
||||||
builder.append(getComment(lines[i]));
|
lastLine = getComment(getComment(lines[i]));
|
||||||
builder.append("\n");
|
i++;
|
||||||
lastLine = getComment(getComment(lines[i]));
|
} else if (containsLine(lastLine)) {
|
||||||
i++;
|
builder.append(getComment(lastLine));
|
||||||
} else if(containsLine(lastLine)) {
|
builder.append("\n");
|
||||||
builder.append(getComment(lastLine));
|
lastLine = getComment(lastLine);
|
||||||
builder.append("\n");
|
} else {
|
||||||
lastLine = getComment(lastLine);
|
builder.append(lines[i]);
|
||||||
} else {
|
builder.append("\n");
|
||||||
builder.append(lines[i]);
|
i++;
|
||||||
builder.append("\n");
|
}
|
||||||
i++;
|
}
|
||||||
}
|
dump = "# AntiCheat configuration file\n# Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/\n" + builder.toString();
|
||||||
}
|
}
|
||||||
dump = "# AntiCheat configuration file\n# Please report any bugs: http://dev.bukkit.org/server-mods/anticheat/\n"+builder.toString();
|
|
||||||
}
|
return dump;
|
||||||
|
}
|
||||||
return dump;
|
|
||||||
}
|
private boolean containsLine(String line) {
|
||||||
|
if (line != null) {
|
||||||
private boolean containsLine(String line)
|
for (String string : comments.keySet()) {
|
||||||
{
|
if (string.replaceAll(" ", "").split(":")[0].equalsIgnoreCase(line.replaceAll(" ", "").split(":")[0])) { return true; }
|
||||||
if(line != null)
|
}
|
||||||
{
|
}
|
||||||
for(String string : comments.keySet()) {
|
return false;
|
||||||
if(string.replaceAll(" ", "").split(":")[0].equalsIgnoreCase(line.replaceAll(" ", "").split(":")[0])) {
|
}
|
||||||
return true;
|
|
||||||
}
|
private String getComment(String line) {
|
||||||
}
|
for (String string : comments.keySet()) {
|
||||||
}
|
if (string.replaceAll(" ", "").split(":")[0].equalsIgnoreCase(line.replaceAll(" ", "").split(":")[0])) { return comments.get(string); }
|
||||||
return false;
|
}
|
||||||
}
|
return null;
|
||||||
|
}
|
||||||
private String getComment(String line)
|
|
||||||
{
|
public static CommentedConfiguration loadConfig(File file) {
|
||||||
for(String string : comments.keySet()) {
|
|
||||||
if(string.replaceAll(" ", "").split(":")[0].equalsIgnoreCase(line.replaceAll(" ", "").split(":")[0])) {
|
CommentedConfiguration config = new CommentedConfiguration();
|
||||||
return comments.get(string);
|
try {
|
||||||
}
|
config.load(file);
|
||||||
}
|
} catch (FileNotFoundException ex) {} catch (IOException ex) {
|
||||||
return null;
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||||
}
|
} catch (InvalidConfigurationException ex) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||||
public static CommentedConfiguration loadConfig(File file) {
|
}
|
||||||
|
|
||||||
CommentedConfiguration config = new CommentedConfiguration();
|
return config;
|
||||||
try {
|
}
|
||||||
config.load(file);
|
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
|
||||||
} catch (InvalidConfigurationException ex) {
|
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file , ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -29,56 +29,36 @@ 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();
|
|
||||||
|
@EventHandler
|
||||||
@EventHandler
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
if (config.logXRay()) {
|
||||||
{
|
Player p = event.getPlayer();
|
||||||
if (config.logXRay())
|
if (p.getGameMode() == GameMode.CREATIVE && !config.trackCreativeXRay()) { return; }
|
||||||
{
|
String player = p.getName();
|
||||||
Player p = event.getPlayer();
|
if (checkManager.willCheck(p, CheckType.XRAY)) {
|
||||||
if(p.getGameMode() == GameMode.CREATIVE && !config.trackCreativeXRay())
|
Material m = event.getBlock().getType();
|
||||||
{
|
if (m == Material.DIAMOND_ORE) {
|
||||||
return;
|
tracker.addDiamond(player);
|
||||||
}
|
} else if (m == Material.IRON_ORE) {
|
||||||
String player = p.getName();
|
tracker.addIron(player);
|
||||||
if (checkManager.willCheck(p, CheckType.XRAY))
|
} else if (m == Material.GOLD_ORE) {
|
||||||
{
|
tracker.addGold(player);
|
||||||
Material m = event.getBlock().getType();
|
} else if (m == Material.LAPIS_ORE) {
|
||||||
if (m == Material.DIAMOND_ORE)
|
tracker.addLapis(player);
|
||||||
{
|
} else if (m == Material.REDSTONE_ORE) {
|
||||||
tracker.addDiamond(player);
|
tracker.addRedstone(player);
|
||||||
}
|
} else if (m == Material.GOLD_ORE) {
|
||||||
else if (m == Material.IRON_ORE)
|
tracker.addGold(player);
|
||||||
{
|
} else {
|
||||||
tracker.addIron(player);
|
tracker.addBlock(player);
|
||||||
}
|
}
|
||||||
else if (m == Material.GOLD_ORE)
|
tracker.addTotal(player);
|
||||||
{
|
}
|
||||||
tracker.addGold(player);
|
}
|
||||||
}
|
}
|
||||||
else if (m == Material.LAPIS_ORE)
|
|
||||||
{
|
|
||||||
tracker.addLapis(player);
|
|
||||||
}
|
|
||||||
else if (m == Material.REDSTONE_ORE)
|
|
||||||
{
|
|
||||||
tracker.addRedstone(player);
|
|
||||||
}
|
|
||||||
else if (m == Material.GOLD_ORE)
|
|
||||||
{
|
|
||||||
tracker.addGold(player);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tracker.addBlock(player);
|
|
||||||
}
|
|
||||||
tracker.addTotal(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -20,81 +20,65 @@ 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;
|
private double g = 0;
|
||||||
private double g = 0;
|
private double i = 0;
|
||||||
private double i = 0;
|
private double l = 0;
|
||||||
private double l = 0;
|
private double r = 0;
|
||||||
private double r = 0;
|
private double o = 0;
|
||||||
private double o = 0;
|
|
||||||
|
public XRayStats(String player, Map<String, Integer> diamond, Map<String, Integer> gold, Map<String, Integer> iron, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total) {
|
||||||
public XRayStats(String player, Map<String, Integer> diamond, Map<String, Integer> gold, Map<String, Integer> iron, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total)
|
if (total.get(player) != null) {
|
||||||
{
|
t = total.get(player);
|
||||||
if (total.get(player) != null)
|
}
|
||||||
{
|
if (diamond.get(player) != null) {
|
||||||
t = total.get(player);
|
d = (diamond.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (diamond.get(player) != null)
|
if (gold.get(player) != null) {
|
||||||
{
|
g = (gold.get(player) / t) * DIVISOR;
|
||||||
d = (diamond.get(player) / t) * DIVISOR;
|
}
|
||||||
}
|
if (iron.get(player) != null) {
|
||||||
if (gold.get(player) != null)
|
i = (iron.get(player) / t) * DIVISOR;
|
||||||
{
|
}
|
||||||
g = (gold.get(player) / t) * DIVISOR;
|
if (lapis.get(player) != null) {
|
||||||
}
|
l = (lapis.get(player) / t) * DIVISOR;
|
||||||
if (iron.get(player) != null)
|
}
|
||||||
{
|
if (redstone.get(player) != null) {
|
||||||
i = (iron.get(player) / t) * DIVISOR;
|
r = (redstone.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if (lapis.get(player) != null)
|
if (other.get(player) != null) {
|
||||||
{
|
o = (other.get(player) / t) * DIVISOR;
|
||||||
l = (lapis.get(player) / t) * DIVISOR;
|
}
|
||||||
}
|
}
|
||||||
if (redstone.get(player) != null)
|
|
||||||
{
|
public double getTotal() {
|
||||||
r = (redstone.get(player) / t) * DIVISOR;
|
return t;
|
||||||
}
|
}
|
||||||
if (other.get(player) != null)
|
|
||||||
{
|
public double getDiamond() {
|
||||||
o = (other.get(player) / t) * DIVISOR;
|
return d;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public double getGold() {
|
||||||
public double getTotal()
|
return g;
|
||||||
{
|
}
|
||||||
return t;
|
|
||||||
}
|
public double getIron() {
|
||||||
|
return i;
|
||||||
public double getDiamond()
|
}
|
||||||
{
|
|
||||||
return d;
|
public double getLapis() {
|
||||||
}
|
return l;
|
||||||
|
}
|
||||||
public double getGold()
|
|
||||||
{
|
public double getRedstone() {
|
||||||
return g;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIron()
|
public double getOther() {
|
||||||
{
|
return o;
|
||||||
return i;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public double getLapis()
|
|
||||||
{
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRedstone()
|
|
||||||
{
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getOther()
|
|
||||||
{
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -25,151 +25,127 @@ 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>();
|
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
private Map<String, Integer> block = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> block = new HashMap<String, Integer>();
|
private Map<String, Integer> totalblock = new HashMap<String, Integer>();
|
||||||
private Map<String, Integer> totalblock = new HashMap<String, Integer>();
|
private List<String> alerted = new ArrayList<String>();
|
||||||
private List<String> alerted = new ArrayList<String>();
|
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
private static final ChatColor RED = ChatColor.RED;
|
||||||
private static final ChatColor RED = ChatColor.RED;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private static final int RATIO_DIVISOR = 3;
|
||||||
private static final int RATIO_DIVISOR = 3;
|
private static final int POWER = 10;
|
||||||
private static final int POWER = 10;
|
private static final int MIN_BLOCK_COUNT = 100;
|
||||||
private static final int MIN_BLOCK_COUNT = 100;
|
|
||||||
|
public XRayTracker() {
|
||||||
public XRayTracker()
|
}
|
||||||
{
|
|
||||||
}
|
public boolean sufficientData(String player) {
|
||||||
|
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
||||||
public boolean sufficientData(String player)
|
}
|
||||||
{
|
|
||||||
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
public void calculate(CommandSender cs, String player, double x, double b, String type) {
|
||||||
}
|
ChatColor color = WHITE;
|
||||||
|
if (x >= b / RATIO_DIVISOR) {
|
||||||
public void calculate(CommandSender cs, String player, double x, double b, String type)
|
color = RED;
|
||||||
{
|
}
|
||||||
ChatColor color = WHITE;
|
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
||||||
if (x >= b / RATIO_DIVISOR)
|
}
|
||||||
{
|
|
||||||
color = RED;
|
public boolean calculate(String player, double x, double b) {
|
||||||
}
|
return x >= b / RATIO_DIVISOR;
|
||||||
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
}
|
||||||
}
|
|
||||||
|
public boolean hasAbnormal(String player) {
|
||||||
public boolean calculate(String player, double x, double b)
|
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
||||||
{
|
double total = stats.getOther();
|
||||||
return x >= b / RATIO_DIVISOR;
|
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAbnormal(String player)
|
public boolean hasAlerted(String player) {
|
||||||
{
|
return alerted.contains(player);
|
||||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
}
|
||||||
double total = stats.getOther();
|
|
||||||
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
public void logAlert(String player) {
|
||||||
}
|
alerted.add(player);
|
||||||
|
}
|
||||||
public boolean hasAlerted(String player)
|
|
||||||
{
|
public void sendStats(CommandSender cs, String player) {
|
||||||
return alerted.contains(player);
|
getStats(cs, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logAlert(String player)
|
public void getStats(CommandSender cs, String player) {
|
||||||
{
|
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
||||||
alerted.add(player);
|
double total = stats.getOther();
|
||||||
}
|
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
||||||
|
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
||||||
public void sendStats(CommandSender cs, String player)
|
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
||||||
{
|
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
||||||
getStats(cs, player);
|
calculate(cs, player, stats.getGold(), total, "gold");
|
||||||
}
|
calculate(cs, player, stats.getIron(), total, "iron");
|
||||||
|
calculate(cs, player, stats.getLapis(), total, "lapis");
|
||||||
public void getStats(CommandSender cs, String player)
|
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
||||||
{
|
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
||||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, lapis, redstone, block, totalblock);
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
double total = stats.getOther();
|
}
|
||||||
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
|
||||||
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
public void addDiamond(String player) {
|
||||||
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
addOre(player, diamond);
|
||||||
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
}
|
||||||
calculate(cs, player, stats.getGold(), total, "gold");
|
|
||||||
calculate(cs, player, stats.getIron(), total, "iron");
|
public void addGold(String player) {
|
||||||
calculate(cs, player, stats.getLapis(), total, "lapis");
|
addOre(player, gold);
|
||||||
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
}
|
||||||
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
public void addIron(String player) {
|
||||||
}
|
addOre(player, iron);
|
||||||
|
}
|
||||||
public void addDiamond(String player)
|
|
||||||
{
|
public void addLapis(String player) {
|
||||||
addOre(player, diamond);
|
addOre(player, lapis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGold(String player)
|
public void addRedstone(String player) {
|
||||||
{
|
addOre(player, redstone);
|
||||||
addOre(player, gold);
|
}
|
||||||
}
|
|
||||||
|
public void addBlock(String player) {
|
||||||
public void addIron(String player)
|
addOre(player, block);
|
||||||
{
|
}
|
||||||
addOre(player, iron);
|
|
||||||
}
|
public void addTotal(String player) {
|
||||||
|
addOre(player, totalblock);
|
||||||
public void addLapis(String player)
|
}
|
||||||
{
|
|
||||||
addOre(player, lapis);
|
private void addOre(String player, Map<String, Integer> map) {
|
||||||
}
|
if (map.get(player) == null || map.get(player) == 0) {
|
||||||
|
map.put(player, 1);
|
||||||
public void addRedstone(String player)
|
} else {
|
||||||
{
|
int playerLevel = map.get(player);
|
||||||
addOre(player, redstone);
|
map.put(player, playerLevel + 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void addBlock(String player)
|
|
||||||
{
|
private float round(double num) {
|
||||||
addOre(player, block);
|
double number = num;
|
||||||
}
|
float p = (float) Math.pow(POWER, 1);
|
||||||
|
number *= p;
|
||||||
public void addTotal(String player)
|
float tmp = Math.round(number);
|
||||||
{
|
return (float) tmp / p;
|
||||||
addOre(player, totalblock);
|
}
|
||||||
}
|
|
||||||
|
public void reset(String player) {
|
||||||
private void addOre(String player, Map<String, Integer> map)
|
totalblock.put(player, 1);
|
||||||
{
|
diamond.put(player, 0);
|
||||||
if (map.get(player) == null || map.get(player) == 0)
|
iron.put(player, 0);
|
||||||
{
|
gold.put(player, 0);
|
||||||
map.put(player, 1);
|
redstone.put(player, 0);
|
||||||
}
|
lapis.put(player, 0);
|
||||||
else
|
totalblock.put(player, 0);
|
||||||
{
|
}
|
||||||
int playerLevel = map.get(player);
|
|
||||||
map.put(player, playerLevel + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private float round(double num)
|
|
||||||
{
|
|
||||||
double number = num;
|
|
||||||
float p = (float) Math.pow(POWER, 1);
|
|
||||||
number *= p;
|
|
||||||
float tmp = Math.round(number);
|
|
||||||
return (float) tmp / p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset(String player)
|
|
||||||
{
|
|
||||||
totalblock.put(player, 1);
|
|
||||||
diamond.put(player, 0);
|
|
||||||
iron.put(player, 0);
|
|
||||||
gold.put(player, 0);
|
|
||||||
redstone.put(player, 0);
|
|
||||||
lapis.put(player, 0);
|
|
||||||
totalblock.put(player, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user