mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-03 22:15:28 +00:00
Merge branch 'master' of github.com:h31ix/AntiCheat into development
Conflicts: src/main/java/net/h31ix/anticheat/event/PlayerListener.java src/main/java/net/h31ix/anticheat/manage/Backend.java src/main/java/net/h31ix/anticheat/manage/Distance.java src/main/java/net/h31ix/anticheat/util/Utilities.java
This commit is contained in:
commit
92d2868802
24 files changed
+1641
-1617
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -40,7 +40,7 @@ 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 final List<Listener> eventList = new ArrayList<Listener>();
|
private final List<Listener> eventList = new ArrayList<Listener>();
|
||||||
@@ -54,12 +54,12 @@ public class Anticheat extends JavaPlugin
|
|||||||
private static final long XRAY_TIME = 1200;
|
private static final long XRAY_TIME = 1200;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
AnticheatManager.close();
|
AnticheatManager.close();
|
||||||
Map<String, Integer> map = manager.getPlayerManager().getLevels();
|
Map<String, Integer> map = manager.getPlayerManager().getLevels();
|
||||||
Iterator<String> set = map.keySet().iterator();
|
Iterator<String> set = map.keySet().iterator();
|
||||||
while (set.hasNext())
|
while (set.hasNext())
|
||||||
{
|
{
|
||||||
String player = set.next();
|
String player = set.next();
|
||||||
config.saveLevel(player, map.get(player));
|
config.saveLevel(player, map.get(player));
|
||||||
@@ -69,7 +69,7 @@ public class Anticheat extends JavaPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
logger = this.getLogger();
|
logger = this.getLogger();
|
||||||
manager = new AnticheatManager(this);
|
manager = new AnticheatManager(this);
|
||||||
@@ -77,95 +77,95 @@ public class Anticheat extends JavaPlugin
|
|||||||
checkConfig();
|
checkConfig();
|
||||||
verbose = config.verboseStartup();
|
verbose = config.verboseStartup();
|
||||||
updateFolder = config.updateFolder();
|
updateFolder = config.updateFolder();
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Setup the config.");
|
logger.log(Level.INFO, "Setup the config.");
|
||||||
}
|
}
|
||||||
checkForUpdate();
|
checkForUpdate();
|
||||||
eventList.add(new PlayerListener());
|
eventList.add(new PlayerListener());
|
||||||
eventList.add(new BlockListener());
|
eventList.add(new BlockListener());
|
||||||
eventList.add(new EntityListener());
|
eventList.add(new EntityListener());
|
||||||
eventList.add(new VehicleListener());
|
eventList.add(new VehicleListener());
|
||||||
final XRayTracker xtracker = manager.getXRayTracker();
|
final XRayTracker xtracker = manager.getXRayTracker();
|
||||||
if (config.logXRay())
|
if (config.logXRay())
|
||||||
{
|
{
|
||||||
eventList.add(new XRayListener());
|
eventList.add(new XRayListener());
|
||||||
if (config.alertXRay())
|
if (config.alertXRay())
|
||||||
{
|
{
|
||||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
for (Player player : getServer().getOnlinePlayers())
|
for (Player player : getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||||
{
|
{
|
||||||
String [] alert = new String[2];
|
String[] alert = new String[2];
|
||||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+name+ChatColor.YELLOW+" might be using xray.";
|
alert[0] = ChatColor.YELLOW + "[ALERT] " + ChatColor.WHITE + name + ChatColor.YELLOW + " might be using xray.";
|
||||||
alert[1] = ChatColor.YELLOW+"[ALERT] Please check their xray stats using "+ChatColor.WHITE+"/anticheat xray "+name+ChatColor.YELLOW+".";
|
alert[1] = ChatColor.YELLOW + "[ALERT] Please check their xray stats using " + ChatColor.WHITE + "/anticheat xray " + name + ChatColor.YELLOW + ".";
|
||||||
Utilities.alert(alert);
|
Utilities.alert(alert);
|
||||||
xtracker.logAlert(name);
|
xtracker.logAlert(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, XRAY_TIME, XRAY_TIME);
|
}, XRAY_TIME, XRAY_TIME);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Scheduled the XRay checker.");
|
logger.log(Level.INFO, "Scheduled the XRay checker.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Listener listener : eventList)
|
for (Listener listener : eventList)
|
||||||
{
|
{
|
||||||
getServer().getPluginManager().registerEvents(listener, this);
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Registered events for ".concat(listener.toString()));
|
logger.log(Level.INFO, "Registered events for ".concat(listener.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Registered commands.");
|
logger.log(Level.INFO, "Registered commands.");
|
||||||
}
|
}
|
||||||
if (update && config.autoUpdate())
|
if (update && config.autoUpdate())
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Downloading the new update...");
|
logger.log(Level.INFO, "Downloading the new update...");
|
||||||
}
|
}
|
||||||
File file = new File("plugins/" + updateFolder);
|
File file = new File("plugins/" + updateFolder);
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
file.mkdir();
|
file.mkdir();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
saveFile(file.getCanonicalPath() + "/AntiCheat.jar","http://dl.dropbox.com/u/38228324/AntiCheat.jar");
|
saveFile(file.getCanonicalPath() + "/AntiCheat.jar", "http://dl.dropbox.com/u/38228324/AntiCheat.jar");
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
metrics = new Metrics(this);
|
metrics = new Metrics(this);
|
||||||
final EventListener listener = new EventListener();
|
final EventListener listener = new EventListener();
|
||||||
Graph hacksGraph = metrics.createGraph("Hacks blocked");
|
Graph hacksGraph = metrics.createGraph("Hacks blocked");
|
||||||
for (final CheckType type : CheckType.values())
|
for (final CheckType type : CheckType.values())
|
||||||
{
|
{
|
||||||
hacksGraph.addPlotter(new Metrics.Plotter(CheckType.getName(type))
|
hacksGraph.addPlotter(new Metrics.Plotter(CheckType.getName(type))
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int getValue()
|
public int getValue()
|
||||||
{
|
{
|
||||||
return listener.getCheats(type);
|
return listener.getCheats(type);
|
||||||
}
|
}
|
||||||
@@ -173,51 +173,51 @@ public class Anticheat extends JavaPlugin
|
|||||||
listener.resetCheck(type);
|
listener.resetCheck(type);
|
||||||
}
|
}
|
||||||
Graph apiGraph = metrics.createGraph("API Usage");
|
Graph apiGraph = metrics.createGraph("API Usage");
|
||||||
apiGraph.addPlotter(new Metrics.Plotter("Checks disabled")
|
apiGraph.addPlotter(new Metrics.Plotter("Checks disabled")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int getValue()
|
public int getValue()
|
||||||
{
|
{
|
||||||
return manager.getCheckManager().getDisabled();
|
return manager.getCheckManager().getDisabled();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
apiGraph.addPlotter(new Metrics.Plotter("Players exempted")
|
apiGraph.addPlotter(new Metrics.Plotter("Players exempted")
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public int getValue()
|
public int getValue()
|
||||||
{
|
{
|
||||||
return manager.getCheckManager().getExempt();
|
return manager.getCheckManager().getExempt();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
metrics.start();
|
metrics.start();
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Metrics started.");
|
logger.log(Level.INFO, "Metrics started.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
for (Player player : getServer().getOnlinePlayers())
|
for (Player player : getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
manager.getPlayerManager().setLevel(player,config.getLevel(name));
|
manager.getPlayerManager().setLevel(player, config.getLevel(name));
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Data for "+player.getName()+" re-applied from flatfile");
|
logger.log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Finished loading.");
|
logger.log(Level.INFO, "Finished loading.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFile(String file, String url)
|
private void saveFile(String file, String url)
|
||||||
{
|
{
|
||||||
BufferedInputStream in = null;
|
BufferedInputStream in = null;
|
||||||
FileOutputStream fout = null;
|
FileOutputStream fout = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
in = new BufferedInputStream(new URL(url).openStream());
|
in = new BufferedInputStream(new URL(url).openStream());
|
||||||
fout = new FileOutputStream(file);
|
fout = new FileOutputStream(file);
|
||||||
@@ -228,56 +228,56 @@ public class Anticheat extends JavaPlugin
|
|||||||
{
|
{
|
||||||
fout.write(data, 0, count);
|
fout.write(data, 0, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (in != null)
|
if (in != null)
|
||||||
{
|
{
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
if (fout != null)
|
if (fout != null)
|
||||||
{
|
{
|
||||||
fout.close();
|
fout.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"AntiCheat update has been downloaded and will be installed on next launch.");
|
logger.log(Level.INFO, "AntiCheat update has been downloaded and will be installed on next launch.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConfig()
|
public void checkConfig()
|
||||||
{
|
{
|
||||||
if (!new File(getDataFolder() + "/config.yml").exists())
|
if (!new File(getDataFolder() + "/config.yml").exists())
|
||||||
{
|
{
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Config file created.");
|
logger.log(Level.INFO, "Config file created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!new File(getDataFolder() + "/lang.yml").exists())
|
if (!new File(getDataFolder() + "/lang.yml").exists())
|
||||||
{
|
{
|
||||||
saveResource("lang.yml",false);
|
saveResource("lang.yml", false);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Lang file created.");
|
logger.log(Level.INFO, "Lang file created.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForUpdate()
|
private void checkForUpdate()
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "Checking for updates...");
|
logger.log(Level.INFO, "Checking for updates...");
|
||||||
}
|
}
|
||||||
@@ -286,61 +286,61 @@ public class Anticheat extends JavaPlugin
|
|||||||
InputStreamReader inStream = null;
|
InputStreamReader inStream = null;
|
||||||
BufferedReader buff;
|
BufferedReader buff;
|
||||||
String v = "";
|
String v = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
url = new URL("http://dl.dropbox.com/u/38228324/anticheatVersion.txt");
|
url = new URL("http://dl.dropbox.com/u/38228324/anticheatVersion.txt");
|
||||||
urlConn = url.openConnection();
|
urlConn = url.openConnection();
|
||||||
inStream = new InputStreamReader(urlConn.getInputStream());
|
inStream = new InputStreamReader(urlConn.getInputStream());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
buff = new BufferedReader(inStream);
|
buff = new BufferedReader(inStream);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
v = buff.readLine();
|
v = buff.readLine();
|
||||||
urlConn = null;
|
urlConn = null;
|
||||||
inStream = null;
|
inStream = null;
|
||||||
buff.close();
|
buff.close();
|
||||||
buff = null;
|
buff = null;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
String version = this.getDescription().getVersion().split("-b")[0];
|
String version = this.getDescription().getVersion().split("-b")[0];
|
||||||
if (!version.equalsIgnoreCase(v))
|
if (!version.equalsIgnoreCase(v))
|
||||||
{
|
{
|
||||||
if (version.endsWith("-PRE") || version.endsWith("-DEV"))
|
if (version.endsWith("-PRE") || version.endsWith("-DEV"))
|
||||||
{
|
{
|
||||||
if (version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
if (version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
||||||
{
|
{
|
||||||
update = true;
|
update = true;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO,"Your dev build has been promoted to release. Downloading the update.");
|
logger.log(Level.INFO, "Your dev build has been promoted to release. Downloading the update.");
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
update = false;
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
logger.log(Level.INFO,"Dev build detected, so skipping update checking until this version is released.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
|
update = false;
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
logger.log(Level.INFO, "Dev build detected, so skipping update checking until this version is released.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
update = true;
|
update = true;
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "An update was found.");
|
logger.log(Level.INFO, "An update was found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "No update found.");
|
logger.log(Level.INFO, "No update found.");
|
||||||
}
|
}
|
||||||
@@ -353,21 +353,21 @@ public class Anticheat extends JavaPlugin
|
|||||||
return manager.getPlugin();
|
return manager.getPlugin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnticheatManager getManager()
|
public static AnticheatManager getManager()
|
||||||
{
|
{
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUpdated()
|
public static boolean isUpdated()
|
||||||
{
|
{
|
||||||
return !update;
|
return !update;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getVersion()
|
public static String getVersion()
|
||||||
{
|
{
|
||||||
return manager.getPlugin().getDescription().getVersion();
|
return manager.getPlugin().getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Logger getAnticheatLogger()
|
public Logger getAnticheatLogger()
|
||||||
{
|
{
|
||||||
return this.getLogger();
|
return this.getLogger();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -35,7 +35,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandHandler implements CommandExecutor
|
public class CommandHandler implements CommandExecutor
|
||||||
{
|
{
|
||||||
private Configuration config = Anticheat.getManager().getConfiguration();
|
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||||
private PlayerManager playerManager = Anticheat.getManager().getPlayerManager();
|
private PlayerManager playerManager = Anticheat.getManager().getPlayerManager();
|
||||||
@@ -47,44 +47,44 @@ public class CommandHandler implements CommandExecutor
|
|||||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||||
private List<String> high = new ArrayList<String>();
|
private List<String> high = new ArrayList<String>();
|
||||||
private List<String> med = new ArrayList<String>();
|
private List<String> med = new ArrayList<String>();
|
||||||
private List<String> low = new ArrayList<String>();
|
private List<String> low = new ArrayList<String>();
|
||||||
private Map<String,Location> spyLocation = new HashMap<String,Location>();
|
private Map<String, Location> spyLocation = new HashMap<String, Location>();
|
||||||
private static final Server SERVER = Bukkit.getServer();
|
private static final Server SERVER = Bukkit.getServer();
|
||||||
private static final int MED_THRESHOLD = 20;
|
private static final int MED_THRESHOLD = 20;
|
||||||
private static final int HIGH_THRESHOLD = 50;
|
private static final int HIGH_THRESHOLD = 50;
|
||||||
private static final String PERMISSIONS_ERROR = RED+"Insufficient Permissions.";
|
private static final String PERMISSIONS_ERROR = RED + "Insufficient Permissions.";
|
||||||
|
|
||||||
public void handleLog(CommandSender cs, String [] args)
|
public void handleLog(CommandSender cs, String[] args)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_LOG.get(cs))
|
if (Permission.SYSTEM_LOG.get(cs))
|
||||||
{
|
{
|
||||||
if(args[1].equalsIgnoreCase("enable"))
|
if (args[1].equalsIgnoreCase("enable"))
|
||||||
{
|
{
|
||||||
if(!config.logConsole())
|
if (!config.logConsole())
|
||||||
{
|
{
|
||||||
config.setLog(true);
|
config.setLog(true);
|
||||||
cs.sendMessage(GREEN+"Console logging enabled.");
|
cs.sendMessage(GREEN + "Console logging enabled.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+"Console logging is already enabled!");
|
cs.sendMessage(GREEN + "Console logging is already enabled!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(args[1].equalsIgnoreCase("disable"))
|
else if (args[1].equalsIgnoreCase("disable"))
|
||||||
{
|
{
|
||||||
if(config.logConsole())
|
if (config.logConsole())
|
||||||
{
|
{
|
||||||
config.setLog(false);
|
config.setLog(false);
|
||||||
cs.sendMessage(GREEN+"Console logging disabled.");
|
cs.sendMessage(GREEN + "Console logging disabled.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+"Console logging is already disabled!");
|
cs.sendMessage(GREEN + "Console logging is already disabled!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Usage: /anticheat log [enable/disable]");
|
cs.sendMessage(RED + "Usage: /anticheat log [enable/disable]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -92,101 +92,101 @@ public class CommandHandler implements CommandExecutor
|
|||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleXRay(CommandSender cs, String [] args)
|
public void handleXRay(CommandSender cs, String[] args)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_XRAY.get(cs))
|
if (Permission.SYSTEM_XRAY.get(cs))
|
||||||
{
|
{
|
||||||
if(config.logXRay())
|
if (config.logXRay())
|
||||||
{
|
{
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if(list.size() == 1)
|
if (list.size() == 1)
|
||||||
{
|
{
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
if(xtracker.sufficientData(player.getName()))
|
if (xtracker.sufficientData(player.getName()))
|
||||||
{
|
{
|
||||||
xtracker.sendStats(cs, player.getName());
|
xtracker.sendStats(cs, player.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Insufficient data collected from "+WHITE+args[1]+RED+".");
|
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[1] + RED + ".");
|
||||||
cs.sendMessage(RED+"Please wait until more info is collected before predictions are calculated.");
|
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(list.size() > 1)
|
else if (list.size() > 1)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
}
|
}
|
||||||
else if(xtracker.sufficientData(args[1]))
|
else if (xtracker.sufficientData(args[1]))
|
||||||
{
|
{
|
||||||
xtracker.sendStats(cs, args[1]);
|
xtracker.sendStats(cs, args[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Insufficient data collected from "+WHITE+args[1]+RED+".");
|
cs.sendMessage(RED + "Insufficient data collected from " + WHITE + args[1] + RED + ".");
|
||||||
cs.sendMessage(RED+"Please wait until more info is collected before predictions are calculated.");
|
cs.sendMessage(RED + "Please wait until more info is collected before predictions are calculated.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"XRay logging is off in the config.");
|
cs.sendMessage(RED + "XRay logging is off in the config.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReset(CommandSender cs, String [] args)
|
public void handleReset(CommandSender cs, String[] args)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_RESET.get(cs))
|
if (Permission.SYSTEM_RESET.get(cs))
|
||||||
{
|
{
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if(list.size() == 1)
|
if (list.size() == 1)
|
||||||
{
|
{
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
if(playerManager.getLevel(player) == 0)
|
if (playerManager.getLevel(player) == 0)
|
||||||
{
|
{
|
||||||
cs.sendMessage(player.getName()+RED+" is already in Low Level!");
|
cs.sendMessage(player.getName() + RED + " is already in Low Level!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
playerManager.reset(player);
|
playerManager.reset(player);
|
||||||
cs.sendMessage(player.getName()+GREEN+" has been reset to Low Level.");
|
cs.sendMessage(player.getName() + GREEN + " has been reset to Low Level.");
|
||||||
}
|
}
|
||||||
xtracker.reset(player.getName());
|
xtracker.reset(player.getName());
|
||||||
cs.sendMessage(player.getName()+GREEN+"'s XRay stats have been reset.");
|
cs.sendMessage(player.getName() + GREEN + "'s XRay stats have been reset.");
|
||||||
}
|
}
|
||||||
else if(list.size() > 1)
|
else if (list.size() > 1)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleSpy(CommandSender cs, String [] args)
|
public void handleSpy(CommandSender cs, String[] args)
|
||||||
{
|
{
|
||||||
if(cs instanceof Player)
|
if (cs instanceof Player)
|
||||||
{
|
{
|
||||||
Player sender = (Player)cs;
|
Player sender = (Player) cs;
|
||||||
if(Permission.SYSTEM_SPY.get(cs))
|
if (Permission.SYSTEM_SPY.get(cs))
|
||||||
{
|
{
|
||||||
if(!args[1].equalsIgnoreCase("off"))
|
if (!args[1].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if(list.size() == 1)
|
if (list.size() == 1)
|
||||||
{
|
{
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
for(Player p : cs.getServer().getOnlinePlayers())
|
for (Player p : cs.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
p.hidePlayer(sender);
|
p.hidePlayer(sender);
|
||||||
}
|
}
|
||||||
@@ -194,199 +194,199 @@ public class CommandHandler implements CommandExecutor
|
|||||||
sender.setFlying(true);
|
sender.setFlying(true);
|
||||||
spyLocation.put(sender.getName(), sender.getLocation());
|
spyLocation.put(sender.getName(), sender.getLocation());
|
||||||
sender.teleport(player);
|
sender.teleport(player);
|
||||||
sender.sendMessage(GREEN+"You have been teleported to "+player.getName()+" and made invisible.");
|
sender.sendMessage(GREEN + "You have been teleported to " + player.getName() + " and made invisible.");
|
||||||
sender.sendMessage(GREEN+"To stop spying, type "+WHITE+" /AntiCheat spy off");
|
sender.sendMessage(GREEN + "To stop spying, type " + WHITE + " /AntiCheat spy off");
|
||||||
}
|
}
|
||||||
else if(list.size() > 1)
|
else if (list.size() > 1)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.setFlying(false);
|
sender.setFlying(false);
|
||||||
sender.setAllowFlight(false);
|
sender.setAllowFlight(false);
|
||||||
if(spyLocation.containsKey(sender.getName()))
|
if (spyLocation.containsKey(sender.getName()))
|
||||||
{
|
{
|
||||||
sender.teleport(spyLocation.get(sender.getName()));
|
sender.teleport(spyLocation.get(sender.getName()));
|
||||||
spyLocation.remove(sender.getName());
|
spyLocation.remove(sender.getName());
|
||||||
}
|
}
|
||||||
for(Player p : cs.getServer().getOnlinePlayers())
|
for (Player p : cs.getServer().getOnlinePlayers())
|
||||||
{
|
{
|
||||||
p.showPlayer(sender);
|
p.showPlayer(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Sorry, but you can't spy on a player from the console.");
|
cs.sendMessage(RED + "Sorry, but you can't spy on a player from the console.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleHelp(CommandSender cs)
|
public void handleHelp(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_HELP.get(cs))
|
if (Permission.SYSTEM_HELP.get(cs))
|
||||||
{
|
{
|
||||||
String base = "/AntiCheat ";
|
String base = "/AntiCheat ";
|
||||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
cs.sendMessage("----------------------[" + GREEN + "AntiCheat" + WHITE + "]----------------------");
|
||||||
cs.sendMessage(base+GREEN+"log [Enable/Disable]"+WHITE+" - toggle logging");
|
cs.sendMessage(base + GREEN + "log [Enable/Disable]" + WHITE + " - toggle logging");
|
||||||
cs.sendMessage(base+GREEN+"report"+WHITE+" - get a detailed cheat report");
|
cs.sendMessage(base + GREEN + "report" + WHITE + " - get a detailed cheat report");
|
||||||
cs.sendMessage(base+GREEN+"report [user]"+WHITE+" - get a player's cheat report");
|
cs.sendMessage(base + GREEN + "report [user]" + WHITE + " - get a player's cheat report");
|
||||||
cs.sendMessage(base+GREEN+"reload"+WHITE+" - reload AntiCheat configuration");
|
cs.sendMessage(base + GREEN + "reload" + WHITE + " - reload AntiCheat configuration");
|
||||||
cs.sendMessage(base+GREEN+"reset [user]"+WHITE+" - reset user's hack level");
|
cs.sendMessage(base + GREEN + "reset [user]" + WHITE + " - reset user's hack level");
|
||||||
cs.sendMessage(base+GREEN+"xray [user]"+WHITE+" - check user's xray levels");
|
cs.sendMessage(base + GREEN + "xray [user]" + WHITE + " - check user's xray levels");
|
||||||
cs.sendMessage(base+GREEN+"spy [user]"+WHITE+" - spy on a user in secret");
|
cs.sendMessage(base + GREEN + "spy [user]" + WHITE + " - spy on a user in secret");
|
||||||
cs.sendMessage(base+GREEN+"help"+WHITE+" - access this page");
|
cs.sendMessage(base + GREEN + "help" + WHITE + " - access this page");
|
||||||
cs.sendMessage(base+GREEN+"update"+WHITE+" - check update status");
|
cs.sendMessage(base + GREEN + "update" + WHITE + " - check update status");
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleUpdate(CommandSender cs)
|
public void handleUpdate(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_UPDATE.get(cs))
|
if (Permission.SYSTEM_UPDATE.get(cs))
|
||||||
{
|
{
|
||||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
cs.sendMessage("Running " + GREEN + "AntiCheat " + WHITE + "v" + GREEN + Anticheat.getVersion());
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
if(!Anticheat.isUpdated())
|
if (!Anticheat.isUpdated())
|
||||||
{
|
{
|
||||||
cs.sendMessage(GRAY+"There "+GREEN+"IS"+GRAY+" a newer version avaliable.");
|
cs.sendMessage(GRAY + "There " + GREEN + "IS" + GRAY + " a newer version avaliable.");
|
||||||
if(config.autoUpdate())
|
if (config.autoUpdate())
|
||||||
{
|
{
|
||||||
cs.sendMessage(GRAY+"It will be installed automatically for you on next launch.");
|
cs.sendMessage(GRAY + "It will be installed automatically for you on next launch.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(GRAY+"Due to your config settings, we "+RED+"can not"+GRAY+" auto update.");
|
cs.sendMessage(GRAY + "Due to your config settings, we " + RED + "can not" + GRAY + " auto update.");
|
||||||
cs.sendMessage(GRAY+"Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
cs.sendMessage(GRAY + "Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(GRAY+"AntiCheat is "+GREEN+"UP TO DATE!");
|
cs.sendMessage(GRAY + "AntiCheat is " + GREEN + "UP TO DATE!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReport(CommandSender cs)
|
public void handleReport(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_REPORT.get(cs))
|
if (Permission.SYSTEM_REPORT.get(cs))
|
||||||
{
|
{
|
||||||
getPlayers();
|
getPlayers();
|
||||||
if(!low.isEmpty())
|
if (!low.isEmpty())
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+"----Level: Low (Not likely hacking)----");
|
cs.sendMessage(GREEN + "----Level: Low (Not likely hacking)----");
|
||||||
for(String string : low)
|
for (String string : low)
|
||||||
{
|
{
|
||||||
cs.sendMessage(GREEN+string);
|
cs.sendMessage(GREEN + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!med.isEmpty())
|
if (!med.isEmpty())
|
||||||
{
|
{
|
||||||
cs.sendMessage(YELLOW+"----Level: Medium (Possibly hacking/lagging)----");
|
cs.sendMessage(YELLOW + "----Level: Medium (Possibly hacking/lagging)----");
|
||||||
for(String string : med)
|
for (String string : med)
|
||||||
{
|
{
|
||||||
cs.sendMessage(YELLOW+string);
|
cs.sendMessage(YELLOW + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!high.isEmpty())
|
if (!high.isEmpty())
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"----Level: High (Probably hacking or bad connection)----");
|
cs.sendMessage(RED + "----Level: High (Probably hacking or bad connection)----");
|
||||||
for(String string : high)
|
for (String string : high)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+string);
|
cs.sendMessage(RED + string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handlePlayerReport(CommandSender cs,String [] args)
|
public void handlePlayerReport(CommandSender cs, String[] args)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_REPORT.get(cs))
|
if (Permission.SYSTEM_REPORT.get(cs))
|
||||||
{
|
{
|
||||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||||
if(list.size() == 1)
|
if (list.size() == 1)
|
||||||
{
|
{
|
||||||
Player player = list.get(0);
|
Player player = list.get(0);
|
||||||
if(args.length == 2)
|
if (args.length == 2)
|
||||||
{
|
{
|
||||||
sendPlayerReport(cs,CheckType.values(),player,1);
|
sendPlayerReport(cs, CheckType.values(), player, 1);
|
||||||
}
|
}
|
||||||
else if(Utilities.isInt(args[2]))
|
else if (Utilities.isInt(args[2]))
|
||||||
{
|
{
|
||||||
int num = Integer.parseInt(args[2]);
|
int num = Integer.parseInt(args[2]);
|
||||||
if(num <= 3 && num > 1)
|
if (num <= 3 && num > 1)
|
||||||
{
|
{
|
||||||
sendPlayerReport(cs,CheckType.values(),player,num);
|
sendPlayerReport(cs, CheckType.values(), player, num);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Page: "+num+RED+" does not exist.");
|
cs.sendMessage(RED + "Page: " + num + RED + " does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Not a valid page number: "+WHITE+args[2]);
|
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(list.size() > 1)
|
else if (list.size() > 1)
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPlayerReport(CommandSender cs, CheckType[] types, Player player, int page)
|
public void sendPlayerReport(CommandSender cs, CheckType[] types, Player player, int page)
|
||||||
{
|
{
|
||||||
cs.sendMessage("--------------------["+GREEN+"REPORT["+page+"/3]"+WHITE+"]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/3]" + WHITE + "]---------------------");
|
||||||
if(page == 1)
|
if (page == 1)
|
||||||
{
|
{
|
||||||
int level = playerManager.getLevel(player);
|
int level = playerManager.getLevel(player);
|
||||||
String levelString = GREEN+"Low";
|
String levelString = GREEN + "Low";
|
||||||
if(level >= 20)
|
if (level >= 20)
|
||||||
{
|
{
|
||||||
levelString = YELLOW+"Medium";
|
levelString = YELLOW + "Medium";
|
||||||
}
|
}
|
||||||
else if (level >= 50)
|
else if (level >= 50)
|
||||||
{
|
{
|
||||||
levelString = RED+"High";
|
levelString = RED + "High";
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY+"Player: "+WHITE+player.getName());
|
cs.sendMessage(GRAY + "Player: " + WHITE + player.getName());
|
||||||
cs.sendMessage(GRAY+"Level: "+levelString);
|
cs.sendMessage(GRAY + "Level: " + levelString);
|
||||||
for(int i=0;i<6;i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
int use = types[i].getUses(player);
|
int use = types[i].getUses(player);
|
||||||
ChatColor color = WHITE;
|
ChatColor color = WHITE;
|
||||||
if(use >= 20)
|
if (use >= 20)
|
||||||
{
|
{
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
}
|
}
|
||||||
@@ -394,16 +394,16 @@ public class CommandHandler implements CommandExecutor
|
|||||||
{
|
{
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY+CheckType.getName(types[i])+": "+color+use);
|
cs.sendMessage(GRAY + CheckType.getName(types[i]) + ": " + color + use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(page == 2)
|
else if (page == 2)
|
||||||
{
|
{
|
||||||
for(int i=6;i<14;i++)
|
for (int i = 6; i < 14; i++)
|
||||||
{
|
{
|
||||||
int use = types[i].getUses(player);
|
int use = types[i].getUses(player);
|
||||||
ChatColor color = WHITE;
|
ChatColor color = WHITE;
|
||||||
if(use >= 20)
|
if (use >= 20)
|
||||||
{
|
{
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
}
|
}
|
||||||
@@ -411,16 +411,16 @@ public class CommandHandler implements CommandExecutor
|
|||||||
{
|
{
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY+CheckType.getName(types[i])+": "+color+use);
|
cs.sendMessage(GRAY + CheckType.getName(types[i]) + ": " + color + use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(page == 3)
|
else if (page == 3)
|
||||||
{
|
{
|
||||||
for(int i=14;i<21;i++)
|
for (int i = 14; i < 21; i++)
|
||||||
{
|
{
|
||||||
int use = types[i].getUses(player);
|
int use = types[i].getUses(player);
|
||||||
ChatColor color = WHITE;
|
ChatColor color = WHITE;
|
||||||
if(use >= 20)
|
if (use >= 20)
|
||||||
{
|
{
|
||||||
color = YELLOW;
|
color = YELLOW;
|
||||||
}
|
}
|
||||||
@@ -428,106 +428,106 @@ public class CommandHandler implements CommandExecutor
|
|||||||
{
|
{
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY+CheckType.getName(types[i])+": "+color+use);
|
cs.sendMessage(GRAY + CheckType.getName(types[i]) + ": " + color + use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleReload(CommandSender cs)
|
public void handleReload(CommandSender cs)
|
||||||
{
|
{
|
||||||
if(Permission.SYSTEM_RELOAD.get(cs))
|
if (Permission.SYSTEM_RELOAD.get(cs))
|
||||||
{
|
{
|
||||||
config.load();
|
config.load();
|
||||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
cs.sendMessage(GREEN + "AntiCheat configuration reloaded.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(PERMISSIONS_ERROR);
|
cs.sendMessage(PERMISSIONS_ERROR);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args)
|
|
||||||
{
|
|
||||||
if(args.length == 3)
|
|
||||||
{
|
|
||||||
if(args[0].equalsIgnoreCase("report"))
|
|
||||||
{
|
|
||||||
handlePlayerReport(cs,args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(args.length == 2)
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 3)
|
||||||
{
|
{
|
||||||
if(args[0].equalsIgnoreCase("log"))
|
if (args[0].equalsIgnoreCase("report"))
|
||||||
{
|
{
|
||||||
handleLog(cs,args);
|
handlePlayerReport(cs, args);
|
||||||
}
|
}
|
||||||
else if(args[0].equalsIgnoreCase("xray"))
|
}
|
||||||
{
|
else if (args.length == 2)
|
||||||
handleXRay(cs,args);
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("log"))
|
||||||
|
{
|
||||||
|
handleLog(cs, args);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("xray"))
|
||||||
|
{
|
||||||
|
handleXRay(cs, args);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("reset"))
|
||||||
|
{
|
||||||
|
handleReset(cs, args);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("spy"))
|
||||||
|
{
|
||||||
|
handleSpy(cs, args);
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("report"))
|
||||||
|
{
|
||||||
|
handlePlayerReport(cs, args);
|
||||||
}
|
}
|
||||||
else if(args[0].equalsIgnoreCase("reset"))
|
|
||||||
{
|
|
||||||
handleReset(cs,args);
|
|
||||||
}
|
|
||||||
else if(args[0].equalsIgnoreCase("spy"))
|
|
||||||
{
|
|
||||||
handleSpy(cs,args);
|
|
||||||
}
|
|
||||||
else if(args[0].equalsIgnoreCase("report"))
|
|
||||||
{
|
|
||||||
handlePlayerReport(cs,args);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Unrecognized command.");
|
cs.sendMessage(RED + "Unrecognized command.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length == 1)
|
else if (args.length == 1)
|
||||||
{
|
{
|
||||||
if(args[0].equalsIgnoreCase("help"))
|
if (args[0].equalsIgnoreCase("help"))
|
||||||
{
|
{
|
||||||
handleHelp(cs);
|
handleHelp(cs);
|
||||||
}
|
}
|
||||||
else if(args[0].equalsIgnoreCase("report"))
|
else if (args[0].equalsIgnoreCase("report"))
|
||||||
{
|
{
|
||||||
handleReport(cs);
|
handleReport(cs);
|
||||||
}
|
}
|
||||||
else if(args[0].equalsIgnoreCase("reload"))
|
else if (args[0].equalsIgnoreCase("reload"))
|
||||||
{
|
{
|
||||||
handleReload(cs);
|
handleReload(cs);
|
||||||
}
|
}
|
||||||
else if(args[0].equalsIgnoreCase("update"))
|
else if (args[0].equalsIgnoreCase("update"))
|
||||||
{
|
{
|
||||||
handleUpdate(cs);
|
handleUpdate(cs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Unrecognized command.");
|
cs.sendMessage(RED + "Unrecognized command.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cs.sendMessage(RED+"Unrecognized command. Try "+ChatColor.WHITE+"/anticheat help");
|
cs.sendMessage(RED + "Unrecognized command. Try " + ChatColor.WHITE + "/anticheat help");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getPlayers()
|
public void getPlayers()
|
||||||
{
|
{
|
||||||
high.clear();
|
high.clear();
|
||||||
med.clear();
|
med.clear();
|
||||||
low.clear();
|
low.clear();
|
||||||
for(Player player : SERVER.getOnlinePlayers())
|
for (Player player : SERVER.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
int level = playerManager.getLevel(player);
|
int level = playerManager.getLevel(player);
|
||||||
if(level <= MED_THRESHOLD)
|
if (level <= MED_THRESHOLD)
|
||||||
{
|
{
|
||||||
low.add(player.getName());
|
low.add(player.getName());
|
||||||
}
|
}
|
||||||
else if(level <= HIGH_THRESHOLD)
|
else if (level <= HIGH_THRESHOLD)
|
||||||
{
|
{
|
||||||
med.add(player.getName());
|
med.add(player.getName());
|
||||||
}
|
}
|
||||||
@@ -535,6 +535,6 @@ public class CommandHandler implements CommandExecutor
|
|||||||
{
|
{
|
||||||
high.add(player.getName());
|
high.add(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -30,7 +30,7 @@ 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; //like a boss!
|
private AnticheatManager micromanage = null; //like a boss!
|
||||||
private File configFile = null;
|
private File configFile = null;
|
||||||
@@ -51,79 +51,79 @@ public class Configuration
|
|||||||
private String updateFolder;
|
private String updateFolder;
|
||||||
private static Language language;
|
private static Language language;
|
||||||
private List<String> worlds = new ArrayList<String>();
|
private List<String> worlds = new ArrayList<String>();
|
||||||
|
|
||||||
public Configuration(AnticheatManager instance)
|
public Configuration(AnticheatManager instance)
|
||||||
{
|
{
|
||||||
micromanage = instance;
|
micromanage = instance;
|
||||||
configFile = new File(micromanage.getPlugin().getDataFolder()+"/config.yml");
|
configFile = new File(micromanage.getPlugin().getDataFolder() + "/config.yml");
|
||||||
levelFile = new File(micromanage.getPlugin().getDataFolder()+"/data/level.yml");
|
levelFile = new File(micromanage.getPlugin().getDataFolder() + "/data/level.yml");
|
||||||
bukkitFile = new File("bukkit.yml");
|
bukkitFile = new File("bukkit.yml");
|
||||||
langFile = new File(micromanage.getPlugin().getDataFolder()+"/lang.yml");
|
langFile = new File(micromanage.getPlugin().getDataFolder() + "/lang.yml");
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save()
|
private void save()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
}
|
}
|
||||||
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 boolean logConsole()
|
public boolean logConsole()
|
||||||
{
|
{
|
||||||
return logConsole;
|
return logConsole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean logXRay()
|
public boolean logXRay()
|
||||||
{
|
{
|
||||||
return logXRay;
|
return logXRay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean alertXRay()
|
public boolean alertXRay()
|
||||||
{
|
{
|
||||||
return alertXRay;
|
return alertXRay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean autoUpdate()
|
public boolean autoUpdate()
|
||||||
{
|
{
|
||||||
return autoUpdate;
|
return autoUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean verboseStartup()
|
public boolean verboseStartup()
|
||||||
{
|
{
|
||||||
return verboseStartup;
|
return verboseStartup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean chatSpam()
|
public boolean chatSpam()
|
||||||
{
|
{
|
||||||
return chatSpam;
|
return chatSpam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean commandSpam()
|
public boolean commandSpam()
|
||||||
{
|
{
|
||||||
return commandSpam;
|
return commandSpam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String updateFolder()
|
public String updateFolder()
|
||||||
{
|
{
|
||||||
return updateFolder;
|
return updateFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFileLogLevel()
|
public int getFileLogLevel()
|
||||||
{
|
{
|
||||||
return fileLogLevel;
|
return fileLogLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Language getLang()
|
public Language getLang()
|
||||||
{
|
{
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void load()
|
public final void load()
|
||||||
{
|
{
|
||||||
FileConfiguration bukkit;
|
FileConfiguration bukkit;
|
||||||
@@ -134,132 +134,132 @@ public class Configuration
|
|||||||
lang = YamlConfiguration.loadConfiguration(langFile);
|
lang = YamlConfiguration.loadConfiguration(langFile);
|
||||||
language = new Language(lang);
|
language = new Language(lang);
|
||||||
updateFolder = bukkit.getString("settings.update-folder");
|
updateFolder = bukkit.getString("settings.update-folder");
|
||||||
if(config.getString("Logging.Log to console") != null)
|
if (config.getString("Logging.Log to console") != null)
|
||||||
{
|
{
|
||||||
boolean b = config.getBoolean("Logging.Log to console");
|
boolean b = config.getBoolean("Logging.Log to console");
|
||||||
config.set("Logging", null);
|
config.set("Logging", null);
|
||||||
config.set("System.Log to console",b);
|
config.set("System.Log to console", b);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
logConsole = config.getBoolean("System.Log to console");
|
logConsole = config.getBoolean("System.Log to console");
|
||||||
if(config.getList("Enable in") == null)
|
if (config.getList("Enable in") == null)
|
||||||
{
|
{
|
||||||
List<String> w = new ArrayList<String>();
|
List<String> w = new ArrayList<String>();
|
||||||
for(World world : Bukkit.getServer().getWorlds())
|
for (World world : Bukkit.getServer().getWorlds())
|
||||||
{
|
{
|
||||||
w.add(world.getName());
|
w.add(world.getName());
|
||||||
}
|
}
|
||||||
config.set("Enable in", w);
|
config.set("Enable in", w);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
worlds = config.getStringList("Enable in");
|
worlds = config.getStringList("Enable in");
|
||||||
if(config.getString("XRay.Log xray stats") == null)
|
if (config.getString("XRay.Log xray stats") == null)
|
||||||
{
|
{
|
||||||
config.set("XRay.Log xray stats", true);
|
config.set("XRay.Log xray stats", true);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
logXRay = config.getBoolean("XRay.Log xray stats");
|
logXRay = config.getBoolean("XRay.Log xray stats");
|
||||||
if(config.getString("System.Auto update") == null)
|
if (config.getString("System.Auto update") == null)
|
||||||
{
|
{
|
||||||
config.set("System.Auto update", true);
|
config.set("System.Auto update", true);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
autoUpdate = config.getBoolean("System.Auto update");
|
autoUpdate = config.getBoolean("System.Auto update");
|
||||||
if(config.getString("System.Verbose startup") == null)
|
if (config.getString("System.Verbose startup") == null)
|
||||||
{
|
{
|
||||||
config.set("System.Verbose startup", false);
|
config.set("System.Verbose startup", false);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
verboseStartup = config.getBoolean("System.Verbose startup");
|
verboseStartup = config.getBoolean("System.Verbose startup");
|
||||||
if(config.getString("XRay.Alert when xray is found") == null)
|
if (config.getString("XRay.Alert when xray is found") == null)
|
||||||
{
|
{
|
||||||
config.set("XRay.Alert when xray is found", false);
|
config.set("XRay.Alert when xray is found", false);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
alertXRay = config.getBoolean("XRay.Alert when xray is found");
|
alertXRay = config.getBoolean("XRay.Alert when xray is found");
|
||||||
if(config.getString("System.File log level") == null)
|
if (config.getString("System.File log level") == null)
|
||||||
{
|
{
|
||||||
config.set("System.File log level", 1);
|
config.set("System.File log level", 1);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
fileLogLevel = config.getInt("System.File log level");
|
fileLogLevel = config.getInt("System.File log level");
|
||||||
if(config.getString("System.Block chat spam") == null)
|
if (config.getString("System.Block chat spam") == null)
|
||||||
{
|
{
|
||||||
config.set("System.Block chat spam", true);
|
config.set("System.Block chat spam", true);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
chatSpam = config.getBoolean("System.Block chat spam");
|
chatSpam = config.getBoolean("System.Block chat spam");
|
||||||
if(config.getString("System.Block command spam") == null)
|
if (config.getString("System.Block command spam") == null)
|
||||||
{
|
{
|
||||||
config.set("System.Block command spam", true);
|
config.set("System.Block command spam", true);
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
commandSpam = config.getBoolean("System.Block command spam");
|
commandSpam = config.getBoolean("System.Block command spam");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResult(String event)
|
public String getResult(String event)
|
||||||
{
|
{
|
||||||
return config.getString("Events.Level "+event);
|
return config.getString("Events.Level " + event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLog(boolean b)
|
public void setLog(boolean b)
|
||||||
{
|
{
|
||||||
config.set("System.Log to console", b);
|
config.set("System.Log to console", b);
|
||||||
this.logConsole = b;
|
this.logConsole = b;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
}
|
}
|
||||||
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> getWorlds()
|
public List<String> getWorlds()
|
||||||
{
|
{
|
||||||
return worlds;
|
return worlds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getConfigFile()
|
public File getConfigFile()
|
||||||
{
|
{
|
||||||
return configFile;
|
return configFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getLevelFile()
|
public File getLevelFile()
|
||||||
{
|
{
|
||||||
return levelFile;
|
return levelFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkInWorld(World world)
|
public boolean checkInWorld(World world)
|
||||||
{
|
{
|
||||||
return worlds.contains(world.getName());
|
return worlds.contains(world.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevel(String player)
|
public int getLevel(String player)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if(level.getString(player) != null)
|
if (level.getString(player) != null)
|
||||||
{
|
{
|
||||||
x = level.getInt(player);
|
x = level.getInt(player);
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveLevel(String player, int x)
|
public void saveLevel(String player, int x)
|
||||||
{
|
{
|
||||||
level.set(player,x);
|
level.set(player, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveLevels()
|
public void saveLevels()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
level.save(levelFile);
|
level.save(levelFile);
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,7 +20,7 @@ package net.h31ix.anticheat;
|
|||||||
|
|
||||||
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;
|
||||||
@@ -29,7 +29,7 @@ public class Language
|
|||||||
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;
|
||||||
|
|
||||||
public Language(FileConfiguration file)
|
public Language(FileConfiguration file)
|
||||||
{
|
{
|
||||||
medAlert = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
medAlert = file.getList("alert.medium_alert").toArray(new String[file.getList("alert.medium_alert").size()]);
|
||||||
@@ -38,41 +38,41 @@ public class Language
|
|||||||
banReason = file.getString("ban.ban_reason");
|
banReason = file.getString("ban.ban_reason");
|
||||||
banBroadcast = file.getString("ban.ban_broadcast");
|
banBroadcast = file.getString("ban.ban_broadcast");
|
||||||
kickReason = file.getString("kick.kick_reason");
|
kickReason = file.getString("kick.kick_reason");
|
||||||
kickBroadcast = file.getString("kick.kick_broadcast");
|
kickBroadcast = file.getString("kick.kick_broadcast");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String [] getMediumAlert()
|
public String[] getMediumAlert()
|
||||||
{
|
{
|
||||||
return medAlert;
|
return medAlert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String [] getHighAlert()
|
public String[] getHighAlert()
|
||||||
{
|
{
|
||||||
return highAlert;
|
return highAlert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String [] getWarning()
|
public String[] getWarning()
|
||||||
{
|
{
|
||||||
return warning;
|
return warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBanReason()
|
public String getBanReason()
|
||||||
{
|
{
|
||||||
return banReason;
|
return banReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBanBroadcast()
|
public String getBanBroadcast()
|
||||||
{
|
{
|
||||||
return banBroadcast;
|
return banBroadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKickReason()
|
public String getKickReason()
|
||||||
{
|
{
|
||||||
return kickReason;
|
return kickReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKickBroadcast()
|
public String getKickBroadcast()
|
||||||
{
|
{
|
||||||
return kickBroadcast;
|
return kickBroadcast;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -45,6 +45,7 @@ public enum Permission
|
|||||||
CHECK_LONGREACH,
|
CHECK_LONGREACH,
|
||||||
CHECK_FASTPROJECTILE,
|
CHECK_FASTPROJECTILE,
|
||||||
CHECK_ITEMSPAM,
|
CHECK_ITEMSPAM,
|
||||||
|
CHECK_INTERACTION,
|
||||||
|
|
||||||
/* System Nodes */
|
/* System Nodes */
|
||||||
SYSTEM_LOG,
|
SYSTEM_LOG,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -31,41 +31,43 @@ 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 PlayerManager pmr = Anticheat.getManager().getPlayerManager();
|
private static PlayerManager pmr = Anticheat.getManager().getPlayerManager();
|
||||||
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)
|
*/
|
||||||
|
public static void activateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
chk.activateCheck(type);
|
chk.activateCheck(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop running a certain check
|
* Stop running a certain check
|
||||||
*
|
*
|
||||||
* @param type Check to stop watching for
|
* @param type
|
||||||
|
* Check to stop watching for
|
||||||
*/
|
*/
|
||||||
public static void deactivateCheck(CheckType type)
|
public static void deactivateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
chk.deactivateCheck(type);
|
chk.deactivateCheck(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a check is currently being watched for
|
* Find out if a check is currently being watched for
|
||||||
*
|
*
|
||||||
* @param type Type to check
|
* @param type
|
||||||
|
* Type to check
|
||||||
* @return true if plugin is watching for this check
|
* @return true if plugin is watching for this check
|
||||||
*/
|
*/
|
||||||
public static boolean isActive(CheckType type)
|
public static boolean isActive(CheckType type)
|
||||||
{
|
{
|
||||||
return chk.isActive(type);
|
return chk.isActive(type);
|
||||||
@@ -73,10 +75,12 @@ public class AnticheatAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow a player to skip a certain check
|
* Allow a player to skip a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to stop watching
|
* @param player
|
||||||
* @param type Check to stop watching for
|
* Player to stop watching
|
||||||
*/
|
* @param type
|
||||||
|
* Check to stop watching for
|
||||||
|
*/
|
||||||
public static void exemptPlayer(Player player, CheckType type)
|
public static void exemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
chk.exemptPlayer(player, type);
|
chk.exemptPlayer(player, type);
|
||||||
@@ -84,50 +88,61 @@ public class AnticheatAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop allowing a player to skip a certain check
|
* Stop allowing a player to skip a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to start watching
|
* @param player
|
||||||
* @param type Check to start watching for
|
* Player to start watching
|
||||||
*/
|
* @param type
|
||||||
|
* Check to start watching for
|
||||||
|
*/
|
||||||
public static void unexemptPlayer(Player player, CheckType type)
|
public static void unexemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
chk.unexemptPlayer(player, type);
|
chk.unexemptPlayer(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a player is currently exempt from a certain check
|
* Find out if a player is currently exempt from a certain check
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player
|
||||||
* @param type Type to check
|
* Player to check
|
||||||
|
* @param type
|
||||||
|
* Type to check
|
||||||
* @return true if plugin is ignoring this check on this player
|
* @return true if plugin is ignoring this check on this player
|
||||||
*/
|
*/
|
||||||
public static boolean isExempt(Player player, CheckType type)
|
public static boolean isExempt(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return chk.isExempt(player, type);
|
return chk.isExempt(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 check will occur for a player. This checks if they are
|
||||||
*
|
* being tracked, the check is active, the player isn't exempt from the
|
||||||
* @param player Player to check
|
* check, and the player doesn't have override permission.
|
||||||
* @param type Type to check
|
*
|
||||||
* @return true if plugin will check this player, and that all things allow it to happen.
|
* @param player
|
||||||
*/
|
* Player to check
|
||||||
|
* @param type
|
||||||
|
* Type to check
|
||||||
|
* @return true if plugin will check this player, and that all things allow
|
||||||
|
* it to happen.
|
||||||
|
*/
|
||||||
public boolean willCheck(Player player, CheckType type)
|
public boolean willCheck(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return chk.willCheck(player, type);
|
return chk.willCheck(player, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//PlayerManager API
|
//PlayerManager API
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a player's integer hack level (0-19 = Low, 20-49 = Medium, 50-60 = High)
|
* Get a player's integer hack level (0-19 = Low, 20-49 = Medium, 50-60 =
|
||||||
*
|
* High)
|
||||||
* @param player Player to check
|
*
|
||||||
|
* @param player
|
||||||
|
* Player to check
|
||||||
* @return player's hack level
|
* @return player's hack level
|
||||||
*/
|
*/
|
||||||
public static int getLevel(Player player)
|
public static int getLevel(Player player)
|
||||||
{
|
{
|
||||||
if(!pmr.hasLevel(player))
|
if (!pmr.hasLevel(player))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -136,10 +151,12 @@ public class AnticheatAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a player's hack level (Min = 0, Max = 60)
|
* Set a player's hack level (Min = 0, Max = 60)
|
||||||
*
|
*
|
||||||
* @param player Player to set
|
* @param player
|
||||||
* @param level Level to set to
|
* Player to set
|
||||||
*/
|
* @param level
|
||||||
|
* Level to set to
|
||||||
|
*/
|
||||||
public static void setLevel(Player player, int level)
|
public static void setLevel(Player player, int level)
|
||||||
{
|
{
|
||||||
pmr.setLevel(player, level);
|
pmr.setLevel(player, level);
|
||||||
@@ -149,14 +166,15 @@ public class AnticheatAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find out if a player is detected as using xray hacks (on any ore)
|
* Find out if a player is detected as using xray hacks (on any ore)
|
||||||
*
|
*
|
||||||
* @param player Player to check
|
* @param player
|
||||||
|
* Player to check
|
||||||
* @return true if the player has any xray anomalies.
|
* @return true if the player has any xray anomalies.
|
||||||
*/
|
*/
|
||||||
public static boolean isXrayer(Player player)
|
public static boolean isXrayer(Player player)
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if (xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
if (xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -164,13 +182,13 @@ public class AnticheatAPI
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Advanced Users Only API.
|
//Advanced Users Only API.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get access to all the other managers, advanced users ONLY
|
* Get access to all the other managers, advanced users ONLY
|
||||||
*
|
*
|
||||||
* @return the AntiCheat Manager
|
* @return the AntiCheat Manager
|
||||||
*/
|
*/
|
||||||
public static AnticheatManager getManager()
|
public static AnticheatManager getManager()
|
||||||
{
|
{
|
||||||
return Anticheat.getManager();
|
return Anticheat.getManager();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -31,87 +31,87 @@ 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 Anticheat plugin = getPlugin();
|
private final Anticheat plugin = getPlugin();
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
public void onBlockDamage(BlockDamageEvent event)
|
||||||
{
|
{
|
||||||
if(event.getInstaBreak())
|
if (event.getInstaBreak())
|
||||||
{
|
{
|
||||||
backend.logInstantBreak(event.getPlayer());
|
backend.logInstantBreak(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if(player != null && checkManager.willCheck(player, CheckType.FAST_PLACE))
|
if (player != null && checkManager.willCheck(player, CheckType.FAST_PLACE))
|
||||||
{
|
{
|
||||||
if(backend.checkFastPlace(player))
|
if (backend.checkFastPlace(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to place a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_PLACE);
|
log("tried to place a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_PLACE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
backend.logBlockPlace(player);
|
backend.logBlockPlace(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Block block = event.getBlock();
|
final Block block = event.getBlock();
|
||||||
boolean noHack = true;
|
boolean noHack = true;
|
||||||
if(player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
if (checkManager.willCheck(player, CheckType.NO_SWING))
|
||||||
{
|
{
|
||||||
if(backend.checkSwing(player,block))
|
if (backend.checkSwing(player, block))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to break a block of "+block.getType().name()+" without swinging their arm.",player,CheckType.NO_SWING);
|
log("tried to break a block of " + block.getType().name() + " without swinging their arm.", player, CheckType.NO_SWING);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.LONG_REACH))
|
if (checkManager.willCheck(player, CheckType.LONG_REACH))
|
||||||
{
|
{
|
||||||
Distance distance = new Distance(player.getLocation(),block.getLocation());
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
if(backend.checkLongReachBlock(player,distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
if (backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to break a block of "+block.getType().name()+" that was too far away.",player,CheckType.LONG_REACH);
|
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.FAST_BREAK) && !backend.isInstantBreakExempt(player))
|
if (checkManager.willCheck(player, CheckType.FAST_BREAK) && !backend.isInstantBreakExempt(player))
|
||||||
{
|
{
|
||||||
if(backend.checkFastBreak(player,block))
|
if (backend.checkFastBreak(player, block))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
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() + " too fast.", player, CheckType.FAST_BREAK);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
backend.checkSwing(player,block);
|
backend.checkSwing(player, block);
|
||||||
}
|
}
|
||||||
}, 2L);
|
}, 2L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(noHack)
|
if (noHack)
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -27,132 +27,131 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.*;
|
||||||
|
|
||||||
|
public class EntityListener extends EventListener
|
||||||
public class EntityListener extends EventListener
|
{
|
||||||
{
|
|
||||||
private final Backend backend = getBackend();
|
private final Backend backend = getBackend();
|
||||||
private final CheckManager checkManager = getCheckManager();
|
private final CheckManager checkManager = getCheckManager();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityShootBow(EntityShootBowEvent event)
|
public void onEntityShootBow(EntityShootBowEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEntity() instanceof Player)
|
if (event.getEntity() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player)event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_BOW))
|
if (checkManager.willCheck(player, CheckType.FAST_BOW))
|
||||||
{
|
{
|
||||||
if(backend.justWoundUp(player))
|
if (backend.justWoundUp(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to fire a bow too fast.",player,CheckType.FAST_BOW);
|
log("tried to fire a bow too fast.", player, CheckType.FAST_BOW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
||||||
{
|
{
|
||||||
Player player = (Player)event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_HEAL))
|
if (checkManager.willCheck(player, CheckType.FAST_HEAL))
|
||||||
{
|
{
|
||||||
if(backend.justHealed(player))
|
if (backend.justHealed(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to heal too fast.",player,CheckType.FAST_HEAL);
|
log("tried to heal too fast.", player, CheckType.FAST_HEAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEntity() instanceof Player)
|
if (event.getEntity() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player)event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_EAT))
|
if (checkManager.willCheck(player, CheckType.FAST_EAT))
|
||||||
{
|
{
|
||||||
if(backend.justStartedEating(player))
|
if (backend.justStartedEating(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to eat too fast.",player,CheckType.FAST_EAT);
|
log("tried to eat too fast.", player, CheckType.FAST_EAT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
boolean noHack = true;
|
boolean noHack = true;
|
||||||
if (event instanceof EntityDamageByEntityEvent)
|
if (event instanceof EntityDamageByEntityEvent)
|
||||||
{
|
{
|
||||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||||
if(event.getEntity() instanceof Player)
|
if (event.getEntity() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player)event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
if (e.getDamager() instanceof Player)
|
if (e.getDamager() instanceof Player)
|
||||||
{
|
{
|
||||||
Player p = (Player)e.getDamager();
|
Player p = (Player) e.getDamager();
|
||||||
backend.logDamage(p);
|
backend.logDamage(p);
|
||||||
backend.logDamage(player);
|
backend.logDamage(player);
|
||||||
if(checkManager.willCheck(p, CheckType.LONG_REACH))
|
if (checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||||
{
|
{
|
||||||
Distance distance = new Distance(player.getLocation(),p.getLocation());
|
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
||||||
if(backend.checkLongReachDamage(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
if (backend.checkLongReachDamage(distance.getXDifference(), distance.getYDifference(), distance.getZDifference()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to damage a player too far away from them.",p,CheckType.LONG_REACH);
|
log("tried to damage a player too far away from them.", p, CheckType.LONG_REACH);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
backend.logDamage(player);
|
backend.logDamage(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(e.getDamager() instanceof Player)
|
if (e.getDamager() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player) e.getDamager();
|
Player player = (Player) e.getDamager();
|
||||||
if(checkManager.willCheck(player, CheckType.FORCEFIELD))
|
if (checkManager.willCheck(player, CheckType.FORCEFIELD))
|
||||||
{
|
{
|
||||||
if(backend.justSprinted(player))
|
if (backend.justSprinted(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to sprint & damage too fast.",player,CheckType.FORCEFIELD);
|
log("tried to sprint & damage too fast.", player, CheckType.FORCEFIELD);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
if (checkManager.willCheck(player, CheckType.NO_SWING))
|
||||||
{
|
{
|
||||||
if(!backend.justAnimated(player))
|
if (!backend.justAnimated(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to damage an entity without swinging their arm.",player,CheckType.NO_SWING);
|
log("tried to damage an entity without swinging their arm.", player, CheckType.NO_SWING);
|
||||||
noHack = false;
|
noHack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(noHack)
|
if (noHack)
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,100 +26,101 @@ 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 PlayerManager PLAYER_MANAGER = Anticheat.getManager().getPlayerManager();
|
private static final PlayerManager PLAYER_MANAGER = Anticheat.getManager().getPlayerManager();
|
||||||
|
|
||||||
public void log(String message,Player player, CheckType type)
|
public void log(String message, Player player, CheckType type)
|
||||||
{
|
{
|
||||||
Anticheat.getManager().log(player.getName()+" "+message);
|
Anticheat.getManager().log(player.getName() + " " + message);
|
||||||
PLAYER_MANAGER.increaseLevel(player);
|
PLAYER_MANAGER.increaseLevel(player);
|
||||||
removeDecrease(player);
|
removeDecrease(player);
|
||||||
logCheat(type,player);
|
logCheat(type, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logCheat(CheckType type,Player player)
|
private void logCheat(CheckType type, Player player)
|
||||||
{
|
{
|
||||||
USAGE_LIST.put(type, getCheats(type)+1);
|
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||||
type.logUse(player);
|
type.logUse(player);
|
||||||
if(Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||||
{
|
{
|
||||||
Anticheat.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks.");
|
Anticheat.getManager().fileLog(player.getName() + " has triggered multiple " + type + " checks.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCheck(CheckType type)
|
public void resetCheck(CheckType type)
|
||||||
{
|
{
|
||||||
USAGE_LIST.put(type, 0);
|
USAGE_LIST.put(type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCheats(CheckType type)
|
public int getCheats(CheckType type)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if(USAGE_LIST.get(type) != null)
|
if (USAGE_LIST.get(type) != null)
|
||||||
{
|
{
|
||||||
x = USAGE_LIST.get(type);
|
x = USAGE_LIST.get(type);
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeDecrease(Player player)
|
private static void removeDecrease(Player player)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if(DECREASE_LIST.get(player.getName()) != null)
|
if (DECREASE_LIST.get(player.getName()) != null)
|
||||||
{
|
{
|
||||||
x = DECREASE_LIST.get(player.getName());
|
x = DECREASE_LIST.get(player.getName());
|
||||||
x-=2;
|
x -= 2;
|
||||||
if(x < 0)
|
if (x < 0)
|
||||||
{
|
{
|
||||||
x = 0;
|
x = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DECREASE_LIST.put(player.getName(), x);
|
DECREASE_LIST.put(player.getName(), x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void decrease(Player player)
|
public static void decrease(Player player)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
if(DECREASE_LIST.get(player.getName()) != null)
|
if (DECREASE_LIST.get(player.getName()) != null)
|
||||||
{
|
{
|
||||||
x = DECREASE_LIST.get(player.getName());
|
x = DECREASE_LIST.get(player.getName());
|
||||||
}
|
}
|
||||||
x+=1;
|
x += 1;
|
||||||
DECREASE_LIST.put(player.getName(), x);
|
DECREASE_LIST.put(player.getName(), x);
|
||||||
if(x >= 10)
|
if (x >= 10)
|
||||||
{
|
{
|
||||||
PLAYER_MANAGER.decreaseLevel(player);
|
PLAYER_MANAGER.decreaseLevel(player);
|
||||||
DECREASE_LIST.put(player.getName(),0);
|
DECREASE_LIST.put(player.getName(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckManager getCheckManager()
|
public static CheckManager getCheckManager()
|
||||||
{
|
{
|
||||||
return CHECK_MANAGER;
|
return CHECK_MANAGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnticheatManager getManager()
|
public static AnticheatManager getManager()
|
||||||
{
|
{
|
||||||
return Anticheat.getManager();
|
return Anticheat.getManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Backend getBackend()
|
public static Backend getBackend()
|
||||||
{
|
{
|
||||||
return BACKEND;
|
return BACKEND;
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerManager getPlayerManager() {
|
|
||||||
return PLAYER_MANAGER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerManager getPlayerManager()
|
||||||
|
{
|
||||||
|
return PLAYER_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
public static Anticheat getPlugin()
|
public static Anticheat getPlugin()
|
||||||
{
|
{
|
||||||
return PLUGIN;
|
return PLUGIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -34,170 +34,172 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
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();
|
Player player = event.getPlayer();
|
||||||
if(checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam())
|
if (checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam())
|
||||||
{
|
{
|
||||||
backend.logChat(player);
|
backend.logChat(player);
|
||||||
if(backend.checkSpam(player, event.getMessage()))
|
if (backend.checkSpam(player, event.getMessage()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED+"Please do not spam.");
|
player.sendMessage(ChatColor.RED + "Please do not spam.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||||
{
|
{
|
||||||
if(event.getEntity().getShooter() instanceof Player)
|
if (event.getEntity().getShooter() instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player)event.getEntity().getShooter();
|
Player player = (Player) event.getEntity().getShooter();
|
||||||
if(checkManager.willCheck(player, CheckType.FAST_PROJECTILE))
|
if (checkManager.willCheck(player, CheckType.FAST_PROJECTILE))
|
||||||
{
|
{
|
||||||
backend.logProjectile(player,this);
|
backend.logProjectile(player, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
if(event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN)
|
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN)
|
||||||
{
|
{
|
||||||
backend.logTeleport(event.getPlayer());
|
backend.logTeleport(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event)
|
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event)
|
||||||
{
|
{
|
||||||
backend.logTeleport(event.getPlayer());
|
backend.logTeleport(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
|
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
|
||||||
{
|
{
|
||||||
if(event.isSneaking())
|
if (event.isSneaking())
|
||||||
{
|
{
|
||||||
backend.logToggleSneak(event.getPlayer());
|
backend.logToggleSneak(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerVelocity(PlayerVelocityEvent event)
|
public void onPlayerVelocity(PlayerVelocityEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
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
|
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))
|
if (backend.justVelocity(player))
|
||||||
{
|
{
|
||||||
if(backend.extendVelocityTime(player))
|
if (backend.extendVelocityTime(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return; // don't log it lol.
|
return; // don't log it lol.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
backend.logVelocity(player);
|
backend.logVelocity(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam())
|
if (checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam())
|
||||||
{
|
{
|
||||||
backend.logChat(player);
|
backend.logChat(player);
|
||||||
if(backend.checkSpam(player, event.getMessage()))
|
if (backend.checkSpam(player, event.getMessage()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.sendMessage(ChatColor.RED+"Please do not spam.");
|
player.sendMessage(ChatColor.RED + "Please do not spam.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
backend.clearChatLevel(event.getPlayer());
|
backend.clearChatLevel(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
|
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(checkManager.willCheck(player, CheckType.SPRINT))
|
if (checkManager.willCheck(player, CheckType.SPRINT))
|
||||||
{
|
{
|
||||||
if(backend.checkSprint(event))
|
if (backend.checkSprint(event))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
log("tried to sprint while hungry.",player,CheckType.SPRINT);
|
log("tried to sprint while hungry.", player, CheckType.SPRINT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
decrease(player);
|
decrease(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlayerInventory inv = player.getInventory();
|
PlayerInventory inv = player.getInventory();
|
||||||
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
{
|
{
|
||||||
Material m = inv.getItemInHand().getType();
|
Material m = inv.getItemInHand().getType();
|
||||||
if(m == Material.BOW)
|
if (m == Material.BOW)
|
||||||
{
|
{
|
||||||
backend.logBowWindUp(player);
|
backend.logBowWindUp(player);
|
||||||
}
|
}
|
||||||
else if(Utilities.isFood(m))
|
else if (Utilities.isFood(m))
|
||||||
{
|
{
|
||||||
backend.logEatingStart(player);
|
backend.logEatingStart(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(event.getClickedBlock() != null)
|
if (event.getClickedBlock() != null)
|
||||||
{
|
{
|
||||||
Distance distance = new Distance(player.getLocation(), event.getClickedBlock().getLocation());
|
Distance distance = new Distance(player.getLocation(), event.getClickedBlock().getLocation());
|
||||||
backend.checkLongReachBlock(player,distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Interactions Check */
|
/* Interactions Check */
|
||||||
|
//TODO: Extend this into block place/break and if working, change to visuals check.
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
if(block != null) {
|
||||||
{
|
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
||||||
// save load and actually call the backend check here.
|
{
|
||||||
if(backend.checkInteraction(player, block))
|
// save load and actually call the backend check here.
|
||||||
{
|
if(backend.checkInteraction(player, block))
|
||||||
event.setCancelled(true);
|
{
|
||||||
log("failed interaction check",player,CheckType.INTERACTION);
|
event.setCancelled(true);
|
||||||
}
|
log("failed interaction check",player,CheckType.INTERACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(checkManager.willCheck(player, CheckType.ITEM_SPAM))
|
if (checkManager.willCheck(player, CheckType.ITEM_SPAM))
|
||||||
{
|
{
|
||||||
if(backend.justDroppedItem(player))
|
if (backend.justDroppedItem(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@@ -206,51 +208,51 @@ public class PlayerListener extends EventListener
|
|||||||
backend.logDroppedItem(player);
|
backend.logDroppedItem(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerEnterBed(PlayerBedEnterEvent event)
|
public void onPlayerEnterBed(PlayerBedEnterEvent event)
|
||||||
{
|
{
|
||||||
backend.logEnterExit(event.getPlayer());
|
backend.logEnterExit(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerExitBed(PlayerBedLeaveEvent event)
|
public void onPlayerExitBed(PlayerBedLeaveEvent event)
|
||||||
{
|
{
|
||||||
backend.logEnterExit(event.getPlayer());
|
backend.logEnterExit(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerAnimation(PlayerAnimationEvent event)
|
public void onPlayerAnimation(PlayerAnimationEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
backend.logAnimation(player);
|
backend.logAnimation(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String section = "\u00a7";
|
String section = "\u00a7";
|
||||||
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
if (checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
||||||
{
|
{
|
||||||
player.sendMessage(section+"f "+section+"f "+section+"1 "+section+"0 "+section+"2 "+section+"4");
|
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
if (checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
||||||
{
|
{
|
||||||
player.sendMessage(section+"f "+section+"f "+section+"2 "+section+"0 "+section+"4 "+section+"8");
|
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
if (checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
||||||
{
|
{
|
||||||
player.sendMessage(section+"f "+section+"f "+section+"4 "+section+"0 "+section+"9 "+section+"6");
|
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||||
}
|
}
|
||||||
backend.logJoin(event.getPlayer());
|
backend.logJoin(event.getPlayer());
|
||||||
if(!getPlayerManager().hasLevel(player))
|
if (!getPlayerManager().hasLevel(player))
|
||||||
{
|
{
|
||||||
getPlayerManager().setLevel(player, getManager().getConfiguration().getLevel(player.getName()));
|
getPlayerManager().setLevel(player, getManager().getConfiguration().getLevel(player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void checkExploit(PlayerMoveEvent event)
|
public void checkExploit(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
@@ -261,69 +263,70 @@ public class PlayerListener extends EventListener
|
|||||||
double x = distance.getXDifference();
|
double x = distance.getXDifference();
|
||||||
double y = distance.getYDifference();
|
double y = distance.getYDifference();
|
||||||
double z = distance.getZDifference();
|
double z = distance.getZDifference();
|
||||||
backend.logAscension(player,from.getY(),to.getY());
|
backend.logAscension(player, from.getY(), to.getY());
|
||||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
||||||
{
|
{
|
||||||
from.setX(from.getX()-1);
|
from.setX(from.getX() - 1);
|
||||||
from.setY(from.getY()-1);
|
from.setY(from.getY() - 1);
|
||||||
from.setZ(from.getZ()-1);
|
from.setZ(from.getZ() - 1);
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
Block lower = player.getWorld().getHighestBlockAt(from);
|
Block lower = player.getWorld().getHighestBlockAt(from);
|
||||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(), lower.getLocation().getY() + 2, lower.getLocation().getZ()));
|
||||||
log("tried to fly.",player,CheckType.FLY);
|
log("tried to fly.", player, CheckType.FLY);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player,from.getY(),to.getY())))
|
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player, from.getY(), to.getY())))
|
||||||
{
|
{
|
||||||
Block lower = player.getWorld().getHighestBlockAt(player.getLocation());
|
Block lower = player.getWorld().getHighestBlockAt(player.getLocation());
|
||||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(), lower.getLocation().getY() + 2, lower.getLocation().getZ()));
|
||||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
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 (event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
|
||||||
{
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
log("tried to ascend too fast.",player,CheckType.SPEED);
|
log("tried to ascend too fast.", player, CheckType.SPEED);
|
||||||
}
|
|
||||||
if(backend.checkXZSpeed(player,x,z))
|
|
||||||
{
|
|
||||||
event.setTo(from);
|
|
||||||
log("tried to move too fast.",player,CheckType.SPEED);
|
|
||||||
}
|
}
|
||||||
}
|
if (backend.checkXZSpeed(player, x, z))
|
||||||
if(checkManager.willCheck(player, CheckType.NOFALL) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && event.getFrom().getY() > event.getTo().getY() && backend.checkNoFall(player, y))
|
{
|
||||||
{
|
event.setTo(from);
|
||||||
|
log("tried to move too fast.", player, CheckType.SPEED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (checkManager.willCheck(player, CheckType.NOFALL) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && event.getFrom().getY() > event.getTo().getY() && backend.checkNoFall(player, y))
|
||||||
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
log("tried avoid fall damage.",player,CheckType.NOFALL);
|
log("tried avoid fall damage.", player, CheckType.NOFALL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void checkSpeed(PlayerMoveEvent event)
|
public void checkSpeed(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
if(event.getTo() != event.getFrom())
|
if (event.getTo() != event.getFrom())
|
||||||
{
|
{
|
||||||
Distance distance = new Distance(from, to);
|
Distance distance = new Distance(from, to);
|
||||||
double x = distance.getXDifference();
|
double x = distance.getXDifference();
|
||||||
double y = distance.getYDifference();
|
double y = distance.getYDifference();
|
||||||
double z = distance.getZDifference();
|
double z = distance.getZDifference();
|
||||||
if(checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player,x,z))
|
if (checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player, x, z))
|
||||||
{
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
log("tried to walk on water.", player, CheckType.WATER_WALK);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player,x,z))
|
if (checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player, x, z))
|
||||||
{
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
player.setSneaking(false);
|
player.setSneaking(false);
|
||||||
log("tried to sneak too fast.",player,CheckType.SNEAK);
|
log("tried to sneak too fast.", player, CheckType.SNEAK);
|
||||||
}
|
}
|
||||||
if(checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
if (checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
||||||
{
|
{
|
||||||
event.setTo(from);
|
event.setTo(from);
|
||||||
log("tried to climb a wall.",player,CheckType.SPIDER);
|
log("tried to climb a wall.", player, CheckType.SPIDER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -24,25 +24,25 @@ 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)
|
if (event.getEntered() instanceof Player)
|
||||||
{
|
{
|
||||||
backend.logEnterExit((Player)event.getEntered());
|
backend.logEnterExit((Player) event.getEntered());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onVehicleExit(VehicleExitEvent event)
|
public void onVehicleExit(VehicleExitEvent event)
|
||||||
{
|
{
|
||||||
if(event.getExited() instanceof Player)
|
if (event.getExited() instanceof Player)
|
||||||
{
|
{
|
||||||
backend.logEnterExit((Player)event.getExited());
|
backend.logEnterExit((Player) event.getExited());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -31,7 +31,7 @@ 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;
|
||||||
@@ -42,7 +42,7 @@ public class AnticheatManager
|
|||||||
private static Logger LOGGER, FILE_LOGGER;
|
private static Logger LOGGER, FILE_LOGGER;
|
||||||
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)
|
public AnticheatManager(Anticheat instance)
|
||||||
{
|
{
|
||||||
plugin = instance;
|
plugin = instance;
|
||||||
@@ -54,68 +54,71 @@ public class AnticheatManager
|
|||||||
playerManager = new PlayerManager(this);
|
playerManager = new PlayerManager(this);
|
||||||
checkManager = new CheckManager(this);
|
checkManager = new CheckManager(this);
|
||||||
backend = new Backend(this);
|
backend = new Backend(this);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File file = new File(plugin.getDataFolder()+"/log");
|
File file = new File(plugin.getDataFolder() + "/log");
|
||||||
if(!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
file.mkdir();
|
file.mkdir();
|
||||||
}
|
}
|
||||||
fileHandler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log",true);
|
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
||||||
fileHandler.setFormatter(new FileFormatter());
|
fileHandler.setFormatter(new FileFormatter());
|
||||||
} catch (Exception ex) {
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
LOGGER.log(Level.SEVERE, null, ex);
|
LOGGER.log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
FILE_LOGGER.setUseParentHandlers(false);
|
FILE_LOGGER.setUseParentHandlers(false);
|
||||||
FILE_LOGGER.addHandler(fileHandler);
|
FILE_LOGGER.addHandler(fileHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String message)
|
public void log(String message)
|
||||||
{
|
{
|
||||||
if(getConfiguration().logConsole())
|
if (getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
LOGGER.info("[AntiCheat] "+ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
LOGGER.info("[AntiCheat] " + ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||||
}
|
}
|
||||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
if (getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||||
{
|
{
|
||||||
fileLog(ChatColor.stripColor(message));
|
fileLog(ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fileLog(String message)
|
public void fileLog(String message)
|
||||||
{
|
{
|
||||||
FILE_LOGGER.info(message);
|
FILE_LOGGER.info(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Anticheat getPlugin()
|
public Anticheat getPlugin()
|
||||||
{
|
{
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration getConfiguration()
|
public Configuration getConfiguration()
|
||||||
{
|
{
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public XRayTracker getXRayTracker()
|
public XRayTracker getXRayTracker()
|
||||||
{
|
{
|
||||||
return xrayTracker;
|
return xrayTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerManager getPlayerManager()
|
public PlayerManager getPlayerManager()
|
||||||
{
|
{
|
||||||
return playerManager;
|
return playerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckManager getCheckManager()
|
public CheckManager getCheckManager()
|
||||||
{
|
{
|
||||||
return checkManager;
|
return checkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Backend getBackend()
|
public Backend getBackend()
|
||||||
{
|
{
|
||||||
return backend;
|
return backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void close()
|
public static void close()
|
||||||
{
|
{
|
||||||
fileHandler.close();
|
fileHandler.close();
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -26,79 +26,77 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
* The manager that AntiCheat will check with to see if it should watch certain
|
||||||
|
* checks and certain players.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CheckManager
|
public class CheckManager
|
||||||
{
|
{
|
||||||
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 Multimap<String,CheckType> exemptList = ArrayListMultimap.create();
|
private static Multimap<String, CheckType> exemptList = ArrayListMultimap.create();
|
||||||
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)
|
public void activateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
if(checkIgnoreList.contains(type))
|
if (checkIgnoreList.contains(type))
|
||||||
{
|
{
|
||||||
manager.log("The "+type.toString()+" check was activated.");
|
manager.log("The " + type.toString() + " check was activated.");
|
||||||
checkIgnoreList.remove(type);
|
checkIgnoreList.remove(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivateCheck(CheckType type)
|
public void deactivateCheck(CheckType type)
|
||||||
{
|
{
|
||||||
manager.log("The "+type.toString()+" check was deactivated.");
|
manager.log("The " + type.toString() + " check was deactivated.");
|
||||||
checkIgnoreList.add(type);
|
checkIgnoreList.add(type);
|
||||||
disabled++;
|
disabled++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive(CheckType type)
|
public boolean isActive(CheckType type)
|
||||||
{
|
{
|
||||||
return !checkIgnoreList.contains(type);
|
return !checkIgnoreList.contains(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exemptPlayer(Player player, CheckType type)
|
public void exemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
manager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
|
manager.log(player.getName() + " was exempted from the " + type.toString() + " check.");
|
||||||
exemptList.put(player.getName(), type);
|
exemptList.put(player.getName(), type);
|
||||||
exempt++;
|
exempt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unexemptPlayer(Player player, CheckType type)
|
public void unexemptPlayer(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
if(exemptList.containsEntry(player.getName(), type))
|
if (exemptList.containsEntry(player.getName(), type))
|
||||||
{
|
{
|
||||||
manager.log(player.getName()+" was re-added to the "+type.toString()+" check.");
|
manager.log(player.getName() + " was re-added to the " + type.toString() + " check.");
|
||||||
exemptList.remove(player.getName(), type);
|
exemptList.remove(player.getName(), type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExempt(Player player, CheckType type)
|
public boolean isExempt(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return exemptList.containsEntry(player.getName(), type);
|
return exemptList.containsEntry(player.getName(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean willCheck(Player player, CheckType type)
|
public boolean willCheck(Player player, CheckType type)
|
||||||
{
|
{
|
||||||
return isActive(type)
|
return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) && !type.checkPermission(player);
|
||||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
|
||||||
&& !isExempt(player, type)
|
|
||||||
&& !type.checkPermission(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getExempt()
|
public int getExempt()
|
||||||
{
|
{
|
||||||
int x = exempt;
|
int x = exempt;
|
||||||
exempt = 0;
|
exempt = 0;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDisabled()
|
public int getDisabled()
|
||||||
{
|
{
|
||||||
int x = disabled;
|
int x = disabled;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -23,14 +23,12 @@ import java.util.Map;
|
|||||||
import net.h31ix.anticheat.Permission;
|
import net.h31ix.anticheat.Permission;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* All the types of checks and their corresponding permission nodes.
|
* All the types of checks and their corresponding permission nodes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public enum CheckType
|
||||||
public enum CheckType
|
|
||||||
{
|
{
|
||||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
||||||
@@ -44,6 +42,7 @@ public enum CheckType
|
|||||||
SPRINT(Permission.CHECK_SPRINT),
|
SPRINT(Permission.CHECK_SPRINT),
|
||||||
SNEAK(Permission.CHECK_SNEAK),
|
SNEAK(Permission.CHECK_SNEAK),
|
||||||
SPEED(Permission.CHECK_SPEED),
|
SPEED(Permission.CHECK_SPEED),
|
||||||
|
INTERACTION(Permission.CHECK_INTERACTION),
|
||||||
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),
|
||||||
@@ -54,53 +53,53 @@ public enum CheckType
|
|||||||
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);
|
||||||
|
|
||||||
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)
|
public boolean checkPermission(Player player)
|
||||||
{
|
{
|
||||||
return permission.get(player);
|
return permission.get(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logUse(Player player)
|
public void logUse(Player player)
|
||||||
{
|
{
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if(level.get(name) == null)
|
if (level.get(name) == null)
|
||||||
{
|
{
|
||||||
level.put(name, 1);
|
level.put(name, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int amount = level.get(name)+1;
|
int amount = level.get(name) + 1;
|
||||||
level.put(name, amount);
|
level.put(name, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearUse(Player player)
|
public void clearUse(Player player)
|
||||||
{
|
{
|
||||||
level.put(player.getName(), 0);
|
level.put(player.getName(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUses(Player player)
|
public int getUses(Player player)
|
||||||
{
|
{
|
||||||
int use = 0;
|
int use = 0;
|
||||||
if(level.get(player.getName()) != null)
|
if (level.get(player.getName()) != null)
|
||||||
{
|
{
|
||||||
use = level.get(player.getName());
|
use = level.get(player.getName());
|
||||||
}
|
}
|
||||||
return use;
|
return use;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName(CheckType type)
|
public static String getName(CheckType type)
|
||||||
{
|
{
|
||||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||||
chars[0] = Character.toUpperCase(chars[0]);
|
chars[0] = Character.toUpperCase(chars[0]);
|
||||||
return new String(chars);
|
return new String(chars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -22,47 +22,36 @@ 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;
|
l1 = to;
|
||||||
l2 = from;
|
l2 = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fromX()
|
public double fromY()
|
||||||
{
|
{
|
||||||
return l2.getX();
|
return l2.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fromY()
|
public double toY()
|
||||||
{
|
{
|
||||||
return l2.getY();
|
return l1.getY();
|
||||||
}
|
|
||||||
|
|
||||||
public double fromZ()
|
|
||||||
{
|
|
||||||
return l2.getZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double toY()
|
|
||||||
{
|
|
||||||
return l1.getY();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getXDifference()
|
public double getXDifference()
|
||||||
{
|
{
|
||||||
return Math.abs(l1.getX()-l2.getX());
|
return Math.abs(l1.getX() - l2.getX());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getZDifference()
|
public double getZDifference()
|
||||||
{
|
{
|
||||||
return Math.abs(l1.getZ()-l2.getZ());
|
return Math.abs(l1.getZ() - l2.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYDifference()
|
public double getYDifference()
|
||||||
{
|
{
|
||||||
return Math.abs(l1.getY()-l2.getY());
|
return Math.abs(l1.getY() - l2.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -29,151 +29,156 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The manager that AntiCheat will use to monitor player's hack levels and to execute events that the admin has set
|
* The manager that AntiCheat will use to monitor player's hack levels and to
|
||||||
|
* execute events that the admin has set
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PlayerManager
|
public class PlayerManager
|
||||||
{
|
{
|
||||||
|
|
||||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
private static Map<String, Integer> level = new HashMap<String, Integer>();
|
||||||
private static Configuration config = null;
|
private static Configuration config = null;
|
||||||
private static Language lang;
|
private static Language lang;
|
||||||
private static final int MED_THRESHOLD = 20;
|
private static final int MED_THRESHOLD = 20;
|
||||||
private static final int HIGH_THRESHOLD = 50;
|
private static final int HIGH_THRESHOLD = 50;
|
||||||
private static final int LEVEL_MAX = 60;
|
private static final int LEVEL_MAX = 60;
|
||||||
private static final int LEVEL_BOOST = 5;
|
private static final int LEVEL_BOOST = 5;
|
||||||
|
|
||||||
public PlayerManager(AnticheatManager instance) {
|
public PlayerManager(AnticheatManager instance)
|
||||||
config = instance.getConfiguration();
|
{
|
||||||
|
config = instance.getConfiguration();
|
||||||
lang = config.getLang();
|
lang = config.getLang();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reactMedium(Player player)
|
private static void reactMedium(Player player)
|
||||||
{
|
{
|
||||||
execute("Medium",player);
|
execute("Medium", player);
|
||||||
Utilities.alert(formatArray(lang.getMediumAlert(),player,ChatColor.YELLOW));
|
Utilities.alert(formatArray(lang.getMediumAlert(), player, ChatColor.YELLOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void reactHigh(Player player)
|
private static void reactHigh(Player player)
|
||||||
{
|
{
|
||||||
execute("High",player);
|
execute("High", player);
|
||||||
Utilities.alert(formatArray(lang.getHighAlert(),player,ChatColor.RED));
|
Utilities.alert(formatArray(lang.getHighAlert(), player, ChatColor.RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increaseLevel(Player player)
|
public void increaseLevel(Player player)
|
||||||
{
|
{
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
if(level.get(name) == null || level.get(name) == 0)
|
if (level.get(name) == null || level.get(name) == 0)
|
||||||
{
|
{
|
||||||
level.put(name,1);
|
level.put(name, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final int playerLevel = level.get(name);
|
final int playerLevel = level.get(name);
|
||||||
level.put(name, playerLevel+1);
|
level.put(name, playerLevel + 1);
|
||||||
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
|
if (playerLevel <= MED_THRESHOLD && playerLevel + 1 > MED_THRESHOLD && playerLevel + 1 <= HIGH_THRESHOLD)
|
||||||
{
|
{
|
||||||
reactMedium(player);
|
reactMedium(player);
|
||||||
}
|
}
|
||||||
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
|
else if (playerLevel <= HIGH_THRESHOLD && playerLevel + 1 > HIGH_THRESHOLD)
|
||||||
{
|
{
|
||||||
reactHigh(player);
|
reactHigh(player);
|
||||||
level.put(player.getName(), MED_THRESHOLD+LEVEL_BOOST);
|
level.put(player.getName(), MED_THRESHOLD + LEVEL_BOOST);
|
||||||
}
|
}
|
||||||
else if (playerLevel > LEVEL_MAX)
|
else if (playerLevel > LEVEL_MAX)
|
||||||
{
|
{
|
||||||
level.put(player.getName(), MED_THRESHOLD+LEVEL_BOOST);
|
level.put(player.getName(), MED_THRESHOLD + LEVEL_BOOST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decreaseLevel(Player player)
|
public void decreaseLevel(Player player)
|
||||||
{
|
{
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
if(level.get(name) != null && level.get(name) != 0)
|
if (level.get(name) != null && level.get(name) != 0)
|
||||||
{
|
{
|
||||||
int playerLevel = level.get(name)-1;
|
int playerLevel = level.get(name) - 1;
|
||||||
level.put(name, playerLevel);
|
level.put(name, playerLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLevel(Player player)
|
public int getLevel(Player player)
|
||||||
{
|
{
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
if(level.get(name) != null)
|
if (level.get(name) != null)
|
||||||
{
|
{
|
||||||
return level.get(name);
|
return level.get(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(Player player, int x)
|
public void setLevel(Player player, int x)
|
||||||
{
|
{
|
||||||
if(!(x > LEVEL_MAX && x < 0))
|
if (!(x > LEVEL_MAX && x < 0))
|
||||||
{
|
{
|
||||||
level.put(player.getName(), x);
|
level.put(player.getName(), x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasLevel(Player player)
|
public boolean hasLevel(Player player)
|
||||||
{
|
{
|
||||||
return level.containsKey(player.getName());
|
return level.containsKey(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(Player player)
|
public void reset(Player player)
|
||||||
{
|
{
|
||||||
level.put(player.getName(),0);
|
level.put(player.getName(), 0);
|
||||||
for(CheckType type : CheckType.values())
|
for (CheckType type : CheckType.values())
|
||||||
{
|
{
|
||||||
type.clearUse(player);
|
type.clearUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Integer> getLevels()
|
public Map<String, Integer> getLevels()
|
||||||
{
|
{
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void execute(String level, Player player)
|
private static void execute(String level, Player player)
|
||||||
{
|
{
|
||||||
String result = config.getResult(level);
|
String result = config.getResult(level);
|
||||||
if(result.startsWith("COMMAND["))
|
if (result.startsWith("COMMAND["))
|
||||||
{
|
{
|
||||||
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
|
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||||
}
|
|
||||||
else if(result.equalsIgnoreCase("KICK"))
|
|
||||||
{
|
|
||||||
player.kickPlayer(formatString(lang.getKickReason(),player,ChatColor.RED));
|
|
||||||
player.getServer().broadcastMessage(formatString(lang.getKickBroadcast(),player,ChatColor.RED));
|
|
||||||
}
|
}
|
||||||
else if(result.equalsIgnoreCase("WARN"))
|
else if (result.equalsIgnoreCase("KICK"))
|
||||||
{
|
{
|
||||||
String[] message = formatArray(lang.getWarning(),player,ChatColor.RED);
|
player.kickPlayer(formatString(lang.getKickReason(), player, ChatColor.RED));
|
||||||
for(String string : message)
|
player.getServer().broadcastMessage(formatString(lang.getKickBroadcast(), player, ChatColor.RED));
|
||||||
|
}
|
||||||
|
else if (result.equalsIgnoreCase("WARN"))
|
||||||
|
{
|
||||||
|
String[] message = formatArray(lang.getWarning(), player, ChatColor.RED);
|
||||||
|
for (String string : message)
|
||||||
{
|
{
|
||||||
player.sendMessage(string);
|
player.sendMessage(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(result.equalsIgnoreCase("BAN"))
|
else if (result.equalsIgnoreCase("BAN"))
|
||||||
{
|
{
|
||||||
player.setBanned(true);
|
player.setBanned(true);
|
||||||
player.kickPlayer(formatString(lang.getBanReason(),player,ChatColor.RED));
|
player.kickPlayer(formatString(lang.getBanReason(), player, ChatColor.RED));
|
||||||
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(),player,ChatColor.RED));
|
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(), player, ChatColor.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static String [] formatArray(String [] array, Player player, ChatColor color)
|
|
||||||
|
private static String[] formatArray(String[] array, Player player, ChatColor color)
|
||||||
{
|
{
|
||||||
for(int i=0;i<array.length;i++)
|
for (int i = 0; i < array.length; i++)
|
||||||
{
|
{
|
||||||
array[i] = formatString(array[i],player,color);
|
array[i] = formatString(array[i], player, color);
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String formatString(String string, Player player, ChatColor color)
|
private static String formatString(String string, Player player, ChatColor color)
|
||||||
{
|
{
|
||||||
return color+string.replaceAll("&player", ChatColor.WHITE+player.getName()+color);
|
return color + string.replaceAll("&player", ChatColor.WHITE + player.getName() + color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend.
|
* The metrics class obtains data about a plugin and submits statistics about it
|
||||||
|
* to the metrics backend.
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Public methods provided by this class:
|
* Public methods provided by this class:
|
||||||
@@ -52,7 +53,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
* void start(); <br/>
|
* void start(); <br/>
|
||||||
* </code>
|
* </code>
|
||||||
*/
|
*/
|
||||||
public class Metrics {
|
public class Metrics
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current revision number
|
* The current revision number
|
||||||
@@ -75,8 +77,8 @@ public class Metrics {
|
|||||||
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
|
* The separator to use for custom data. This MUST NOT change unless you are
|
||||||
* version of metrics and want to change it.
|
* hosting your own version of metrics and want to change it.
|
||||||
*/
|
*/
|
||||||
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||||
|
|
||||||
@@ -96,7 +98,8 @@ public class Metrics {
|
|||||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default graph, used for addCustomData when you don't want a specific graph
|
* The default graph, used for addCustomData when you don't want a specific
|
||||||
|
* graph
|
||||||
*/
|
*/
|
||||||
private final Graph defaultGraph = new Graph("Default");
|
private final Graph defaultGraph = new Graph("Default");
|
||||||
|
|
||||||
@@ -110,8 +113,10 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private final String guid;
|
private final String guid;
|
||||||
|
|
||||||
public Metrics(Plugin plugin) throws IOException {
|
public Metrics(Plugin plugin) throws IOException
|
||||||
if (plugin == null) {
|
{
|
||||||
|
if (plugin == null)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Plugin cannot be null");
|
throw new IllegalArgumentException("Plugin cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +131,8 @@ public class Metrics {
|
|||||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||||
|
|
||||||
// Do we need to create the file?
|
// Do we need to create the file?
|
||||||
if (configuration.get("guid", null) == null) {
|
if (configuration.get("guid", null) == null)
|
||||||
|
{
|
||||||
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
||||||
configuration.save(file);
|
configuration.save(file);
|
||||||
}
|
}
|
||||||
@@ -136,14 +142,18 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs
|
* Construct and create a Graph that can be used to separate specific
|
||||||
* on the metrics website. Plotters can be added to the graph object returned.
|
* plotters to their own graphs on the metrics website. Plotters can be
|
||||||
*
|
* added to the graph object returned.
|
||||||
|
*
|
||||||
* @param name
|
* @param name
|
||||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
* @return Graph object created. Will never return NULL under normal
|
||||||
|
* circumstances unless bad parameters are given
|
||||||
*/
|
*/
|
||||||
public Graph createGraph(String name) {
|
public Graph createGraph(String name)
|
||||||
if (name == null) {
|
{
|
||||||
|
if (name == null)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Graph name cannot be null");
|
throw new IllegalArgumentException("Graph name cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,11 +169,13 @@ public class Metrics {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a custom data plotter to the default graph
|
* Adds a custom data plotter to the default graph
|
||||||
*
|
*
|
||||||
* @param plotter
|
* @param plotter
|
||||||
*/
|
*/
|
||||||
public void addCustomData(Plotter plotter) {
|
public void addCustomData(Plotter plotter)
|
||||||
if (plotter == null) {
|
{
|
||||||
|
if (plotter == null)
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("Plotter cannot be null");
|
throw new IllegalArgumentException("Plotter cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,23 +187,29 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send
|
* Start measuring statistics. This will immediately create an async
|
||||||
* the initial data to the metrics backend, and then after that it will post in increments of
|
* repeating task as the plugin and send the initial data to the metrics
|
||||||
* PING_INTERVAL * 1200 ticks.
|
* backend, and then after that it will post in increments of PING_INTERVAL
|
||||||
|
* * 1200 ticks.
|
||||||
*/
|
*/
|
||||||
public void start() {
|
public void start()
|
||||||
|
{
|
||||||
// Did we opt out?
|
// Did we opt out?
|
||||||
if (configuration.getBoolean("opt-out", false)) {
|
if (configuration.getBoolean("opt-out", false))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Begin hitting the server with glorious data
|
// Begin hitting the server with glorious data
|
||||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
|
||||||
|
{
|
||||||
private boolean firstPost = true;
|
private boolean firstPost = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||||
// it is not a interval ping, so it evaluates to FALSE
|
// it is not a interval ping, so it evaluates to FALSE
|
||||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||||
@@ -200,7 +218,9 @@ public class Metrics {
|
|||||||
// After the first post we set firstPost to false
|
// After the first post we set firstPost to false
|
||||||
// Each post thereafter will be a ping
|
// Each post thereafter will be a ping
|
||||||
firstPost = false;
|
firstPost = false;
|
||||||
} catch (IOException e) {
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
System.err.println("[Metrics] " + e.getMessage());
|
System.err.println("[Metrics] " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,35 +230,36 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Generic method that posts a plugin to the metrics website
|
* Generic method that posts a plugin to the metrics website
|
||||||
*/
|
*/
|
||||||
private void postPlugin(boolean isPing) throws IOException {
|
private void postPlugin(boolean isPing) throws IOException
|
||||||
|
{
|
||||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||||
PluginDescriptionFile description = plugin.getDescription();
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
|
|
||||||
// Construct the post data
|
// Construct the post data
|
||||||
String data = encode("guid") + '=' + encode(guid)
|
String data = encode("guid") + '=' + encode(guid) + encodeDataPair("version", description.getVersion().split("-b")[0]) + encodeDataPair("server", Bukkit.getVersion()) + encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length)) + encodeDataPair("revision", String.valueOf(REVISION));
|
||||||
+ encodeDataPair("version", description.getVersion().split("-b")[0])
|
|
||||||
+ encodeDataPair("server", Bukkit.getVersion())
|
|
||||||
+ encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length))
|
|
||||||
+ encodeDataPair("revision", String.valueOf(REVISION));
|
|
||||||
|
|
||||||
// If we're pinging, append it
|
// If we're pinging, append it
|
||||||
if (isPing) {
|
if (isPing)
|
||||||
|
{
|
||||||
data += encodeDataPair("ping", "true");
|
data += encodeDataPair("ping", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||||
// inside of the graph (e.g plotters)
|
// inside of the graph (e.g plotters)
|
||||||
synchronized (graphs) {
|
synchronized (graphs)
|
||||||
|
{
|
||||||
Iterator<Graph> iter = graphs.iterator();
|
Iterator<Graph> iter = graphs.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
Graph graph = iter.next();
|
Graph graph = iter.next();
|
||||||
|
|
||||||
// Because we have a lock on the graphs set already, it is reasonable to assume
|
// Because we have a lock on the graphs set already, it is reasonable to assume
|
||||||
// that our lock transcends down to the individual plotters in the graphs also.
|
// that our lock transcends down to the individual plotters in the graphs also.
|
||||||
// Because our methods are private, no one but us can reasonably access this list
|
// Because our methods are private, no one but us can reasonably access this list
|
||||||
// without reflection so this is a safe assumption without adding more code.
|
// without reflection so this is a safe assumption without adding more code.
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
for (Plotter plotter : graph.getPlotters())
|
||||||
|
{
|
||||||
// The key name to send to the metrics server
|
// The key name to send to the metrics server
|
||||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||||
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||||
@@ -262,9 +283,12 @@ public class Metrics {
|
|||||||
|
|
||||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||||
// It does not reroute POST requests so we need to go around it
|
// It does not reroute POST requests so we need to go around it
|
||||||
if (isMineshafterPresent()) {
|
if (isMineshafterPresent())
|
||||||
|
{
|
||||||
connection = url.openConnection(Proxy.NO_PROXY);
|
connection = url.openConnection(Proxy.NO_PROXY);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
connection = url.openConnection();
|
connection = url.openConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,18 +307,25 @@ public class Metrics {
|
|||||||
writer.close();
|
writer.close();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
if (response.startsWith("ERR")) {
|
if (response.startsWith("ERR"))
|
||||||
|
{
|
||||||
throw new IOException(response); //Throw the exception
|
throw new IOException(response); //Throw the exception
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Is this the first update this hour?
|
// Is this the first update this hour?
|
||||||
if (response.contains("OK This is your first update this hour")) {
|
if (response.contains("OK This is your first update this hour"))
|
||||||
synchronized (graphs) {
|
{
|
||||||
|
synchronized (graphs)
|
||||||
|
{
|
||||||
Iterator<Graph> iter = graphs.iterator();
|
Iterator<Graph> iter = graphs.iterator();
|
||||||
|
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext())
|
||||||
|
{
|
||||||
Graph graph = iter.next();
|
Graph graph = iter.next();
|
||||||
|
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
for (Plotter plotter : graph.getPlotters())
|
||||||
|
{
|
||||||
plotter.reset();
|
plotter.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,52 +336,62 @@ public class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
* Check if mineshafter is present. If it is, we need to bypass it to send
|
||||||
*
|
* POST requests
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private boolean isMineshafterPresent() {
|
private boolean isMineshafterPresent()
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
Class.forName("mineshafter.MineServer");
|
Class.forName("mineshafter.MineServer");
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
|
* <p>
|
||||||
* key/value pair MUST be included manually, e.g:</p>
|
* Encode a key/value data pair to be used in a HTTP post request. This
|
||||||
|
* INCLUDES a & so the first key/value pair MUST be included manually, e.g:
|
||||||
|
* </p>
|
||||||
* <code>
|
* <code>
|
||||||
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException {
|
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException
|
||||||
|
{
|
||||||
return '&' + encode(key) + '=' + encode(value);
|
return '&' + encode(key) + '=' + encode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode text as UTF-8
|
* Encode text as UTF-8
|
||||||
*
|
*
|
||||||
* @param text
|
* @param text
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static String encode(String text) throws UnsupportedEncodingException {
|
private static String encode(String text) throws UnsupportedEncodingException
|
||||||
|
{
|
||||||
return URLEncoder.encode(text, "UTF-8");
|
return URLEncoder.encode(text, "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a custom graph on the website
|
* Represents a custom graph on the website
|
||||||
*/
|
*/
|
||||||
public static class Graph {
|
public static class Graph
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The graph's name, alphanumeric and spaces only :)
|
* The graph's name, alphanumeric and spaces only :) If it does not
|
||||||
* If it does not comply to the above when submitted, it is rejected
|
* comply to the above when submitted, it is rejected
|
||||||
*/
|
*/
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
@@ -359,54 +400,62 @@ public class Metrics {
|
|||||||
*/
|
*/
|
||||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||||
|
|
||||||
private Graph(String name) {
|
private Graph(String name)
|
||||||
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the graph's name
|
* Gets the graph's name
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName()
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a plotter to the graph, which will be used to plot entries
|
* Add a plotter to the graph, which will be used to plot entries
|
||||||
*
|
*
|
||||||
* @param plotter
|
* @param plotter
|
||||||
*/
|
*/
|
||||||
public void addPlotter(Plotter plotter) {
|
public void addPlotter(Plotter plotter)
|
||||||
|
{
|
||||||
plotters.add(plotter);
|
plotters.add(plotter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a plotter from the graph
|
* Remove a plotter from the graph
|
||||||
*
|
*
|
||||||
* @param plotter
|
* @param plotter
|
||||||
*/
|
*/
|
||||||
public void removePlotter(Plotter plotter) {
|
public void removePlotter(Plotter plotter)
|
||||||
|
{
|
||||||
plotters.remove(plotter);
|
plotters.remove(plotter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Set<Plotter> getPlotters() {
|
public Set<Plotter> getPlotters()
|
||||||
|
{
|
||||||
return Collections.unmodifiableSet(plotters);
|
return Collections.unmodifiableSet(plotters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode()
|
||||||
|
{
|
||||||
return name.hashCode();
|
return name.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object)
|
||||||
if (!(object instanceof Graph)) {
|
{
|
||||||
|
if (!(object instanceof Graph))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,7 +468,8 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Interface used to collect custom data for a plugin
|
* Interface used to collect custom data for a plugin
|
||||||
*/
|
*/
|
||||||
public static abstract class Plotter {
|
public static abstract class Plotter
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plot's name
|
* The plot's name
|
||||||
@@ -429,49 +479,56 @@ public class Metrics {
|
|||||||
/**
|
/**
|
||||||
* Construct a plotter with the default plot name
|
* Construct a plotter with the default plot name
|
||||||
*/
|
*/
|
||||||
public Plotter() {
|
public Plotter()
|
||||||
|
{
|
||||||
this("Default");
|
this("Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a plotter with a specific plot name
|
* Construct a plotter with a specific plot name
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public Plotter(String name) {
|
public Plotter(String name)
|
||||||
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current value for the plotted point
|
* Get the current value for the plotted point
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract int getValue();
|
public abstract int getValue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the column name for the plotted point
|
* Get the column name for the plotted point
|
||||||
*
|
*
|
||||||
* @return the plotted point's column name
|
* @return the plotted point's column name
|
||||||
*/
|
*/
|
||||||
public String getColumnName() {
|
public String getColumnName()
|
||||||
|
{
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the website graphs have been updated
|
* Called after the website graphs have been updated
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode()
|
||||||
|
{
|
||||||
return getColumnName().hashCode() + getValue();
|
return getColumnName().hashCode() + getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object)
|
||||||
if (!(object instanceof Plotter)) {
|
{
|
||||||
|
if (!(object instanceof Plotter))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,13 +20,14 @@ 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(' ');
|
StringBuilder output = new StringBuilder().append(record.getMessage()).append(' ');
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -23,28 +23,24 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.logging.Formatter;
|
import java.util.logging.Formatter;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
public class FileFormatter extends Formatter {
|
public class FileFormatter extends Formatter
|
||||||
|
{
|
||||||
|
|
||||||
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
||||||
private static final String lineSep = System.getProperty("line.separator");
|
private static final String lineSep = System.getProperty("line.separator");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String format(LogRecord record) {
|
public String format(LogRecord record)
|
||||||
if(record.getMessage().startsWith("[AntiCheat]"))
|
{
|
||||||
|
if (record.getMessage().startsWith("[AntiCheat]"))
|
||||||
{
|
{
|
||||||
StringBuilder output = new StringBuilder()
|
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(format.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(lineSep);
|
||||||
.append("[")
|
return output.toString();
|
||||||
.append(record.getLevel()).append('|')
|
|
||||||
.append(format.format(new Date(record.getMillis())))
|
|
||||||
.append("]: ")
|
|
||||||
.append(record.getMessage()).append(' ')
|
|
||||||
.append(lineSep);
|
|
||||||
return output.toString();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -24,199 +24,148 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
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 Utilities()
|
private Utilities()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void alert(String [] message)
|
|
||||||
|
public static void alert(String[] message)
|
||||||
{
|
{
|
||||||
for(String msg : message)
|
for (String msg : message)
|
||||||
{
|
{
|
||||||
Bukkit.broadcast(msg, "anticheat.alert");
|
Bukkit.broadcast(msg, "anticheat.alert");
|
||||||
}
|
}
|
||||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
if (Anticheat.getManager().getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
for(String msg : message)
|
for (String msg : message)
|
||||||
{
|
{
|
||||||
Anticheat.getManager().log(msg);
|
Anticheat.getManager().log(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandAt(Block block)
|
public static boolean cantStandAt(Block block)
|
||||||
{
|
{
|
||||||
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandClose(Block block)
|
public static boolean cantStandClose(Block block)
|
||||||
{
|
{
|
||||||
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean cantStandFar(Block block)
|
public static boolean cantStandFar(Block block)
|
||||||
{
|
{
|
||||||
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canStand(Block block)
|
public static boolean canStand(Block block)
|
||||||
{
|
{
|
||||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInstantBreak(Material m)
|
public static boolean isInstantBreak(Material m)
|
||||||
{
|
{
|
||||||
return INSTANT_BREAK.contains(m);
|
return INSTANT_BREAK.contains(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFood(Material m)
|
public static boolean isFood(Material m)
|
||||||
{
|
{
|
||||||
return FOOD.contains(m);
|
return FOOD.contains(m);
|
||||||
}
|
}
|
||||||
public static boolean isInteractable(Material m) {
|
|
||||||
|
public static boolean isInteractable(Material m)
|
||||||
|
{
|
||||||
return INTERACTABLE.contains(m);
|
return INTERACTABLE.contains(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sprintFly(Player player)
|
public static boolean sprintFly(Player player)
|
||||||
{
|
{
|
||||||
return player.isSprinting() || player.isFlying();
|
return player.isSprinting() || player.isFlying();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnLilyPad(Player player)
|
public static boolean isOnLilyPad(Player player)
|
||||||
{
|
{
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
Material lily = Material.WATER_LILY;
|
Material lily = Material.WATER_LILY;
|
||||||
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUsingMcMMOAbility(Player player)
|
public static boolean isUsingMcMMOAbility(Player player)
|
||||||
{
|
{
|
||||||
boolean b = false;
|
boolean b = false;
|
||||||
if(player.getServer().getPluginManager().getPlugin("mcMMO") != null)
|
if (player.getServer().getPluginManager().getPlugin("mcMMO") != null)
|
||||||
{
|
{
|
||||||
if(mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BLAST_MINING))
|
if (mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BLAST_MINING))
|
||||||
{
|
{
|
||||||
b = true;
|
b = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Credits to sk89q for the calculation of cardinal direction.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the cardinal compass direction of a player.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getCardinalDirection(Player player) {
|
|
||||||
double rot = (player.getLocation().getYaw() - 90) % 360;
|
|
||||||
if (rot < 0) {
|
|
||||||
rot += 360.0;
|
|
||||||
}
|
|
||||||
return getDirection(rot);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the cardinal compass direction of a location.
|
|
||||||
*
|
|
||||||
* @param location
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static String getCardinalDirectionLoc(Location player) {
|
|
||||||
double rot = (player.getYaw() - 90) % 360;
|
|
||||||
if (rot < 0) {
|
|
||||||
rot += 360.0;
|
|
||||||
}
|
|
||||||
return getDirection(rot);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a rotation to a cardinal direction name.
|
|
||||||
*
|
|
||||||
* @param rot
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static String getDirection(double rot) {
|
|
||||||
if (0 <= rot && rot < 22.5) {
|
|
||||||
return "N";
|
|
||||||
} else if (22.5 <= rot && rot < 67.5) {
|
|
||||||
return "NE";
|
|
||||||
} else if (67.5 <= rot && rot < 112.5) {
|
|
||||||
return "E";
|
|
||||||
} else if (112.5 <= rot && rot < 157.5) {
|
|
||||||
return "SE";
|
|
||||||
} else if (157.5 <= rot && rot < 202.5) {
|
|
||||||
return "S";
|
|
||||||
} else if (202.5 <= rot && rot < 247.5) {
|
|
||||||
return "SW";
|
|
||||||
} else if (247.5 <= rot && rot < 292.5) {
|
|
||||||
return "W";
|
|
||||||
} else if (292.5 <= rot && rot < 337.5) {
|
|
||||||
return "NW";
|
|
||||||
} else if (337.5 <= rot && rot < 360.0) {
|
|
||||||
return "N";
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isSubmersed(Player player)
|
public static boolean isSubmersed(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInWater(Player player)
|
public static boolean isInWater(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOnLadder(Player player)
|
public static boolean isOnLadder(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
|
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInt(String string)
|
public static boolean isInt(String string)
|
||||||
{
|
{
|
||||||
boolean x = false;
|
boolean x = false;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
Integer.parseInt(string);
|
Integer.parseInt(string);
|
||||||
x = true;
|
x = true;
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
static
|
|
||||||
|
static
|
||||||
{
|
{
|
||||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||||
INSTANT_BREAK.add(Material.RED_ROSE);
|
INSTANT_BREAK.add(Material.RED_ROSE);
|
||||||
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
INSTANT_BREAK.add(Material.BROWN_MUSHROOM);
|
||||||
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
|
INSTANT_BREAK.add(Material.YELLOW_FLOWER);
|
||||||
INSTANT_BREAK.add(Material.REDSTONE);
|
INSTANT_BREAK.add(Material.REDSTONE);
|
||||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
|
INSTANT_BREAK.add(Material.REDSTONE_TORCH_OFF);
|
||||||
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
|
INSTANT_BREAK.add(Material.REDSTONE_TORCH_ON);
|
||||||
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
INSTANT_BREAK.add(Material.REDSTONE_WIRE);
|
||||||
INSTANT_BREAK.add(Material.LONG_GRASS);
|
INSTANT_BREAK.add(Material.LONG_GRASS);
|
||||||
INSTANT_BREAK.add(Material.PAINTING);
|
INSTANT_BREAK.add(Material.PAINTING);
|
||||||
INSTANT_BREAK.add(Material.WHEAT);
|
INSTANT_BREAK.add(Material.WHEAT);
|
||||||
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
INSTANT_BREAK.add(Material.SUGAR_CANE);
|
||||||
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
|
INSTANT_BREAK.add(Material.SUGAR_CANE_BLOCK);
|
||||||
INSTANT_BREAK.add(Material.DIODE);
|
INSTANT_BREAK.add(Material.DIODE);
|
||||||
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
|
INSTANT_BREAK.add(Material.DIODE_BLOCK_OFF);
|
||||||
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
|
INSTANT_BREAK.add(Material.DIODE_BLOCK_ON);
|
||||||
INSTANT_BREAK.add(Material.SAPLING);
|
INSTANT_BREAK.add(Material.SAPLING);
|
||||||
INSTANT_BREAK.add(Material.TORCH);
|
INSTANT_BREAK.add(Material.TORCH);
|
||||||
INSTANT_BREAK.add(Material.CROPS);
|
INSTANT_BREAK.add(Material.CROPS);
|
||||||
INSTANT_BREAK.add(Material.SNOW);
|
INSTANT_BREAK.add(Material.SNOW);
|
||||||
INSTANT_BREAK.add(Material.TNT);
|
INSTANT_BREAK.add(Material.TNT);
|
||||||
INTERACTABLE.add(Material.STONE_BUTTON);
|
INTERACTABLE.add(Material.STONE_BUTTON);
|
||||||
INTERACTABLE.add(Material.LEVER);
|
INTERACTABLE.add(Material.LEVER);
|
||||||
@@ -247,6 +196,6 @@ public final class Utilities
|
|||||||
FOOD.add(Material.COOKIE);
|
FOOD.add(Material.COOKIE);
|
||||||
FOOD.add(Material.BREAD);
|
FOOD.add(Material.BREAD);
|
||||||
FOOD.add(Material.SPIDER_EYE);
|
FOOD.add(Material.SPIDER_EYE);
|
||||||
FOOD.add(Material.ROTTEN_FLESH);
|
FOOD.add(Material.ROTTEN_FLESH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -28,49 +28,50 @@ 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())
|
if (config.logXRay())
|
||||||
{
|
{
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
String player = p.getName();
|
String player = p.getName();
|
||||||
if(checkManager.willCheck(p, CheckType.XRAY))
|
if (checkManager.willCheck(p, CheckType.XRAY))
|
||||||
{
|
{
|
||||||
Material m = event.getBlock().getType();
|
Material m = event.getBlock().getType();
|
||||||
if(m == Material.DIAMOND_ORE)
|
if (m == Material.DIAMOND_ORE)
|
||||||
{
|
{
|
||||||
tracker.addDiamond(player);
|
tracker.addDiamond(player);
|
||||||
}
|
}
|
||||||
else if(m == Material.IRON_ORE)
|
else if (m == Material.IRON_ORE)
|
||||||
{
|
{
|
||||||
tracker.addIron(player);
|
tracker.addIron(player);
|
||||||
}
|
}
|
||||||
else if(m == Material.COAL_ORE)
|
else if (m == Material.COAL_ORE)
|
||||||
{
|
{
|
||||||
tracker.addCoal(player);
|
tracker.addCoal(player);
|
||||||
}
|
}
|
||||||
else if(m == Material.GOLD_ORE)
|
else if (m == Material.GOLD_ORE)
|
||||||
{
|
{
|
||||||
tracker.addGold(player);
|
tracker.addGold(player);
|
||||||
}
|
}
|
||||||
else if(m == Material.LAPIS_ORE)
|
else if (m == Material.LAPIS_ORE)
|
||||||
{
|
{
|
||||||
tracker.addLapis(player);
|
tracker.addLapis(player);
|
||||||
}
|
}
|
||||||
else if(m == Material.REDSTONE_ORE)
|
else if (m == Material.REDSTONE_ORE)
|
||||||
{
|
{
|
||||||
tracker.addRedstone(player);
|
tracker.addRedstone(player);
|
||||||
}
|
}
|
||||||
else if(m == Material.GOLD_ORE)
|
else if (m == Material.GOLD_ORE)
|
||||||
{
|
{
|
||||||
tracker.addGold(player);
|
tracker.addGold(player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tracker.addBlock(player);
|
tracker.addBlock(player);
|
||||||
@@ -78,5 +79,5 @@ public class XRayListener implements Listener {
|
|||||||
tracker.addTotal(player);
|
tracker.addTotal(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -20,7 +20,8 @@ package net.h31ix.anticheat.xray;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class XRayStats {
|
public class XRayStats
|
||||||
|
{
|
||||||
private static final int DIVISOR = 100;
|
private static final int DIVISOR = 100;
|
||||||
private double t = 1;
|
private double t = 1;
|
||||||
private double d = 0;
|
private double d = 0;
|
||||||
@@ -28,82 +29,82 @@ public class XRayStats {
|
|||||||
private double i = 0;
|
private double i = 0;
|
||||||
private double c = 0;
|
private double c = 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> coal,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> coal, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total)
|
||||||
{
|
{
|
||||||
if(total.get(player) != null)
|
if (total.get(player) != null)
|
||||||
{
|
{
|
||||||
t = total.get(player);
|
t = total.get(player);
|
||||||
}
|
}
|
||||||
if(diamond.get(player) != null)
|
if (diamond.get(player) != null)
|
||||||
{
|
{
|
||||||
d = (diamond.get(player)/t)*DIVISOR;
|
d = (diamond.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if(gold.get(player) != null)
|
if (gold.get(player) != null)
|
||||||
{
|
{
|
||||||
g = (gold.get(player)/t)*DIVISOR;
|
g = (gold.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if(iron.get(player) != null)
|
if (iron.get(player) != null)
|
||||||
{
|
{
|
||||||
i = (iron.get(player)/t)*DIVISOR;
|
i = (iron.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if(coal.get(player) != null)
|
if (coal.get(player) != null)
|
||||||
{
|
{
|
||||||
c = (coal.get(player)/t)*DIVISOR;
|
c = (coal.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if(lapis.get(player) != null)
|
if (lapis.get(player) != null)
|
||||||
{
|
{
|
||||||
l = (lapis.get(player)/t)*DIVISOR;
|
l = (lapis.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if(redstone.get(player) != null)
|
if (redstone.get(player) != null)
|
||||||
{
|
{
|
||||||
r = (redstone.get(player)/t)*DIVISOR;
|
r = (redstone.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
if(other.get(player) != null)
|
if (other.get(player) != null)
|
||||||
{
|
{
|
||||||
o = (other.get(player)/t)*DIVISOR;
|
o = (other.get(player) / t) * DIVISOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTotal()
|
public double getTotal()
|
||||||
{
|
{
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDiamond()
|
public double getDiamond()
|
||||||
{
|
{
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getGold()
|
public double getGold()
|
||||||
{
|
{
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIron()
|
public double getIron()
|
||||||
{
|
{
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCoal()
|
public double getCoal()
|
||||||
{
|
{
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLapis()
|
public double getLapis()
|
||||||
{
|
{
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getRedstone()
|
public double getRedstone()
|
||||||
{
|
{
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOther()
|
public double getOther()
|
||||||
{
|
{
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* AntiCheat for Bukkit.
|
* AntiCheat for Bukkit.
|
||||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -25,15 +25,16 @@ 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> gold = new HashMap<String,Integer>();
|
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
||||||
private Map<String,Integer> iron = new HashMap<String,Integer>();
|
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
||||||
private Map<String,Integer> coal = 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> coal = new HashMap<String, Integer>();
|
||||||
private Map<String,Integer> redstone = new HashMap<String,Integer>();
|
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
||||||
private Map<String,Integer> block = new HashMap<String,Integer>();
|
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
||||||
private Map<String,Integer> totalblock = new HashMap<String,Integer>();
|
private Map<String, Integer> block = 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;
|
||||||
@@ -42,141 +43,141 @@ public class XRayTracker {
|
|||||||
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)
|
public boolean sufficientData(String player)
|
||||||
{
|
{
|
||||||
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
return totalblock.get(player) != null && totalblock.get(player) >= MIN_BLOCK_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculate(CommandSender cs, String player, double x, double b, String type)
|
public void calculate(CommandSender cs, String player, double x, double b, String type)
|
||||||
{
|
{
|
||||||
ChatColor color = WHITE;
|
ChatColor color = WHITE;
|
||||||
if(x >= b/RATIO_DIVISOR)
|
if (x >= b / RATIO_DIVISOR)
|
||||||
{
|
{
|
||||||
color = RED;
|
color = RED;
|
||||||
}
|
}
|
||||||
cs.sendMessage(GRAY+"Percent "+type+" ore: "+color+round(x)+"%");
|
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean calculate(String player, double x, double b)
|
public boolean calculate(String player, double x, double b)
|
||||||
{
|
{
|
||||||
return x >= b/RATIO_DIVISOR;
|
return x >= b / RATIO_DIVISOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAbnormal(String player)
|
public boolean hasAbnormal(String player)
|
||||||
{
|
{
|
||||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,lapis,redstone,block,totalblock);
|
XRayStats stats = new XRayStats(player, diamond, gold, iron, coal, lapis, redstone, block, totalblock);
|
||||||
double total = stats.getOther();
|
double total = stats.getOther();
|
||||||
return calculate(player,stats.getDiamond(),total) || calculate(player,stats.getGold(),total) || calculate(player,stats.getIron(),total) || calculate(player,stats.getCoal(),total) || calculate(player,stats.getLapis(),total) || calculate(player,stats.getRedstone(),total);
|
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getCoal(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasAlerted(String player)
|
public boolean hasAlerted(String player)
|
||||||
{
|
{
|
||||||
return alerted.contains(player);
|
return alerted.contains(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logAlert(String player)
|
public void logAlert(String player)
|
||||||
{
|
{
|
||||||
alerted.add(player);
|
alerted.add(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendStats(CommandSender cs, String player)
|
public void sendStats(CommandSender cs, String player)
|
||||||
{
|
{
|
||||||
getStats(cs,player);
|
getStats(cs, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getStats(CommandSender cs, String player)
|
public void getStats(CommandSender cs, String player)
|
||||||
{
|
{
|
||||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,lapis,redstone,block,totalblock);
|
XRayStats stats = new XRayStats(player, diamond, gold, iron, coal, lapis, redstone, block, totalblock);
|
||||||
double total = stats.getOther();
|
double total = stats.getOther();
|
||||||
cs.sendMessage("--------------------["+GREEN+"X-Ray Stats"+WHITE+"]---------------------");
|
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
||||||
cs.sendMessage(GRAY+"Player: "+WHITE+player);
|
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
||||||
cs.sendMessage(GRAY+"Total blocks broken: "+WHITE+stats.getTotal());
|
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
||||||
calculate(cs,player,stats.getDiamond(),total,"diamond");
|
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
||||||
calculate(cs,player,stats.getGold(),total,"gold");
|
calculate(cs, player, stats.getGold(), total, "gold");
|
||||||
calculate(cs,player,stats.getIron(),total,"iron");
|
calculate(cs, player, stats.getIron(), total, "iron");
|
||||||
calculate(cs,player,stats.getCoal(),total,"coal");
|
calculate(cs, player, stats.getCoal(), total, "coal");
|
||||||
calculate(cs,player,stats.getLapis(),total,"lapis");
|
calculate(cs, player, stats.getLapis(), total, "lapis");
|
||||||
calculate(cs,player,stats.getRedstone(),total,"redstone");
|
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
||||||
cs.sendMessage(GRAY+"Percent all other blocks: "+WHITE+round(stats.getOther())+"%");
|
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
||||||
cs.sendMessage("-----------------------------------------------------");
|
cs.sendMessage("-----------------------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDiamond(String player)
|
public void addDiamond(String player)
|
||||||
{
|
{
|
||||||
addOre(player,diamond);
|
addOre(player, diamond);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGold(String player)
|
public void addGold(String player)
|
||||||
{
|
{
|
||||||
addOre(player,gold);
|
addOre(player, gold);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCoal(String player)
|
public void addCoal(String player)
|
||||||
{
|
{
|
||||||
addOre(player,coal);
|
addOre(player, coal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addIron(String player)
|
public void addIron(String player)
|
||||||
{
|
{
|
||||||
addOre(player,iron);
|
addOre(player, iron);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLapis(String player)
|
public void addLapis(String player)
|
||||||
{
|
{
|
||||||
addOre(player,lapis);
|
addOre(player, lapis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRedstone(String player)
|
public void addRedstone(String player)
|
||||||
{
|
{
|
||||||
addOre(player,redstone);
|
addOre(player, redstone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlock(String player)
|
public void addBlock(String player)
|
||||||
{
|
{
|
||||||
addOre(player,block);
|
addOre(player, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTotal(String player)
|
public void addTotal(String player)
|
||||||
{
|
{
|
||||||
addOre(player,totalblock);
|
addOre(player, totalblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addOre(String player, Map<String,Integer> map)
|
private void addOre(String player, Map<String, Integer> map)
|
||||||
{
|
{
|
||||||
if(map.get(player) == null || map.get(player) == 0)
|
if (map.get(player) == null || map.get(player) == 0)
|
||||||
{
|
{
|
||||||
map.put(player,1);
|
map.put(player, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int playerLevel = map.get(player);
|
int playerLevel = map.get(player);
|
||||||
map.put(player, playerLevel+1);
|
map.put(player, playerLevel + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float round(double num)
|
private float round(double num)
|
||||||
{
|
{
|
||||||
double number = num;
|
double number = num;
|
||||||
float p = (float)Math.pow(POWER,1);
|
float p = (float) Math.pow(POWER, 1);
|
||||||
number*=p;
|
number *= p;
|
||||||
float tmp = Math.round(number);
|
float tmp = Math.round(number);
|
||||||
return (float)tmp/p;
|
return (float) tmp / p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(String player)
|
public void reset(String player)
|
||||||
{
|
{
|
||||||
totalblock.put(player,1);
|
totalblock.put(player, 1);
|
||||||
diamond.put(player,0);
|
diamond.put(player, 0);
|
||||||
iron.put(player,0);
|
iron.put(player, 0);
|
||||||
gold.put(player,0);
|
gold.put(player, 0);
|
||||||
coal.put(player,0);
|
coal.put(player, 0);
|
||||||
redstone.put(player,0);
|
redstone.put(player, 0);
|
||||||
lapis.put(player,0);
|
lapis.put(player, 0);
|
||||||
totalblock.put(player,0);
|
totalblock.put(player, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user