mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Major refactoring to fix runtime errors, better fastbreak and fly check, and a better API. Thanks a ton @SuperSpyTX
This commit is contained in:
1 parent
d8dc8ed1e0
commit
af91c8a541
22 files changed
+1478
-1204
No files matched your search
@@ -45,9 +45,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Anticheat extends JavaPlugin
|
||||
public class Anticheat extends JavaPlugin
|
||||
{
|
||||
private static Anticheat plugin;
|
||||
private static AnticheatManager manager;
|
||||
private final List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static boolean update = false;
|
||||
private static final int BYTE_SIZE = 1024;
|
||||
@@ -56,13 +56,13 @@ public class Anticheat extends JavaPlugin
|
||||
private static boolean verbose;
|
||||
private static String updateFolder;
|
||||
private static Metrics metrics;
|
||||
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
Map<String,Integer> map = AnticheatManager.PLAYER_MANAGER.getLevels();
|
||||
Map<String, Integer> map = manager.getPlayerManager().getLevels();
|
||||
Iterator<String> set = map.keySet().iterator();
|
||||
while(set.hasNext())
|
||||
while (set.hasNext())
|
||||
{
|
||||
String player = set.next();
|
||||
config.saveLevel(player, map.get(player));
|
||||
@@ -74,8 +74,8 @@ public class Anticheat extends JavaPlugin
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
plugin = this;
|
||||
config = AnticheatManager.CONFIGURATION;
|
||||
manager = new AnticheatManager(this);
|
||||
config = manager.getConfiguration();
|
||||
checkConfig();
|
||||
verbose = config.verboseStartup();
|
||||
updateFolder = config.updateFolder();
|
||||
@@ -84,55 +84,62 @@ public class Anticheat extends JavaPlugin
|
||||
eventList.add(new BlockListener());
|
||||
eventList.add(new EntityListener());
|
||||
eventList.add(new VehicleListener());
|
||||
final XRayTracker xtracker = AnticheatManager.XRAY_TRACKER;
|
||||
if(config.logXRay())
|
||||
final XRayTracker xtracker = manager.getXRayTracker();
|
||||
if (config.logXRay())
|
||||
{
|
||||
eventList.add(new XRayListener());
|
||||
if(config.alertXRay())
|
||||
if (config.alertXRay())
|
||||
{
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
getServer().getScheduler().scheduleAsyncRepeatingTask(this, new Runnable()
|
||||
{
|
||||
for(Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
String name = player.getName();
|
||||
if(!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
String [] alert = new String[2];
|
||||
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+".";
|
||||
Utilities.alert(alert);
|
||||
xtracker.logAlert(name);
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
String name = player.getName();
|
||||
if (!xtracker.hasAlerted(name) && xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||
{
|
||||
String[] alert = new String[2];
|
||||
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 + ".";
|
||||
Utilities.alert(alert);
|
||||
xtracker.logAlert(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
}, 1200L, 1200L);
|
||||
}
|
||||
}
|
||||
for(Listener listener : eventList)
|
||||
for (Listener listener : eventList)
|
||||
{
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Registered events for ".concat(listener.toString()));
|
||||
}
|
||||
logger.log(Level.INFO, "[AC] Registered events for ".concat(listener.toString()));
|
||||
}
|
||||
}
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Registered commands");
|
||||
logger.log(Level.INFO,"[AC] Finished loading.");
|
||||
}
|
||||
if(update && config.autoUpdate())
|
||||
logger.log(Level.INFO, "[AC] Registered commands");
|
||||
logger.log(Level.INFO, "[AC] Finished loading.");
|
||||
}
|
||||
if (update && config.autoUpdate())
|
||||
{
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Downloading the new update...");
|
||||
}
|
||||
File file = new File("plugins/"+updateFolder);
|
||||
if(!file.exists())
|
||||
logger.log(Level.INFO, "[AC] Downloading the new update...");
|
||||
}
|
||||
File file = new File("plugins/" + updateFolder);
|
||||
if (!file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -141,28 +148,24 @@ public class Anticheat extends JavaPlugin
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
if(verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Enabling metrics...");
|
||||
}
|
||||
metrics = new Metrics(this);
|
||||
final EventListener listener = new EventListener();
|
||||
Graph graph = metrics.createGraph("Hacks blocked");
|
||||
for(final CheckType type : CheckType.values())
|
||||
for (final CheckType type : CheckType.values())
|
||||
{
|
||||
char [] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||
chars[0]= Character.toUpperCase(chars[0]);
|
||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||
chars[0] = Character.toUpperCase(chars[0]);
|
||||
graph.addPlotter(new Metrics.Plotter(new String(chars))
|
||||
{
|
||||
@Override
|
||||
@@ -170,170 +173,165 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
return listener.getCheats(type);
|
||||
}
|
||||
});
|
||||
});
|
||||
listener.resetCheck(type);
|
||||
}
|
||||
metrics.start();
|
||||
if(verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Metrics started.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
}
|
||||
for(Player player : getServer().getOnlinePlayers())
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
String name = player.getName();
|
||||
AnticheatManager.PLAYER_MANAGER.setLevel(player, config.getLevel(name));
|
||||
String name = player.getName();
|
||||
manager.getPlayerManager().setLevel(player,config.getLevel(name));
|
||||
}
|
||||
if(verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Player's levels collected from storage and applied.");
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile(String file, String url)
|
||||
{
|
||||
BufferedInputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try
|
||||
{
|
||||
in = new BufferedInputStream(new URL(url).openStream());
|
||||
fout = new FileOutputStream(file);
|
||||
}
|
||||
|
||||
byte[] data = new byte[BYTE_SIZE];
|
||||
int count;
|
||||
while ((count = in.read(data, 0, BYTE_SIZE)) != -1)
|
||||
{
|
||||
fout.write(data, 0, count);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
private void saveFile(String file, String url)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
BufferedInputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try
|
||||
{
|
||||
if (in != null)
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
if (fout != null)
|
||||
{
|
||||
fout.close();
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
}
|
||||
if(verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] AntiCheat update has been downloaded and will be installed on next launch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkConfig()
|
||||
{
|
||||
if(!new File(plugin.getDataFolder()+"/config.yml").exists())
|
||||
{
|
||||
plugin.saveDefaultConfig();
|
||||
if(verbose)
|
||||
in = new BufferedInputStream(new URL(url).openStream());
|
||||
fout = new FileOutputStream(file);
|
||||
|
||||
byte[] data = new byte[BYTE_SIZE];
|
||||
int count;
|
||||
while ((count = in.read(data, 0, BYTE_SIZE)) != -1)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Config file created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdate()
|
||||
{
|
||||
if(verbose)
|
||||
fout.write(data, 0, count);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Checking for updates...");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if (in != null)
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
if (fout != null)
|
||||
{
|
||||
fout.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] AntiCheat update has been downloaded and will be installed on next launch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkConfig()
|
||||
{
|
||||
if (!new File(getDataFolder() + "/config.yml").exists())
|
||||
{
|
||||
saveDefaultConfig();
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Config file created");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkForUpdate()
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Checking for updates...");
|
||||
}
|
||||
URL url = null;
|
||||
URLConnection urlConn = null;
|
||||
InputStreamReader inStream = null;
|
||||
BufferedReader buff = null;
|
||||
InputStreamReader inStream = null;
|
||||
BufferedReader buff = null;
|
||||
String v = "";
|
||||
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();
|
||||
inStream = new InputStreamReader(urlConn.getInputStream());
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
}
|
||||
buff= new BufferedReader(inStream);
|
||||
try
|
||||
{
|
||||
v =buff.readLine();
|
||||
urlConn = null;
|
||||
inStream = null;
|
||||
buff.close();
|
||||
buff = null;
|
||||
inStream = new InputStreamReader(urlConn.getInputStream());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (!this.getDescription().getVersion().equalsIgnoreCase(v))
|
||||
buff = new BufferedReader(inStream);
|
||||
try
|
||||
{
|
||||
v = buff.readLine();
|
||||
urlConn = null;
|
||||
inStream = null;
|
||||
buff.close();
|
||||
buff = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (!this.getDescription().getVersion().equalsIgnoreCase(v))
|
||||
{
|
||||
String version = this.getDescription().getVersion();
|
||||
if(version.endsWith("-PRE") || version.endsWith("-DEV"))
|
||||
{
|
||||
if(version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
||||
if (version.endsWith("-PRE") || version.endsWith("-DEV"))
|
||||
{
|
||||
if (version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v))
|
||||
{
|
||||
update = true;
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Your dev build has been promoted to release. Downloading the update.");
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
update = false;
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] Dev build detected, so skipping update checking until this version is released.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
update = true;
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] An update was found.");
|
||||
}
|
||||
logger.log(Level.INFO, "[AC] An update was found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if(verbose)
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"[AC] No update found.");
|
||||
}
|
||||
logger.log(Level.INFO, "[AC] No update found.");
|
||||
}
|
||||
update = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
return manager.getPlugin();
|
||||
}
|
||||
|
||||
public static boolean isUpdated()
|
||||
|
||||
public static AnticheatManager getManager()
|
||||
{
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static boolean isUpdated()
|
||||
{
|
||||
return !update;
|
||||
}
|
||||
|
||||
public static String getVersion()
|
||||
|
||||
public static String getVersion()
|
||||
{
|
||||
return plugin.getDescription().getVersion();
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,335 +1,335 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.PlayerManager;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
private Configuration config = AnticheatManager.CONFIGURATION;
|
||||
private PlayerManager playerManager = AnticheatManager.PLAYER_MANAGER;
|
||||
private XRayTracker xtracker = AnticheatManager.XRAY_TRACKER;
|
||||
private static final ChatColor RED = ChatColor.RED;
|
||||
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||
private List<Player> high = new ArrayList<Player>();
|
||||
private List<Player> med = new ArrayList<Player>();
|
||||
private List<Player> low = new ArrayList<Player>();
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
|
||||
public void handleLog(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.log") || hasPermission(cs,"admin"))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("enable"))
|
||||
{
|
||||
if(!config.logConsole())
|
||||
{
|
||||
config.setLog(true);
|
||||
cs.sendMessage(GREEN+"Console logging enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GREEN+"Console logging is already enabled!");
|
||||
}
|
||||
}
|
||||
else if(args[1].equalsIgnoreCase("disable"))
|
||||
{
|
||||
if(config.logConsole())
|
||||
{
|
||||
config.setLog(false);
|
||||
cs.sendMessage(GREEN+"Console logging disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GREEN+"Console logging is already disabled!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Usage: /anticheat log [enable/disable]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleXRay(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.xray") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||
{
|
||||
if(config.logXRay())
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
if(xtracker.sufficientData(player.getName()))
|
||||
{
|
||||
xtracker.sendStats(cs, player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
}
|
||||
else if(xtracker.sufficientData(args[1]))
|
||||
{
|
||||
xtracker.sendStats(cs, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"XRay logging is off in the config.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReset(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.reset") || hasPermission(cs,"admin"))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
getPlayers();
|
||||
if(low.contains(player))
|
||||
{
|
||||
cs.sendMessage(player.getName()+RED+" is already in Low Level!");
|
||||
}
|
||||
else if (med.contains(player) || high.contains(player))
|
||||
{
|
||||
playerManager.reset(player);
|
||||
cs.sendMessage(player.getName()+GREEN+" has been reset to Low Level.");
|
||||
}
|
||||
xtracker.reset(player.getName());
|
||||
cs.sendMessage(player.getName()+GREEN+"'s XRay stats have been reset.");
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleHelp(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.help") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||
{
|
||||
String base = "/AntiCheat ";
|
||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
||||
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+"reload"+WHITE+" - reload AntiCheat configuration");
|
||||
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+"help"+WHITE+" - access this page");
|
||||
cs.sendMessage(base+GREEN+"update"+WHITE+" - check update status");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public void handleUpdate(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.update") || hasPermission(cs,"admin"))
|
||||
{
|
||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
if(!Anticheat.isUpdated())
|
||||
{
|
||||
cs.sendMessage("There "+GREEN+"IS"+WHITE+" a newer version avaliable.");
|
||||
if(config.autoUpdate())
|
||||
{
|
||||
cs.sendMessage("It will be installed automatically for you on next launch.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage("Due to your config settings, we "+RED+"can not"+WHITE+" auto update.");
|
||||
cs.sendMessage("Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage("AntiCheat is "+GREEN+"UP TO DATE!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReport(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.report") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||
{
|
||||
getPlayers();
|
||||
if(!low.isEmpty())
|
||||
{
|
||||
cs.sendMessage(GREEN+"----Level: Low (Not likely hacking)----");
|
||||
for(Player player : low)
|
||||
{
|
||||
cs.sendMessage(GREEN+player.getName());
|
||||
}
|
||||
}
|
||||
if(!med.isEmpty())
|
||||
{
|
||||
cs.sendMessage(YELLOW+"----Level: Medium (Possibly hacking/lagging)----");
|
||||
for(Player player : med)
|
||||
{
|
||||
cs.sendMessage(YELLOW+player.getName());
|
||||
}
|
||||
}
|
||||
if(!high.isEmpty())
|
||||
{
|
||||
cs.sendMessage(RED+"----Level: High (Probably hacking or bad connection)----");
|
||||
for(Player player : high)
|
||||
{
|
||||
cs.sendMessage(RED+player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReload(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.reload") || hasPermission(cs,"admin"))
|
||||
{
|
||||
config.load();
|
||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args)
|
||||
{
|
||||
if(args.length == 2)
|
||||
{
|
||||
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
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command.");
|
||||
}
|
||||
}
|
||||
else if (args.length == 1)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
handleHelp(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("report"))
|
||||
{
|
||||
handleReport(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
handleReload(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("update"))
|
||||
{
|
||||
handleUpdate(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command. Try "+ChatColor.WHITE+"/anticheat help");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender cs, String permission)
|
||||
{
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
if(((Player)cs).hasPermission("anticheat."+permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage("Insufficient permissions.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void getPlayers()
|
||||
{
|
||||
high.clear();
|
||||
med.clear();
|
||||
low.clear();
|
||||
for(Player player : SERVER.getOnlinePlayers())
|
||||
{
|
||||
int level = playerManager.getLevel(player);
|
||||
if(level <= MED_THRESHOLD)
|
||||
{
|
||||
low.add(player);
|
||||
}
|
||||
else if(level <= HIGH_THRESHOLD)
|
||||
{
|
||||
med.add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
high.add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.PlayerManager;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandHandler implements CommandExecutor
|
||||
{
|
||||
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||
private PlayerManager playerManager = Anticheat.getManager().getPlayerManager();
|
||||
private XRayTracker xtracker = Anticheat.getManager().getXRayTracker();
|
||||
private static final ChatColor RED = ChatColor.RED;
|
||||
private static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||
private List<Player> high = new ArrayList<Player>();
|
||||
private List<Player> med = new ArrayList<Player>();
|
||||
private List<Player> low = new ArrayList<Player>();
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
|
||||
public void handleLog(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.log") || hasPermission(cs,"admin"))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("enable"))
|
||||
{
|
||||
if(!config.logConsole())
|
||||
{
|
||||
config.setLog(true);
|
||||
cs.sendMessage(GREEN+"Console logging enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GREEN+"Console logging is already enabled!");
|
||||
}
|
||||
}
|
||||
else if(args[1].equalsIgnoreCase("disable"))
|
||||
{
|
||||
if(config.logConsole())
|
||||
{
|
||||
config.setLog(false);
|
||||
cs.sendMessage(GREEN+"Console logging disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GREEN+"Console logging is already disabled!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Usage: /anticheat log [enable/disable]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleXRay(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.xray") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||
{
|
||||
if(config.logXRay())
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
if(xtracker.sufficientData(player.getName()))
|
||||
{
|
||||
xtracker.sendStats(cs, player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
}
|
||||
else if(xtracker.sufficientData(args[1]))
|
||||
{
|
||||
xtracker.sendStats(cs, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"XRay logging is off in the config.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReset(CommandSender cs, String [] args)
|
||||
{
|
||||
if(hasPermission(cs,"system.reset") || hasPermission(cs,"admin"))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
getPlayers();
|
||||
if(low.contains(player))
|
||||
{
|
||||
cs.sendMessage(player.getName()+RED+" is already in Low Level!");
|
||||
}
|
||||
else if (med.contains(player) || high.contains(player))
|
||||
{
|
||||
playerManager.reset(player);
|
||||
cs.sendMessage(player.getName()+GREEN+" has been reset to Low Level.");
|
||||
}
|
||||
xtracker.reset(player.getName());
|
||||
cs.sendMessage(player.getName()+GREEN+"'s XRay stats have been reset.");
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleHelp(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.help") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||
{
|
||||
String base = "/AntiCheat ";
|
||||
cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------");
|
||||
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+"reload"+WHITE+" - reload AntiCheat configuration");
|
||||
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+"help"+WHITE+" - access this page");
|
||||
cs.sendMessage(base+GREEN+"update"+WHITE+" - check update status");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
public void handleUpdate(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.update") || hasPermission(cs,"admin"))
|
||||
{
|
||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
if(!Anticheat.isUpdated())
|
||||
{
|
||||
cs.sendMessage("There "+GREEN+"IS"+WHITE+" a newer version avaliable.");
|
||||
if(config.autoUpdate())
|
||||
{
|
||||
cs.sendMessage("It will be installed automatically for you on next launch.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage("Due to your config settings, we "+RED+"can not"+WHITE+" auto update.");
|
||||
cs.sendMessage("Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage("AntiCheat is "+GREEN+"UP TO DATE!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReport(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.report") || hasPermission(cs,"admin") || hasPermission(cs,"mod"))
|
||||
{
|
||||
getPlayers();
|
||||
if(!low.isEmpty())
|
||||
{
|
||||
cs.sendMessage(GREEN+"----Level: Low (Not likely hacking)----");
|
||||
for(Player player : low)
|
||||
{
|
||||
cs.sendMessage(GREEN+player.getName());
|
||||
}
|
||||
}
|
||||
if(!med.isEmpty())
|
||||
{
|
||||
cs.sendMessage(YELLOW+"----Level: Medium (Possibly hacking/lagging)----");
|
||||
for(Player player : med)
|
||||
{
|
||||
cs.sendMessage(YELLOW+player.getName());
|
||||
}
|
||||
}
|
||||
if(!high.isEmpty())
|
||||
{
|
||||
cs.sendMessage(RED+"----Level: High (Probably hacking or bad connection)----");
|
||||
for(Player player : high)
|
||||
{
|
||||
cs.sendMessage(RED+player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReload(CommandSender cs)
|
||||
{
|
||||
if(hasPermission(cs,"system.reload") || hasPermission(cs,"admin"))
|
||||
{
|
||||
config.load();
|
||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args)
|
||||
{
|
||||
if(args.length == 2)
|
||||
{
|
||||
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
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command.");
|
||||
}
|
||||
}
|
||||
else if (args.length == 1)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
handleHelp(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("report"))
|
||||
{
|
||||
handleReport(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
handleReload(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("update"))
|
||||
{
|
||||
handleUpdate(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command. Try "+ChatColor.WHITE+"/anticheat help");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender cs, String permission)
|
||||
{
|
||||
if(cs instanceof Player)
|
||||
{
|
||||
if(((Player)cs).hasPermission("anticheat."+permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage("Insufficient permissions.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public void getPlayers()
|
||||
{
|
||||
high.clear();
|
||||
med.clear();
|
||||
low.clear();
|
||||
for(Player player : SERVER.getOnlinePlayers())
|
||||
{
|
||||
int level = playerManager.getLevel(player);
|
||||
if(level <= MED_THRESHOLD)
|
||||
{
|
||||
low.add(player);
|
||||
}
|
||||
else if(level <= HIGH_THRESHOLD)
|
||||
{
|
||||
med.add(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
high.add(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,20 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class Configuration {
|
||||
private File configFile = new File(Anticheat.getPlugin().getDataFolder()+"/config.yml");
|
||||
private File levelFile = new File(Anticheat.getPlugin().getDataFolder()+"/data/level.yml");
|
||||
private File bukkitFile = new File("bukkit.yml");
|
||||
public class Configuration
|
||||
{
|
||||
private AnticheatManager micromanage = null; //like a boss!
|
||||
private File configFile = null;
|
||||
private File levelFile = null;
|
||||
private File bukkitFile = null;
|
||||
private FileConfiguration config;
|
||||
private FileConfiguration level;
|
||||
private FileConfiguration bukkit;
|
||||
@@ -44,8 +49,12 @@ public class Configuration {
|
||||
private String updateFolder;
|
||||
private List<String> worlds = new ArrayList<String>();
|
||||
|
||||
public Configuration()
|
||||
public Configuration(AnticheatManager instance)
|
||||
{
|
||||
micromanage = instance;
|
||||
configFile = new File(micromanage.getPlugin().getDataFolder()+"/config.yml");
|
||||
levelFile = new File(micromanage.getPlugin().getDataFolder()+"/data/level.yml");
|
||||
bukkitFile = new File("bukkit.yml");
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -93,7 +102,7 @@ public class Configuration {
|
||||
|
||||
public final void load()
|
||||
{
|
||||
Anticheat.checkConfig();
|
||||
micromanage.getPlugin().checkConfig();
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
level = YamlConfiguration.loadConfiguration(levelFile);
|
||||
bukkit = YamlConfiguration.loadConfiguration(bukkitFile);
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.h31ix.anticheat.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.PlayerManager;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
|
||||
public class AnticheatAPI
|
||||
{
|
||||
private static CheckManager chk = Anticheat.getManager().getCheckManager();
|
||||
private static PlayerManager pmr = Anticheat.getManager().getPlayerManager();
|
||||
private static XRayTracker xtracker = Anticheat.getManager().getXRayTracker();
|
||||
|
||||
//CheckManager API.
|
||||
|
||||
public static void activateCheck(CheckType type)
|
||||
{
|
||||
chk.activateCheck(type);
|
||||
}
|
||||
|
||||
public static void deactivateCheck(CheckType type)
|
||||
{
|
||||
chk.deactivateCheck(type);
|
||||
}
|
||||
|
||||
public static boolean isActive(CheckType type)
|
||||
{
|
||||
return chk.isActive(type);
|
||||
}
|
||||
|
||||
public static void exemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
chk.exemptPlayer(player, type);
|
||||
}
|
||||
|
||||
public static void unexemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
chk.unexemptPlayer(player, type);
|
||||
}
|
||||
|
||||
public static boolean isExempt(Player player, CheckType type)
|
||||
{
|
||||
return chk.isExempt(player, type);
|
||||
}
|
||||
|
||||
//PlayerManager API
|
||||
|
||||
public static int getLevel(Player player)
|
||||
{
|
||||
if(!pmr.hasLevel(player))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return pmr.getLevel(player);
|
||||
}
|
||||
|
||||
public static void setLevel(Player player, int x)
|
||||
{
|
||||
pmr.setLevel(player, x);
|
||||
}
|
||||
|
||||
//XrayTracker API
|
||||
|
||||
public static boolean isXrayer(Player player)
|
||||
{
|
||||
String name = player.getName();
|
||||
if (xtracker.sufficientData(name) && xtracker.hasAbnormal(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Advanced Users Only API.
|
||||
|
||||
public static AnticheatManager getManager()
|
||||
{
|
||||
return Anticheat.getManager();
|
||||
}
|
||||
}
|
||||
@@ -1,122 +1,121 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.Distance;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class BlockListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
private final CheckManager checkManager = getCheckManager();
|
||||
private final Anticheat plugin = getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
if(event.getInstaBreak())
|
||||
{
|
||||
backend.logInstantBreak(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if(player != null && player.getGameMode() != GameMode.CREATIVE)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.FAST_PLACE))
|
||||
{
|
||||
if(backend.justPlaced(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to place a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_PLACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
backend.logBlockPlace(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
boolean noHack = true;
|
||||
if(player != null)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
{
|
||||
if(backend.checkSwing(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" without swinging their arm.",player,CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(),block.getLocation());
|
||||
if(backend.checkLongReachBlock(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" that was too far away.",player,CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.FAST_BREAK))
|
||||
{
|
||||
if(backend.checkFastBreak(player,block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_BREAK);
|
||||
noHack = false;
|
||||
}
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
backend.checkSwing(player);
|
||||
}
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
if(noHack)
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.Distance;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class BlockListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
private final CheckManager checkManager = getCheckManager();
|
||||
private final Anticheat plugin = getPlugin();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
if(event.getInstaBreak())
|
||||
{
|
||||
backend.logInstantBreak(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if(player != null)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.FAST_PLACE))
|
||||
{
|
||||
if(backend.checkFastPlace(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to place a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_PLACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
backend.logBlockPlace(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
boolean noHack = true;
|
||||
if(player != null)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
{
|
||||
if(backend.checkSwing(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" without swinging their arm.",player,CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(),block.getLocation());
|
||||
if(backend.checkLongReachBlock(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" that was too far away.",player,CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.FAST_BREAK))
|
||||
{
|
||||
if(backend.checkFastBreak(player,block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_BREAK);
|
||||
noHack = false;
|
||||
}
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
backend.checkSwing(player);
|
||||
}
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
if(noHack)
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,162 +1,162 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.Distance;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
|
||||
public class EntityListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
private final CheckManager checkManager = getCheckManager();
|
||||
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_BOW))
|
||||
{
|
||||
if(backend.justWoundUp(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to fire a bow too fast.",player,CheckType.FAST_BOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_HEAL))
|
||||
{
|
||||
if(backend.justHealed(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to heal too fast.",player,CheckType.FAST_HEAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_EAT))
|
||||
{
|
||||
if(backend.justStartedEating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to eat too fast.",player,CheckType.FAST_EAT);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
boolean noHack = true;
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if (e.getDamager() instanceof Player)
|
||||
{
|
||||
Player p = (Player)e.getDamager();
|
||||
backend.logDamage(p);
|
||||
backend.logDamage(player);
|
||||
if(checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(),p.getLocation());
|
||||
if(backend.checkLongReachDamage(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to damage a player too far away from them.",p,CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
backend.logDamage(player);
|
||||
}
|
||||
}
|
||||
if(e.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player) e.getDamager();
|
||||
if(checkManager.willCheck(player, CheckType.FORCEFIELD))
|
||||
{
|
||||
if(backend.justSprinted(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to sprint & damage too fast.",player,CheckType.FORCEFIELD);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
{
|
||||
if(!backend.justAnimated(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to damage an entity without swinging their arm.",player,CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(noHack)
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import net.h31ix.anticheat.manage.Distance;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
|
||||
public class EntityListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
private final CheckManager checkManager = getCheckManager();
|
||||
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_BOW))
|
||||
{
|
||||
if(backend.justWoundUp(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to fire a bow too fast.",player,CheckType.FAST_BOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_HEAL))
|
||||
{
|
||||
if(backend.justHealed(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to heal too fast.",player,CheckType.FAST_HEAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_EAT))
|
||||
{
|
||||
if(backend.justStartedEating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to eat too fast.",player,CheckType.FAST_EAT);
|
||||
}
|
||||
else
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
boolean noHack = true;
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if(event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if (e.getDamager() instanceof Player)
|
||||
{
|
||||
Player p = (Player)e.getDamager();
|
||||
backend.logDamage(p);
|
||||
backend.logDamage(player);
|
||||
if(checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(),p.getLocation());
|
||||
if(backend.checkLongReachDamage(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to damage a player too far away from them.",p,CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
backend.logDamage(player);
|
||||
}
|
||||
}
|
||||
if(e.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player) e.getDamager();
|
||||
if(checkManager.willCheck(player, CheckType.FORCEFIELD))
|
||||
{
|
||||
if(backend.justSprinted(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to sprint & damage too fast.",player,CheckType.FORCEFIELD);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
{
|
||||
if(!backend.justAnimated(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to damage an entity without swinging their arm.",player,CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(noHack)
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,16 +30,16 @@ public class EventListener implements Listener
|
||||
{
|
||||
private static final Map<CheckType,Integer> usageList = new EnumMap<CheckType,Integer>(CheckType.class);
|
||||
private static final Map<String,Integer> decreaseList = new HashMap<String,Integer>();
|
||||
private static final CheckManager CHECK_MANAGER = AnticheatManager.CHECK_MANAGER;
|
||||
private static final Backend BACKEND = AnticheatManager.BACKEND;
|
||||
private static final Anticheat PLUGIN = Anticheat.getPlugin();
|
||||
private static final PlayerManager PLAYER_MANAGER = AnticheatManager.PLAYER_MANAGER;
|
||||
private static final CheckManager CHECK_MANAGER = Anticheat.getManager().getCheckManager();
|
||||
private static final Backend BACKEND = Anticheat.getManager().getBackend();
|
||||
private static final Anticheat PLUGIN = Anticheat.getManager().getPlugin();
|
||||
private static final PlayerManager PLAYER_MANAGER = Anticheat.getManager().getPlayerManager();
|
||||
|
||||
public void log(String message,Player player, CheckType type)
|
||||
{
|
||||
if(AnticheatManager.CONFIGURATION.logConsole())
|
||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||
{
|
||||
AnticheatManager.log(player.getName()+" "+message);
|
||||
Anticheat.getManager().log(player.getName()+" "+message);
|
||||
}
|
||||
PLAYER_MANAGER.increaseLevel(player);
|
||||
removeDecrease(player);
|
||||
@@ -102,11 +102,19 @@ public class EventListener implements Listener
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
|
||||
public static AnticheatManager getManager() {
|
||||
return Anticheat.getManager();
|
||||
}
|
||||
|
||||
public static Backend getBackend()
|
||||
{
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public static PlayerManager getPlayerManager() {
|
||||
return PLAYER_MANAGER;
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin()
|
||||
{
|
||||
return PLUGIN;
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.h31ix.anticheat.manage.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -154,20 +155,20 @@ public class PlayerListener extends EventListener
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
||||
{
|
||||
player.sendMessage("§f §f §1 §0 §2 §4");
|
||||
player.sendMessage("§f §f §1 §0 §2 §4");
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
||||
{
|
||||
player.sendMessage("§f §f §2 §0 §4 §8");
|
||||
player.sendMessage("§f §f §2 §0 §4 §8");
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
||||
{
|
||||
player.sendMessage("§f §f §4 §0 §9 §6");
|
||||
player.sendMessage("§f §f §4 §0 §9 §6");
|
||||
}
|
||||
backend.logJoin(event.getPlayer());
|
||||
if(!AnticheatManager.PLAYER_MANAGER.hasLevel(player))
|
||||
if(!getPlayerManager().hasLevel(player))
|
||||
{
|
||||
AnticheatManager.PLAYER_MANAGER.setLevel(player, AnticheatManager.CONFIGURATION.getLevel(player.getName()));
|
||||
getPlayerManager().setLevel(player, getManager().getConfiguration().getLevel(player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +185,17 @@ public class PlayerListener extends EventListener
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, from.getY(), to.getY()))
|
||||
{
|
||||
event.setTo(from);
|
||||
//Lets really give this flyer a real pushdown.
|
||||
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ());
|
||||
Block whatever = newLocation.getBlock();
|
||||
if(whatever.getTypeId() != 0)
|
||||
{
|
||||
event.setTo(newLocation);
|
||||
}
|
||||
/* else
|
||||
{
|
||||
downlow--;
|
||||
}*/
|
||||
log("tried to fly.",player,CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||
@@ -220,7 +232,7 @@ public class PlayerListener extends EventListener
|
||||
event.setTo(from);
|
||||
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SNEAK) && checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkSneak(player,x,z))
|
||||
if(checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player,x,z))
|
||||
{
|
||||
event.setTo(from);
|
||||
player.setSneaking(false);
|
||||
@@ -232,4 +244,4 @@ public class PlayerListener extends EventListener
|
||||
log("tried to climb a wall.",player,CheckType.SPIDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,48 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
public class VehicleListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent event)
|
||||
{
|
||||
if(event.getEntered() instanceof Player)
|
||||
{
|
||||
backend.logEnterExit((Player)event.getEntered());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleExit(VehicleExitEvent event)
|
||||
{
|
||||
if(event.getExited() instanceof Player)
|
||||
{
|
||||
backend.logEnterExit((Player)event.getExited());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.event;
|
||||
|
||||
import net.h31ix.anticheat.manage.Backend;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
public class VehicleListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent event)
|
||||
{
|
||||
if(event.getEntered() instanceof Player)
|
||||
{
|
||||
backend.logEnterExit((Player)event.getEntered());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleExit(VehicleExitEvent event)
|
||||
{
|
||||
if(event.getExited() instanceof Player)
|
||||
{
|
||||
backend.logEnterExit((Player)event.getExited());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,25 +20,65 @@ package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.xray.XRayTracker;
|
||||
|
||||
public final class AnticheatManager
|
||||
public class AnticheatManager
|
||||
{
|
||||
private AnticheatManager()
|
||||
private Anticheat plugin = null;
|
||||
private Configuration CONFIGURATION = null;
|
||||
private XRayTracker XRAY_TRACKER = null;
|
||||
private PlayerManager PLAYER_MANAGER = null;
|
||||
private CheckManager CHECK_MANAGER = null;
|
||||
private Backend BACKEND = null;
|
||||
private Logger LOGGER = null;
|
||||
|
||||
public AnticheatManager(Anticheat instance)
|
||||
{
|
||||
|
||||
plugin = instance;
|
||||
// now load all the others!!!!!
|
||||
CONFIGURATION = new Configuration(this);
|
||||
XRAY_TRACKER = new XRayTracker();
|
||||
PLAYER_MANAGER = new PlayerManager(this);
|
||||
CHECK_MANAGER = new CheckManager(this);
|
||||
BACKEND = new Backend(this);
|
||||
LOGGER = Logger.getLogger("Minecraft");
|
||||
}
|
||||
|
||||
public static final Configuration CONFIGURATION = new Configuration();
|
||||
public static final XRayTracker XRAY_TRACKER = new XRayTracker();
|
||||
public static final PlayerManager PLAYER_MANAGER = new PlayerManager();
|
||||
public static final CheckManager CHECK_MANAGER = new CheckManager();
|
||||
public static final Backend BACKEND = new Backend();
|
||||
private static final Logger ANTICHEAT_LOGGER = Logger.getLogger("Minecraft");
|
||||
|
||||
public static void log(String message)
|
||||
public void log(String message)
|
||||
{
|
||||
ANTICHEAT_LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||
LOGGER.log(Level.WARNING,"[AC] ".concat(message));
|
||||
}
|
||||
|
||||
public Anticheat getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public Configuration getConfiguration()
|
||||
{
|
||||
return CONFIGURATION;
|
||||
}
|
||||
|
||||
public XRayTracker getXRayTracker()
|
||||
{
|
||||
return XRAY_TRACKER;
|
||||
}
|
||||
|
||||
public PlayerManager getPlayerManager()
|
||||
{
|
||||
return PLAYER_MANAGER;
|
||||
}
|
||||
|
||||
public CheckManager getCheckManager()
|
||||
{
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
|
||||
public Backend getBackend()
|
||||
{
|
||||
return BACKEND;
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,9 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -41,6 +41,15 @@ public class Backend
|
||||
public static final int DAMAGE_TIME = 50;
|
||||
public static final int KNOCKBACK_DAMAGE_TIME = 50;
|
||||
|
||||
public static final int FASTBREAK_LIMIT = 3;
|
||||
public static final int FASTBREAK_TIMEMAX = 500;
|
||||
public static final int FASTBREAK_MAXVIOLATIONS = 2;
|
||||
public static final int FASTBREAK_MAXVIOLATIONTIME = 10000;
|
||||
public static final int FASTPLACE_LIMIT = 2;
|
||||
public static final int FASTPLACE_TIMEMAX = 20;
|
||||
public static final int FASTPLACE_MAXVIOLATIONS = 1;
|
||||
public static final int FASTPLACE_MAXVIOLATIONTIME = 10000;
|
||||
|
||||
private static final int CHAT_WARN_LEVEL = 7;
|
||||
private static final int CHAT_KICK_LEVEL = 10;
|
||||
private static final int CHAT_BAN_LEVEL = 3;
|
||||
@@ -71,7 +80,7 @@ public class Backend
|
||||
public static final double XZ_SPEED_MAX_WATER = 0.19;
|
||||
public static final double XZ_SPEED_MAX_WATER_SPRINT = 0.3;
|
||||
|
||||
private Anticheat plugin = Anticheat.getPlugin();
|
||||
private AnticheatManager micromanage = null;
|
||||
private List<String> droppedItem = new ArrayList<String>();
|
||||
private List<String> animated = new ArrayList<String>();
|
||||
private List<String> movingExempt = new ArrayList<String>();
|
||||
@@ -88,6 +97,17 @@ public class Backend
|
||||
private Map<String,Integer> chatLevel = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> chatKicks = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> nofallViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> fastBreakViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> blocksBroken = new HashMap<String,Integer>();
|
||||
private Map<String,Long> lastBlockBroken = new HashMap<String,Long>();
|
||||
private Map<String,Integer> fastPlaceViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> blocksPlaced = new HashMap<String,Integer>();
|
||||
private Map<String,Long> lastBlockPlaced = new HashMap<String,Long>();
|
||||
|
||||
public Backend(AnticheatManager instance)
|
||||
{
|
||||
micromanage = instance;
|
||||
}
|
||||
|
||||
public boolean checkLongReachBlock(double x,double y,double z)
|
||||
{
|
||||
@@ -233,9 +253,26 @@ public class Backend
|
||||
}
|
||||
if(violation >= FLIGHT_LIMIT)
|
||||
{
|
||||
System.out.println("yep");
|
||||
flightViolation.put(name, 1);
|
||||
return true;
|
||||
}
|
||||
//Start Fly bypass patch.
|
||||
if(flightViolation.containsKey(name) && flightViolation.get(name) > 0)
|
||||
{
|
||||
for(int i= 5;i>0;i--)
|
||||
{
|
||||
System.out.println(i);
|
||||
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ());
|
||||
Block lower = newLocation.getBlock();
|
||||
if(lower.getTypeId() == 0)
|
||||
{
|
||||
player.teleport(newLocation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//End Fly bypass patch.
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -248,19 +285,60 @@ public class Backend
|
||||
|
||||
public boolean checkFastBreak(Player player, Block block)
|
||||
{
|
||||
if(player.getGameMode() != GameMode.CREATIVE && !player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES))
|
||||
String name = player.getName();
|
||||
if(!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES && player.getGameMode() != GameMode.CREATIVE))
|
||||
{
|
||||
if (!justBroke(player))
|
||||
if (!fastBreakViolation.containsKey(name))
|
||||
{
|
||||
logBlockBreak(player);
|
||||
fastBreakViolation.put(name, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
player.sendMessage(""+math);
|
||||
if(fastBreakViolation.get(name) > FASTBREAK_MAXVIOLATIONS && math < FASTBREAK_MAXVIOLATIONTIME)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
else if(fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME)
|
||||
{
|
||||
fastBreakViolation.put(name, 0);
|
||||
}
|
||||
}
|
||||
if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name))
|
||||
{
|
||||
if(!lastBlockBroken.containsKey(name))
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
}
|
||||
blocksBroken.put(name, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
blocksBroken.put(name, blocksBroken.get(name)+1);
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX)
|
||||
{
|
||||
blocksBroken.put(name, 0);
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
fastBreakViolation.put(name, fastBreakViolation.get(name)+1);
|
||||
return true;
|
||||
}
|
||||
else if(blocksBroken.get(name) > FASTBREAK_LIMIT)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
blocksBroken.put(name, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkFastPlace(Player player)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void logBowWindUp(Player player)
|
||||
{
|
||||
@@ -425,10 +503,11 @@ public class Backend
|
||||
return droppedItem.contains(player.getName());
|
||||
}
|
||||
|
||||
private void logEvent(final List list, final Player player, long time)
|
||||
@SuppressWarnings("unchecked")
|
||||
private void logEvent(@SuppressWarnings("rawtypes") final List list, final Player player, long time)
|
||||
{
|
||||
list.add(player.getName());
|
||||
Anticheat.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Anticheat.getPlugin(), new Runnable()
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@@ -437,10 +516,11 @@ public class Backend
|
||||
}
|
||||
}, time);
|
||||
}
|
||||
private void logEvent(final Map map, final Player player, final Object obj, long time)
|
||||
@SuppressWarnings("unchecked")
|
||||
private void logEvent(@SuppressWarnings("rawtypes") final Map map, final Player player, final Object obj, long time)
|
||||
{
|
||||
map.put(player,obj);
|
||||
Anticheat.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Anticheat.getPlugin(), new Runnable()
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
@@ -473,14 +553,14 @@ public class Backend
|
||||
if(chatKicks.get(name) <= CHAT_BAN_LEVEL)
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Spamming, kick "+kick+"/3");
|
||||
plugin.getServer().broadcastMessage(ChatColor.RED+player.getName()+" was kicked for spamming.");
|
||||
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was kicked for spamming.");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Banned for spamming.");
|
||||
player.setBanned(true);
|
||||
plugin.getServer().broadcastMessage(ChatColor.RED+player.getName()+" was banned for spamming.");
|
||||
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was banned for spamming.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,9 +31,20 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class CheckManager
|
||||
{
|
||||
public AnticheatManager manager = null;
|
||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||
private static Multimap<Player,CheckType> exemptList = ArrayListMultimap.create();
|
||||
|
||||
/**
|
||||
* Initialize the class.
|
||||
*
|
||||
* @param instance The AntiCheat Manager
|
||||
*/
|
||||
public CheckManager(AnticheatManager instance)
|
||||
{
|
||||
manager = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start running a certain check
|
||||
*
|
||||
@@ -41,7 +52,7 @@ public class CheckManager
|
||||
*/
|
||||
public void activateCheck(CheckType type)
|
||||
{
|
||||
AnticheatManager.log("The "+type.toString()+" check was activated.");
|
||||
manager.log("The "+type.toString()+" check was activated.");
|
||||
checkIgnoreList.remove(type);
|
||||
}
|
||||
|
||||
@@ -52,7 +63,7 @@ public class CheckManager
|
||||
*/
|
||||
public void deactivateCheck(CheckType type)
|
||||
{
|
||||
AnticheatManager.log("The "+type.toString()+" check was deactivated.");
|
||||
manager.log("The "+type.toString()+" check was deactivated.");
|
||||
checkIgnoreList.add(type);
|
||||
}
|
||||
|
||||
@@ -75,7 +86,7 @@ public class CheckManager
|
||||
*/
|
||||
public void exemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
AnticheatManager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
|
||||
manager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
|
||||
exemptList.put(player,type);
|
||||
}
|
||||
|
||||
@@ -87,7 +98,7 @@ public class CheckManager
|
||||
*/
|
||||
public void unexemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
AnticheatManager.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(type, type);
|
||||
}
|
||||
|
||||
@@ -118,7 +129,7 @@ public class CheckManager
|
||||
public boolean willCheck(Player player, CheckType type)
|
||||
{
|
||||
return isActive(type)
|
||||
&& AnticheatManager.CONFIGURATION.checkInWorld(player.getWorld())
|
||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
||||
&& !isExempt(player, type)
|
||||
&& !hasPermission(player, type.getPermission());
|
||||
}
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class Distance
|
||||
{
|
||||
private final Location l1,l2;
|
||||
|
||||
public Distance(Location from, Location to)
|
||||
{
|
||||
l1 = to;
|
||||
l2 = from;
|
||||
}
|
||||
|
||||
public double getXDifference()
|
||||
{
|
||||
return Math.abs(l1.getX()-l2.getX());
|
||||
}
|
||||
|
||||
public double getZDifference()
|
||||
{
|
||||
return Math.abs(l1.getZ()-l2.getZ());
|
||||
}
|
||||
|
||||
public double getYDifference()
|
||||
{
|
||||
return Math.abs(l1.getY()-l2.getY());
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class Distance
|
||||
{
|
||||
private final Location l1,l2;
|
||||
|
||||
public Distance(Location from, Location to)
|
||||
{
|
||||
l1 = to;
|
||||
l2 = from;
|
||||
}
|
||||
|
||||
public double getXDifference()
|
||||
{
|
||||
return Math.abs(l1.getX()-l2.getX());
|
||||
}
|
||||
|
||||
public double getZDifference()
|
||||
{
|
||||
return Math.abs(l1.getZ()-l2.getZ());
|
||||
}
|
||||
|
||||
public double getYDifference()
|
||||
{
|
||||
return Math.abs(l1.getY()-l2.getY());
|
||||
}
|
||||
}
|
||||
@@ -1,141 +1,151 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerManager {
|
||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
private static Configuration config = AnticheatManager.CONFIGURATION;
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
|
||||
private static void reactMedium(Player player)
|
||||
{
|
||||
execute("Medium",player);
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
||||
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
||||
Utilities.alert(alert);
|
||||
}
|
||||
private static void reactHigh(Player player)
|
||||
{
|
||||
execute("High",player);
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
|
||||
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
|
||||
Utilities.alert(alert);
|
||||
}
|
||||
|
||||
public void increaseLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) == null || level.get(name) == 0)
|
||||
{
|
||||
level.put(name,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int playerLevel = level.get(name);
|
||||
level.put(name, playerLevel+1);
|
||||
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
|
||||
{
|
||||
reactMedium(player);
|
||||
}
|
||||
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
|
||||
{
|
||||
reactHigh(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decreaseLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) != null && level.get(name) != 0)
|
||||
{
|
||||
int playerLevel = level.get(name)-1;
|
||||
level.put(name, playerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) != null)
|
||||
{
|
||||
return level.get(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(Player player, int x)
|
||||
{
|
||||
level.put(player.getName(), x);
|
||||
}
|
||||
|
||||
public boolean hasLevel(Player player)
|
||||
{
|
||||
return level.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void reset(Player player)
|
||||
{
|
||||
level.put(player.getName(),0);
|
||||
}
|
||||
|
||||
public Map<String,Integer> getLevels()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
private static void execute(String level, Player player)
|
||||
{
|
||||
String result = config.getResult(level);
|
||||
if(result.startsWith("COMMAND["))
|
||||
{
|
||||
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
else if(result.equalsIgnoreCase("KICK"))
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
|
||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
|
||||
}
|
||||
else if(result.equalsIgnoreCase("WARN"))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
|
||||
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
|
||||
}
|
||||
else if(result.equalsIgnoreCase("BAN"))
|
||||
{
|
||||
player.setBanned(true);
|
||||
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
|
||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerManager {
|
||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
private static Configuration config = null;
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
|
||||
public PlayerManager(AnticheatManager instance) {
|
||||
config = instance.getConfiguration();
|
||||
}
|
||||
|
||||
private static void reactMedium(Player player)
|
||||
{
|
||||
execute("Medium",player);
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.YELLOW+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.YELLOW+" has entered the MEDIUM hack level.";
|
||||
alert[1] = ChatColor.YELLOW+"[ALERT] This means they may be using a hacked client or may have a bad connection!";
|
||||
Utilities.alert(alert);
|
||||
}
|
||||
private static void reactHigh(Player player)
|
||||
{
|
||||
execute("High",player);
|
||||
String [] alert = new String[2];
|
||||
alert[0] = ChatColor.RED+"[ALERT] "+ChatColor.WHITE+player.getName()+ChatColor.RED+" has entered the HIGH hack level.";
|
||||
alert[1] = ChatColor.RED+"[ALERT] This means they probably are hacking or are lagging out!";
|
||||
Utilities.alert(alert);
|
||||
}
|
||||
|
||||
public void increaseLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) == null || level.get(name) == 0)
|
||||
{
|
||||
level.put(name,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int playerLevel = level.get(name);
|
||||
level.put(name, playerLevel+1);
|
||||
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
|
||||
{
|
||||
reactMedium(player);
|
||||
}
|
||||
else if(playerLevel <= HIGH_THRESHOLD && playerLevel+1 > HIGH_THRESHOLD)
|
||||
{
|
||||
reactHigh(player);
|
||||
level.put(player.getName(), MED_THRESHOLD+5);
|
||||
}
|
||||
else if (playerLevel > HIGH_THRESHOLD)
|
||||
{
|
||||
level.put(player.getName(), MED_THRESHOLD+5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void decreaseLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) != null && level.get(name) != 0)
|
||||
{
|
||||
int playerLevel = level.get(name)-1;
|
||||
level.put(name, playerLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) != null)
|
||||
{
|
||||
return level.get(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLevel(Player player, int x)
|
||||
{
|
||||
level.put(player.getName(), x);
|
||||
}
|
||||
|
||||
public boolean hasLevel(Player player)
|
||||
{
|
||||
return level.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void reset(Player player)
|
||||
{
|
||||
level.put(player.getName(),0);
|
||||
}
|
||||
|
||||
public Map<String,Integer> getLevels()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
private static void execute(String level, Player player)
|
||||
{
|
||||
String result = config.getResult(level);
|
||||
if(result.startsWith("COMMAND["))
|
||||
{
|
||||
String command = result.replaceAll("COMMAND\\[", "").replaceAll("]", "").replaceAll("&player", player.getName());
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
else if(result.equalsIgnoreCase("KICK"))
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Kicked by AntiCheat");
|
||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was kicked for hacking.");
|
||||
}
|
||||
else if(result.equalsIgnoreCase("WARN"))
|
||||
{
|
||||
player.sendMessage(ChatColor.RED+"[AntiCheat] Hacks are not allowed on this server.");
|
||||
player.sendMessage(ChatColor.RED+"[AntiCheat] If you continue to use hacks, action will be taken.");
|
||||
}
|
||||
else if(result.equalsIgnoreCase("BAN"))
|
||||
{
|
||||
player.setBanned(true);
|
||||
player.kickPlayer(ChatColor.RED+"Banned by AntiCheat");
|
||||
player.getServer().broadcastMessage(ChatColor.RED+"[AntiCheat] "+player.getName()+" was banned for hacking.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -50,7 +53,7 @@ public final class Utilities
|
||||
}
|
||||
}
|
||||
}
|
||||
if(AnticheatManager.CONFIGURATION.logConsole())
|
||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||
{
|
||||
Logger logger = Logger.getLogger("Minecraft");
|
||||
for(String msg : message)
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package net.h31ix.anticheat.xray;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.Configuration;
|
||||
import net.h31ix.anticheat.manage.AnticheatManager;
|
||||
import net.h31ix.anticheat.manage.CheckManager;
|
||||
import net.h31ix.anticheat.manage.CheckType;
|
||||
import org.bukkit.Material;
|
||||
@@ -29,9 +29,9 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class XRayListener implements Listener {
|
||||
private XRayTracker tracker = AnticheatManager.XRAY_TRACKER;
|
||||
private Configuration config = AnticheatManager.CONFIGURATION;
|
||||
private CheckManager checkManager = AnticheatManager.CHECK_MANAGER;
|
||||
private XRayTracker tracker = Anticheat.getManager().getXRayTracker();
|
||||
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||
private CheckManager checkManager = Anticheat.getManager().getCheckManager();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
|
||||
@@ -1,109 +1,109 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.xray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class XRayStats {
|
||||
private static final int DIVISOR = 100;
|
||||
private double t = 1;
|
||||
private double d = 0;
|
||||
private double g = 0;
|
||||
private double i = 0;
|
||||
private double c = 0;
|
||||
private double l = 0;
|
||||
private double r = 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)
|
||||
{
|
||||
if(total.get(player) != null)
|
||||
{
|
||||
t = total.get(player);
|
||||
}
|
||||
if(diamond.get(player) != null)
|
||||
{
|
||||
d = (diamond.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(gold.get(player) != null)
|
||||
{
|
||||
g = (gold.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(iron.get(player) != null)
|
||||
{
|
||||
i = (iron.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(coal.get(player) != null)
|
||||
{
|
||||
c = (coal.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(lapis.get(player) != null)
|
||||
{
|
||||
l = (lapis.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(redstone.get(player) != null)
|
||||
{
|
||||
r = (redstone.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(other.get(player) != null)
|
||||
{
|
||||
o = (other.get(player)/t)*DIVISOR;
|
||||
}
|
||||
}
|
||||
|
||||
public double getTotal()
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
public double getDiamond()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
public double getGold()
|
||||
{
|
||||
return g;
|
||||
}
|
||||
|
||||
public double getIron()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
public double getCoal()
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
public double getLapis()
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
public double getRedstone()
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
public double getOther()
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.xray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class XRayStats {
|
||||
private static final int DIVISOR = 100;
|
||||
private double t = 1;
|
||||
private double d = 0;
|
||||
private double g = 0;
|
||||
private double i = 0;
|
||||
private double c = 0;
|
||||
private double l = 0;
|
||||
private double r = 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)
|
||||
{
|
||||
if(total.get(player) != null)
|
||||
{
|
||||
t = total.get(player);
|
||||
}
|
||||
if(diamond.get(player) != null)
|
||||
{
|
||||
d = (diamond.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(gold.get(player) != null)
|
||||
{
|
||||
g = (gold.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(iron.get(player) != null)
|
||||
{
|
||||
i = (iron.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(coal.get(player) != null)
|
||||
{
|
||||
c = (coal.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(lapis.get(player) != null)
|
||||
{
|
||||
l = (lapis.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(redstone.get(player) != null)
|
||||
{
|
||||
r = (redstone.get(player)/t)*DIVISOR;
|
||||
}
|
||||
if(other.get(player) != null)
|
||||
{
|
||||
o = (other.get(player)/t)*DIVISOR;
|
||||
}
|
||||
}
|
||||
|
||||
public double getTotal()
|
||||
{
|
||||
return t;
|
||||
}
|
||||
|
||||
public double getDiamond()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
public double getGold()
|
||||
{
|
||||
return g;
|
||||
}
|
||||
|
||||
public double getIron()
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
public double getCoal()
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
public double getLapis()
|
||||
{
|
||||
return l;
|
||||
}
|
||||
|
||||
public double getRedstone()
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
public double getOther()
|
||||
{
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,6 @@ public class XRayTracker {
|
||||
|
||||
public XRayTracker()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean sufficientData(String player)
|
||||
|
||||
Reference in new issue
Block a user