mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-04 14:38:47 +00:00
Merge branch 'master' of github.com:h31ix/AntiCheat into development
Conflicts: src/main/java/net/h31ix/anticheat/event/PlayerListener.java src/main/java/net/h31ix/anticheat/manage/Backend.java src/main/java/net/h31ix/anticheat/manage/Distance.java src/main/java/net/h31ix/anticheat/util/Utilities.java
This commit is contained in:
commit
92d2868802
24 files changed
+914
-890
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -102,9 +102,9 @@ public class Anticheat extends JavaPlugin
|
||||
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+".";
|
||||
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);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class Anticheat extends JavaPlugin
|
||||
}
|
||||
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)
|
||||
{
|
||||
@@ -201,10 +201,10 @@ public class Anticheat extends JavaPlugin
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
String name = player.getName();
|
||||
manager.getPlayerManager().setLevel(player,config.getLevel(name));
|
||||
manager.getPlayerManager().setLevel(player, config.getLevel(name));
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "Data for "+player.getName()+" re-applied from flatfile");
|
||||
logger.log(Level.INFO, "Data for " + player.getName() + " re-applied from flatfile");
|
||||
}
|
||||
}
|
||||
if (verbose)
|
||||
@@ -250,7 +250,7 @@ public class Anticheat extends JavaPlugin
|
||||
}
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"AntiCheat update has been downloaded and will be installed on next launch.");
|
||||
logger.log(Level.INFO, "AntiCheat update has been downloaded and will be installed on next launch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -262,15 +262,15 @@ public class Anticheat extends JavaPlugin
|
||||
saveDefaultConfig();
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "Config file created.");
|
||||
logger.log(Level.INFO, "Config file created.");
|
||||
}
|
||||
}
|
||||
if (!new File(getDataFolder() + "/lang.yml").exists())
|
||||
{
|
||||
saveResource("lang.yml",false);
|
||||
saveResource("lang.yml", false);
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO, "Lang file created.");
|
||||
logger.log(Level.INFO, "Lang file created.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public class Anticheat extends JavaPlugin
|
||||
update = true;
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"Your dev build has been promoted to release. Downloading the update.");
|
||||
logger.log(Level.INFO, "Your dev build has been promoted to release. Downloading the update.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -325,7 +325,7 @@ public class Anticheat extends JavaPlugin
|
||||
update = false;
|
||||
if (verbose)
|
||||
{
|
||||
logger.log(Level.INFO,"Dev build detected, so skipping update checking until this version is released.");
|
||||
logger.log(Level.INFO, "Dev build detected, so skipping update checking until this version is released.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -48,43 +48,43 @@ public class CommandHandler implements CommandExecutor
|
||||
private List<String> high = new ArrayList<String>();
|
||||
private List<String> med = new ArrayList<String>();
|
||||
private List<String> low = new ArrayList<String>();
|
||||
private Map<String,Location> spyLocation = new HashMap<String,Location>();
|
||||
private Map<String, Location> spyLocation = new HashMap<String, Location>();
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
private static final int HIGH_THRESHOLD = 50;
|
||||
private static final String PERMISSIONS_ERROR = RED+"Insufficient Permissions.";
|
||||
private static final String PERMISSIONS_ERROR = RED + "Insufficient Permissions.";
|
||||
|
||||
public void handleLog(CommandSender cs, String [] args)
|
||||
public void handleLog(CommandSender cs, String[] args)
|
||||
{
|
||||
if(Permission.SYSTEM_LOG.get(cs))
|
||||
if (Permission.SYSTEM_LOG.get(cs))
|
||||
{
|
||||
if(args[1].equalsIgnoreCase("enable"))
|
||||
if (args[1].equalsIgnoreCase("enable"))
|
||||
{
|
||||
if(!config.logConsole())
|
||||
if (!config.logConsole())
|
||||
{
|
||||
config.setLog(true);
|
||||
cs.sendMessage(GREEN+"Console logging enabled.");
|
||||
cs.sendMessage(GREEN + "Console logging enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GREEN+"Console logging is already enabled!");
|
||||
cs.sendMessage(GREEN + "Console logging is already enabled!");
|
||||
}
|
||||
}
|
||||
else if(args[1].equalsIgnoreCase("disable"))
|
||||
else if (args[1].equalsIgnoreCase("disable"))
|
||||
{
|
||||
if(config.logConsole())
|
||||
if (config.logConsole())
|
||||
{
|
||||
config.setLog(false);
|
||||
cs.sendMessage(GREEN+"Console logging disabled.");
|
||||
cs.sendMessage(GREEN + "Console logging disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GREEN+"Console logging is already disabled!");
|
||||
cs.sendMessage(GREEN + "Console logging is already disabled!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Usage: /anticheat log [enable/disable]");
|
||||
cs.sendMessage(RED + "Usage: /anticheat log [enable/disable]");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -93,43 +93,43 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public void handleXRay(CommandSender cs, String [] args)
|
||||
public void handleXRay(CommandSender cs, String[] args)
|
||||
{
|
||||
if(Permission.SYSTEM_XRAY.get(cs))
|
||||
if (Permission.SYSTEM_XRAY.get(cs))
|
||||
{
|
||||
if(config.logXRay())
|
||||
if (config.logXRay())
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
if (list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
if(xtracker.sufficientData(player.getName()))
|
||||
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.");
|
||||
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)
|
||||
else if (list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||
}
|
||||
else if(xtracker.sufficientData(args[1]))
|
||||
else if (xtracker.sufficientData(args[1]))
|
||||
{
|
||||
xtracker.sendStats(cs, args[1]);
|
||||
xtracker.sendStats(cs, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Insufficient data collected from "+WHITE+args[1]+RED+".");
|
||||
cs.sendMessage(RED+"Please wait until more info is collected before predictions are calculated.");
|
||||
cs.sendMessage(RED + "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.");
|
||||
cs.sendMessage(RED + "XRay logging is off in the config.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -138,33 +138,33 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public void handleReset(CommandSender cs, String [] args)
|
||||
public void handleReset(CommandSender cs, String[] args)
|
||||
{
|
||||
if(Permission.SYSTEM_RESET.get(cs))
|
||||
if (Permission.SYSTEM_RESET.get(cs))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
if (list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
if(playerManager.getLevel(player) == 0)
|
||||
if (playerManager.getLevel(player) == 0)
|
||||
{
|
||||
cs.sendMessage(player.getName()+RED+" is already in Low Level!");
|
||||
cs.sendMessage(player.getName() + RED + " is already in Low Level!");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerManager.reset(player);
|
||||
cs.sendMessage(player.getName()+GREEN+" has been reset to Low Level.");
|
||||
cs.sendMessage(player.getName() + GREEN + " has been reset to Low Level.");
|
||||
}
|
||||
xtracker.reset(player.getName());
|
||||
cs.sendMessage(player.getName()+GREEN+"'s XRay stats have been reset.");
|
||||
cs.sendMessage(player.getName() + GREEN + "'s XRay stats have been reset.");
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
else if (list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -173,20 +173,20 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSpy(CommandSender cs, String [] args)
|
||||
public void handleSpy(CommandSender cs, String[] args)
|
||||
{
|
||||
if(cs instanceof Player)
|
||||
if (cs instanceof Player)
|
||||
{
|
||||
Player sender = (Player)cs;
|
||||
if(Permission.SYSTEM_SPY.get(cs))
|
||||
Player sender = (Player) cs;
|
||||
if (Permission.SYSTEM_SPY.get(cs))
|
||||
{
|
||||
if(!args[1].equalsIgnoreCase("off"))
|
||||
if (!args[1].equalsIgnoreCase("off"))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
if (list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
for(Player p : cs.getServer().getOnlinePlayers())
|
||||
for (Player p : cs.getServer().getOnlinePlayers())
|
||||
{
|
||||
p.hidePlayer(sender);
|
||||
}
|
||||
@@ -194,28 +194,28 @@ public class CommandHandler implements CommandExecutor
|
||||
sender.setFlying(true);
|
||||
spyLocation.put(sender.getName(), sender.getLocation());
|
||||
sender.teleport(player);
|
||||
sender.sendMessage(GREEN+"You have been teleported to "+player.getName()+" and made invisible.");
|
||||
sender.sendMessage(GREEN+"To stop spying, type "+WHITE+" /AntiCheat spy off");
|
||||
sender.sendMessage(GREEN + "You have been teleported to " + player.getName() + " and made invisible.");
|
||||
sender.sendMessage(GREEN + "To stop spying, type " + WHITE + " /AntiCheat spy off");
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
else if (list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.setFlying(false);
|
||||
sender.setAllowFlight(false);
|
||||
if(spyLocation.containsKey(sender.getName()))
|
||||
if (spyLocation.containsKey(sender.getName()))
|
||||
{
|
||||
sender.teleport(spyLocation.get(sender.getName()));
|
||||
spyLocation.remove(sender.getName());
|
||||
}
|
||||
for(Player p : cs.getServer().getOnlinePlayers())
|
||||
for (Player p : cs.getServer().getOnlinePlayers())
|
||||
{
|
||||
p.showPlayer(sender);
|
||||
}
|
||||
@@ -228,25 +228,25 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Sorry, but you can't spy on a player from the console.");
|
||||
cs.sendMessage(RED + "Sorry, but you can't spy on a player from the console.");
|
||||
}
|
||||
}
|
||||
|
||||
public void handleHelp(CommandSender cs)
|
||||
{
|
||||
if(Permission.SYSTEM_HELP.get(cs))
|
||||
if (Permission.SYSTEM_HELP.get(cs))
|
||||
{
|
||||
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+"report [user]"+WHITE+" - get a player's 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+"spy [user]"+WHITE+" - spy on a user in secret");
|
||||
cs.sendMessage(base+GREEN+"help"+WHITE+" - access this page");
|
||||
cs.sendMessage(base+GREEN+"update"+WHITE+" - check update status");
|
||||
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 + "report [user]" + WHITE + " - get a player's 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 + "spy [user]" + WHITE + " - spy on a user in secret");
|
||||
cs.sendMessage(base + GREEN + "help" + WHITE + " - access this page");
|
||||
cs.sendMessage(base + GREEN + "update" + WHITE + " - check update status");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
}
|
||||
else
|
||||
@@ -257,26 +257,26 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleUpdate(CommandSender cs)
|
||||
{
|
||||
if(Permission.SYSTEM_UPDATE.get(cs))
|
||||
if (Permission.SYSTEM_UPDATE.get(cs))
|
||||
{
|
||||
cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion());
|
||||
cs.sendMessage("Running " + GREEN + "AntiCheat " + WHITE + "v" + GREEN + Anticheat.getVersion());
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
if(!Anticheat.isUpdated())
|
||||
if (!Anticheat.isUpdated())
|
||||
{
|
||||
cs.sendMessage(GRAY+"There "+GREEN+"IS"+GRAY+" a newer version avaliable.");
|
||||
if(config.autoUpdate())
|
||||
cs.sendMessage(GRAY + "There " + GREEN + "IS" + GRAY + " a newer version avaliable.");
|
||||
if (config.autoUpdate())
|
||||
{
|
||||
cs.sendMessage(GRAY+"It will be installed automatically for you on next launch.");
|
||||
cs.sendMessage(GRAY + "It will be installed automatically for you on next launch.");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GRAY+"Due to your config settings, we "+RED+"can not"+GRAY+" auto update.");
|
||||
cs.sendMessage(GRAY+"Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||
cs.sendMessage(GRAY + "Due to your config settings, we " + RED + "can not" + GRAY + " auto update.");
|
||||
cs.sendMessage(GRAY + "Please visit http://dev.bukkit.org/server-mods/anticheat/");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(GRAY+"AntiCheat is "+GREEN+"UP TO DATE!");
|
||||
cs.sendMessage(GRAY + "AntiCheat is " + GREEN + "UP TO DATE!");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -287,31 +287,31 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReport(CommandSender cs)
|
||||
{
|
||||
if(Permission.SYSTEM_REPORT.get(cs))
|
||||
if (Permission.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
getPlayers();
|
||||
if(!low.isEmpty())
|
||||
if (!low.isEmpty())
|
||||
{
|
||||
cs.sendMessage(GREEN+"----Level: Low (Not likely hacking)----");
|
||||
for(String string : low)
|
||||
cs.sendMessage(GREEN + "----Level: Low (Not likely hacking)----");
|
||||
for (String string : low)
|
||||
{
|
||||
cs.sendMessage(GREEN+string);
|
||||
cs.sendMessage(GREEN + string);
|
||||
}
|
||||
}
|
||||
if(!med.isEmpty())
|
||||
if (!med.isEmpty())
|
||||
{
|
||||
cs.sendMessage(YELLOW+"----Level: Medium (Possibly hacking/lagging)----");
|
||||
for(String string : med)
|
||||
cs.sendMessage(YELLOW + "----Level: Medium (Possibly hacking/lagging)----");
|
||||
for (String string : med)
|
||||
{
|
||||
cs.sendMessage(YELLOW+string);
|
||||
cs.sendMessage(YELLOW + string);
|
||||
}
|
||||
}
|
||||
if(!high.isEmpty())
|
||||
if (!high.isEmpty())
|
||||
{
|
||||
cs.sendMessage(RED+"----Level: High (Probably hacking or bad connection)----");
|
||||
for(String string : high)
|
||||
cs.sendMessage(RED + "----Level: High (Probably hacking or bad connection)----");
|
||||
for (String string : high)
|
||||
{
|
||||
cs.sendMessage(RED+string);
|
||||
cs.sendMessage(RED + string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,42 +321,42 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePlayerReport(CommandSender cs,String [] args)
|
||||
public void handlePlayerReport(CommandSender cs, String[] args)
|
||||
{
|
||||
if(Permission.SYSTEM_REPORT.get(cs))
|
||||
if (Permission.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
List<Player> list = SERVER.matchPlayer(args[1]);
|
||||
if(list.size() == 1)
|
||||
if (list.size() == 1)
|
||||
{
|
||||
Player player = list.get(0);
|
||||
if(args.length == 2)
|
||||
if (args.length == 2)
|
||||
{
|
||||
sendPlayerReport(cs,CheckType.values(),player,1);
|
||||
sendPlayerReport(cs, CheckType.values(), player, 1);
|
||||
}
|
||||
else if(Utilities.isInt(args[2]))
|
||||
else if (Utilities.isInt(args[2]))
|
||||
{
|
||||
int num = Integer.parseInt(args[2]);
|
||||
if(num <= 3 && num > 1)
|
||||
if (num <= 3 && num > 1)
|
||||
{
|
||||
sendPlayerReport(cs,CheckType.values(),player,num);
|
||||
sendPlayerReport(cs, CheckType.values(), player, num);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Page: "+num+RED+" does not exist.");
|
||||
cs.sendMessage(RED + "Page: " + num + RED + " does not exist.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Not a valid page number: "+WHITE+args[2]);
|
||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[2]);
|
||||
}
|
||||
}
|
||||
else if(list.size() > 1)
|
||||
else if (list.size() > 1)
|
||||
{
|
||||
cs.sendMessage(RED+"Multiple players found by name: "+WHITE+args[1]+RED+".");
|
||||
cs.sendMessage(RED + "Multiple players found by name: " + WHITE + args[1] + RED + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Player: "+WHITE+args[1]+RED+" not found.");
|
||||
cs.sendMessage(RED + "Player: " + WHITE + args[1] + RED + " not found.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -367,26 +367,26 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void sendPlayerReport(CommandSender cs, CheckType[] types, Player player, int page)
|
||||
{
|
||||
cs.sendMessage("--------------------["+GREEN+"REPORT["+page+"/3]"+WHITE+"]---------------------");
|
||||
if(page == 1)
|
||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/3]" + WHITE + "]---------------------");
|
||||
if (page == 1)
|
||||
{
|
||||
int level = playerManager.getLevel(player);
|
||||
String levelString = GREEN+"Low";
|
||||
if(level >= 20)
|
||||
String levelString = GREEN + "Low";
|
||||
if (level >= 20)
|
||||
{
|
||||
levelString = YELLOW+"Medium";
|
||||
levelString = YELLOW + "Medium";
|
||||
}
|
||||
else if (level >= 50)
|
||||
{
|
||||
levelString = RED+"High";
|
||||
levelString = RED + "High";
|
||||
}
|
||||
cs.sendMessage(GRAY+"Player: "+WHITE+player.getName());
|
||||
cs.sendMessage(GRAY+"Level: "+levelString);
|
||||
for(int i=0;i<6;i++)
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + player.getName());
|
||||
cs.sendMessage(GRAY + "Level: " + levelString);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int use = types[i].getUses(player);
|
||||
ChatColor color = WHITE;
|
||||
if(use >= 20)
|
||||
if (use >= 20)
|
||||
{
|
||||
color = YELLOW;
|
||||
}
|
||||
@@ -394,16 +394,16 @@ public class CommandHandler implements CommandExecutor
|
||||
{
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY+CheckType.getName(types[i])+": "+color+use);
|
||||
cs.sendMessage(GRAY + CheckType.getName(types[i]) + ": " + color + use);
|
||||
}
|
||||
}
|
||||
else if(page == 2)
|
||||
else if (page == 2)
|
||||
{
|
||||
for(int i=6;i<14;i++)
|
||||
for (int i = 6; i < 14; i++)
|
||||
{
|
||||
int use = types[i].getUses(player);
|
||||
ChatColor color = WHITE;
|
||||
if(use >= 20)
|
||||
if (use >= 20)
|
||||
{
|
||||
color = YELLOW;
|
||||
}
|
||||
@@ -411,16 +411,16 @@ public class CommandHandler implements CommandExecutor
|
||||
{
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY+CheckType.getName(types[i])+": "+color+use);
|
||||
cs.sendMessage(GRAY + CheckType.getName(types[i]) + ": " + color + use);
|
||||
}
|
||||
}
|
||||
else if(page == 3)
|
||||
else if (page == 3)
|
||||
{
|
||||
for(int i=14;i<21;i++)
|
||||
for (int i = 14; i < 21; i++)
|
||||
{
|
||||
int use = types[i].getUses(player);
|
||||
ChatColor color = WHITE;
|
||||
if(use >= 20)
|
||||
if (use >= 20)
|
||||
{
|
||||
color = YELLOW;
|
||||
}
|
||||
@@ -428,7 +428,7 @@ public class CommandHandler implements CommandExecutor
|
||||
{
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY+CheckType.getName(types[i])+": "+color+use);
|
||||
cs.sendMessage(GRAY + CheckType.getName(types[i]) + ": " + color + use);
|
||||
}
|
||||
}
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
@@ -437,10 +437,10 @@ public class CommandHandler implements CommandExecutor
|
||||
|
||||
public void handleReload(CommandSender cs)
|
||||
{
|
||||
if(Permission.SYSTEM_RELOAD.get(cs))
|
||||
if (Permission.SYSTEM_RELOAD.get(cs))
|
||||
{
|
||||
config.load();
|
||||
cs.sendMessage(GREEN+"AntiCheat configuration reloaded.");
|
||||
cs.sendMessage(GREEN + "AntiCheat configuration reloaded.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -451,66 +451,66 @@ public class CommandHandler implements CommandExecutor
|
||||
@Override
|
||||
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args)
|
||||
{
|
||||
if(args.length == 3)
|
||||
if (args.length == 3)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("report"))
|
||||
if (args[0].equalsIgnoreCase("report"))
|
||||
{
|
||||
handlePlayerReport(cs,args);
|
||||
handlePlayerReport(cs, args);
|
||||
}
|
||||
}
|
||||
else if(args.length == 2)
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("log"))
|
||||
if (args[0].equalsIgnoreCase("log"))
|
||||
{
|
||||
handleLog(cs,args);
|
||||
handleLog(cs, args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("xray"))
|
||||
else if (args[0].equalsIgnoreCase("xray"))
|
||||
{
|
||||
handleXRay(cs,args);
|
||||
handleXRay(cs, args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("reset"))
|
||||
else if (args[0].equalsIgnoreCase("reset"))
|
||||
{
|
||||
handleReset(cs,args);
|
||||
handleReset(cs, args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("spy"))
|
||||
else if (args[0].equalsIgnoreCase("spy"))
|
||||
{
|
||||
handleSpy(cs,args);
|
||||
handleSpy(cs, args);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("report"))
|
||||
else if (args[0].equalsIgnoreCase("report"))
|
||||
{
|
||||
handlePlayerReport(cs,args);
|
||||
handlePlayerReport(cs, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command.");
|
||||
cs.sendMessage(RED + "Unrecognized command.");
|
||||
}
|
||||
}
|
||||
else if (args.length == 1)
|
||||
{
|
||||
if(args[0].equalsIgnoreCase("help"))
|
||||
if (args[0].equalsIgnoreCase("help"))
|
||||
{
|
||||
handleHelp(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("report"))
|
||||
else if (args[0].equalsIgnoreCase("report"))
|
||||
{
|
||||
handleReport(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("reload"))
|
||||
else if (args[0].equalsIgnoreCase("reload"))
|
||||
{
|
||||
handleReload(cs);
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("update"))
|
||||
else if (args[0].equalsIgnoreCase("update"))
|
||||
{
|
||||
handleUpdate(cs);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command.");
|
||||
cs.sendMessage(RED + "Unrecognized command.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cs.sendMessage(RED+"Unrecognized command. Try "+ChatColor.WHITE+"/anticheat help");
|
||||
cs.sendMessage(RED + "Unrecognized command. Try " + ChatColor.WHITE + "/anticheat help");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -520,14 +520,14 @@ public class CommandHandler implements CommandExecutor
|
||||
high.clear();
|
||||
med.clear();
|
||||
low.clear();
|
||||
for(Player player : SERVER.getOnlinePlayers())
|
||||
for (Player player : SERVER.getOnlinePlayers())
|
||||
{
|
||||
int level = playerManager.getLevel(player);
|
||||
if(level <= MED_THRESHOLD)
|
||||
if (level <= MED_THRESHOLD)
|
||||
{
|
||||
low.add(player.getName());
|
||||
}
|
||||
else if(level <= HIGH_THRESHOLD)
|
||||
else if (level <= HIGH_THRESHOLD)
|
||||
{
|
||||
med.add(player.getName());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -54,11 +54,11 @@ public class 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");
|
||||
langFile = new File(micromanage.getPlugin().getDataFolder()+"/lang.yml");
|
||||
micromanage = instance;
|
||||
configFile = new File(micromanage.getPlugin().getDataFolder() + "/config.yml");
|
||||
levelFile = new File(micromanage.getPlugin().getDataFolder() + "/data/level.yml");
|
||||
bukkitFile = new File("bukkit.yml");
|
||||
langFile = new File(micromanage.getPlugin().getDataFolder() + "/lang.yml");
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -134,18 +134,18 @@ public class Configuration
|
||||
lang = YamlConfiguration.loadConfiguration(langFile);
|
||||
language = new Language(lang);
|
||||
updateFolder = bukkit.getString("settings.update-folder");
|
||||
if(config.getString("Logging.Log to console") != null)
|
||||
if (config.getString("Logging.Log to console") != null)
|
||||
{
|
||||
boolean b = config.getBoolean("Logging.Log to console");
|
||||
config.set("Logging", null);
|
||||
config.set("System.Log to console",b);
|
||||
config.set("System.Log to console", b);
|
||||
save();
|
||||
}
|
||||
logConsole = config.getBoolean("System.Log to console");
|
||||
if(config.getList("Enable in") == null)
|
||||
if (config.getList("Enable in") == null)
|
||||
{
|
||||
List<String> w = new ArrayList<String>();
|
||||
for(World world : Bukkit.getServer().getWorlds())
|
||||
for (World world : Bukkit.getServer().getWorlds())
|
||||
{
|
||||
w.add(world.getName());
|
||||
}
|
||||
@@ -153,43 +153,43 @@ public class Configuration
|
||||
save();
|
||||
}
|
||||
worlds = config.getStringList("Enable in");
|
||||
if(config.getString("XRay.Log xray stats") == null)
|
||||
if (config.getString("XRay.Log xray stats") == null)
|
||||
{
|
||||
config.set("XRay.Log xray stats", true);
|
||||
save();
|
||||
}
|
||||
logXRay = config.getBoolean("XRay.Log xray stats");
|
||||
if(config.getString("System.Auto update") == null)
|
||||
if (config.getString("System.Auto update") == null)
|
||||
{
|
||||
config.set("System.Auto update", true);
|
||||
save();
|
||||
}
|
||||
autoUpdate = config.getBoolean("System.Auto update");
|
||||
if(config.getString("System.Verbose startup") == null)
|
||||
if (config.getString("System.Verbose startup") == null)
|
||||
{
|
||||
config.set("System.Verbose startup", false);
|
||||
save();
|
||||
}
|
||||
verboseStartup = config.getBoolean("System.Verbose startup");
|
||||
if(config.getString("XRay.Alert when xray is found") == null)
|
||||
if (config.getString("XRay.Alert when xray is found") == null)
|
||||
{
|
||||
config.set("XRay.Alert when xray is found", false);
|
||||
save();
|
||||
}
|
||||
alertXRay = config.getBoolean("XRay.Alert when xray is found");
|
||||
if(config.getString("System.File log level") == null)
|
||||
if (config.getString("System.File log level") == null)
|
||||
{
|
||||
config.set("System.File log level", 1);
|
||||
save();
|
||||
}
|
||||
fileLogLevel = config.getInt("System.File log level");
|
||||
if(config.getString("System.Block chat spam") == null)
|
||||
if (config.getString("System.Block chat spam") == null)
|
||||
{
|
||||
config.set("System.Block chat spam", true);
|
||||
save();
|
||||
}
|
||||
chatSpam = config.getBoolean("System.Block chat spam");
|
||||
if(config.getString("System.Block command spam") == null)
|
||||
if (config.getString("System.Block command spam") == null)
|
||||
{
|
||||
config.set("System.Block command spam", true);
|
||||
save();
|
||||
@@ -199,7 +199,7 @@ public class Configuration
|
||||
|
||||
public String getResult(String event)
|
||||
{
|
||||
return config.getString("Events.Level "+event);
|
||||
return config.getString("Events.Level " + event);
|
||||
}
|
||||
|
||||
public void setLog(boolean b)
|
||||
@@ -239,7 +239,7 @@ public class Configuration
|
||||
public int getLevel(String player)
|
||||
{
|
||||
int x = 0;
|
||||
if(level.getString(player) != null)
|
||||
if (level.getString(player) != null)
|
||||
{
|
||||
x = level.getInt(player);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class Configuration
|
||||
|
||||
public void saveLevel(String player, int x)
|
||||
{
|
||||
level.set(player,x);
|
||||
level.set(player, x);
|
||||
}
|
||||
|
||||
public void saveLevels()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -41,17 +41,17 @@ public class Language
|
||||
kickBroadcast = file.getString("kick.kick_broadcast");
|
||||
}
|
||||
|
||||
public String [] getMediumAlert()
|
||||
public String[] getMediumAlert()
|
||||
{
|
||||
return medAlert;
|
||||
}
|
||||
|
||||
public String [] getHighAlert()
|
||||
public String[] getHighAlert()
|
||||
{
|
||||
return highAlert;
|
||||
}
|
||||
|
||||
public String [] getWarning()
|
||||
public String[] getWarning()
|
||||
{
|
||||
return warning;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -45,6 +45,7 @@ public enum Permission
|
||||
CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE,
|
||||
CHECK_ITEMSPAM,
|
||||
CHECK_INTERACTION,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,7 +31,6 @@ import org.bukkit.entity.Player;
|
||||
* Developer's interface for all things AntiCheat.
|
||||
*/
|
||||
|
||||
|
||||
public class AnticheatAPI
|
||||
{
|
||||
private static CheckManager chk = Anticheat.getManager().getCheckManager();
|
||||
@@ -43,17 +42,19 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Start running a certain check
|
||||
*
|
||||
* @param type Check to start watching for
|
||||
* @param type
|
||||
* Check to start watching for
|
||||
*/
|
||||
public static void activateCheck(CheckType type)
|
||||
{
|
||||
chk.activateCheck(type);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Stop running a certain check
|
||||
*
|
||||
* @param type Check to stop watching for
|
||||
* @param type
|
||||
* Check to stop watching for
|
||||
*/
|
||||
public static void deactivateCheck(CheckType type)
|
||||
{
|
||||
@@ -63,7 +64,8 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Find out if a check is currently being watched for
|
||||
*
|
||||
* @param type Type to check
|
||||
* @param type
|
||||
* Type to check
|
||||
* @return true if plugin is watching for this check
|
||||
*/
|
||||
public static boolean isActive(CheckType type)
|
||||
@@ -74,8 +76,10 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Allow a player to skip a certain check
|
||||
*
|
||||
* @param player Player to stop watching
|
||||
* @param type Check to stop watching for
|
||||
* @param player
|
||||
* Player to stop watching
|
||||
* @param type
|
||||
* Check to stop watching for
|
||||
*/
|
||||
public static void exemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
@@ -85,8 +89,10 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Stop allowing a player to skip a certain check
|
||||
*
|
||||
* @param player Player to start watching
|
||||
* @param type Check to start watching for
|
||||
* @param player
|
||||
* Player to start watching
|
||||
* @param type
|
||||
* Check to start watching for
|
||||
*/
|
||||
public static void unexemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
@@ -96,8 +102,10 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Find out if a player is currently exempt from a certain check
|
||||
*
|
||||
* @param player Player to check
|
||||
* @param type Type to check
|
||||
* @param player
|
||||
* Player to check
|
||||
* @param type
|
||||
* Type to check
|
||||
* @return true if plugin is ignoring this check on this player
|
||||
*/
|
||||
public static boolean isExempt(Player player, CheckType type)
|
||||
@@ -106,11 +114,16 @@ public class AnticheatAPI
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out if a check will occur for a player. This checks if they are being tracked, the check is active, the player isn't exempt from the check, and the player doesn't have override permission.
|
||||
* Find out if a check will occur for a player. This checks if they are
|
||||
* being tracked, the check is active, the player isn't exempt from the
|
||||
* check, and the player doesn't have override permission.
|
||||
*
|
||||
* @param player Player to check
|
||||
* @param type Type to check
|
||||
* @return true if plugin will check this player, and that all things allow it to happen.
|
||||
* @param player
|
||||
* Player to check
|
||||
* @param type
|
||||
* Type to check
|
||||
* @return true if plugin will check this player, and that all things allow
|
||||
* it to happen.
|
||||
*/
|
||||
public boolean willCheck(Player player, CheckType type)
|
||||
{
|
||||
@@ -120,14 +133,16 @@ public class AnticheatAPI
|
||||
//PlayerManager API
|
||||
|
||||
/**
|
||||
* Get a player's integer hack level (0-19 = Low, 20-49 = Medium, 50-60 = High)
|
||||
* Get a player's integer hack level (0-19 = Low, 20-49 = Medium, 50-60 =
|
||||
* High)
|
||||
*
|
||||
* @param player Player to check
|
||||
* @param player
|
||||
* Player to check
|
||||
* @return player's hack level
|
||||
*/
|
||||
public static int getLevel(Player player)
|
||||
{
|
||||
if(!pmr.hasLevel(player))
|
||||
if (!pmr.hasLevel(player))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -137,8 +152,10 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Set a player's hack level (Min = 0, Max = 60)
|
||||
*
|
||||
* @param player Player to set
|
||||
* @param level Level to set to
|
||||
* @param player
|
||||
* Player to set
|
||||
* @param level
|
||||
* Level to set to
|
||||
*/
|
||||
public static void setLevel(Player player, int level)
|
||||
{
|
||||
@@ -150,7 +167,8 @@ public class AnticheatAPI
|
||||
/**
|
||||
* Find out if a player is detected as using xray hacks (on any ore)
|
||||
*
|
||||
* @param player Player to check
|
||||
* @param player
|
||||
* Player to check
|
||||
* @return true if the player has any xray anomalies.
|
||||
*/
|
||||
public static boolean isXrayer(Player player)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -40,7 +40,7 @@ public class BlockListener extends EventListener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockDamage(BlockDamageEvent event)
|
||||
{
|
||||
if(event.getInstaBreak())
|
||||
if (event.getInstaBreak())
|
||||
{
|
||||
backend.logInstantBreak(event.getPlayer());
|
||||
}
|
||||
@@ -51,12 +51,12 @@ public class BlockListener extends EventListener
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if(player != null && checkManager.willCheck(player, CheckType.FAST_PLACE))
|
||||
if (player != null && checkManager.willCheck(player, CheckType.FAST_PLACE))
|
||||
{
|
||||
if(backend.checkFastPlace(player))
|
||||
if (backend.checkFastPlace(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to place a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_PLACE);
|
||||
log("tried to place a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_PLACE);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,33 +72,33 @@ public class BlockListener extends EventListener
|
||||
final Player player = event.getPlayer();
|
||||
final Block block = event.getBlock();
|
||||
boolean noHack = true;
|
||||
if(player != null)
|
||||
if (player != null)
|
||||
{
|
||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
if (checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
{
|
||||
if(backend.checkSwing(player,block))
|
||||
if (backend.checkSwing(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" without swinging their arm.",player,CheckType.NO_SWING);
|
||||
log("tried to break a block of " + block.getType().name() + " without swinging their arm.", player, CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.LONG_REACH))
|
||||
if (checkManager.willCheck(player, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(),block.getLocation());
|
||||
if(backend.checkLongReachBlock(player,distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||
if (backend.checkLongReachBlock(player, 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);
|
||||
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) && !backend.isInstantBreakExempt(player))
|
||||
if (checkManager.willCheck(player, CheckType.FAST_BREAK) && !backend.isInstantBreakExempt(player))
|
||||
{
|
||||
if(backend.checkFastBreak(player,block))
|
||||
if (backend.checkFastBreak(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to break a block of "+block.getType().name()+" too fast.",player,CheckType.FAST_BREAK);
|
||||
log("tried to break a block of " + block.getType().name() + " too fast.", player, CheckType.FAST_BREAK);
|
||||
noHack = false;
|
||||
}
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable()
|
||||
@@ -106,12 +106,12 @@ public class BlockListener extends EventListener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
backend.checkSwing(player,block);
|
||||
backend.checkSwing(player, block);
|
||||
}
|
||||
}, 2L);
|
||||
}, 2L);
|
||||
}
|
||||
}
|
||||
if(noHack)
|
||||
if (noHack)
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -27,7 +27,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
|
||||
|
||||
public class EntityListener extends EventListener
|
||||
{
|
||||
private final Backend backend = getBackend();
|
||||
@@ -36,15 +35,15 @@ public class EntityListener extends EventListener
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_BOW))
|
||||
Player player = (Player) event.getEntity();
|
||||
if (checkManager.willCheck(player, CheckType.FAST_BOW))
|
||||
{
|
||||
if(backend.justWoundUp(player))
|
||||
if (backend.justWoundUp(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to fire a bow too fast.",player,CheckType.FAST_BOW);
|
||||
log("tried to fire a bow too fast.", player, CheckType.FAST_BOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -57,15 +56,15 @@ public class EntityListener extends EventListener
|
||||
@EventHandler
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
||||
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_HEAL))
|
||||
Player player = (Player) event.getEntity();
|
||||
if (checkManager.willCheck(player, CheckType.FAST_HEAL))
|
||||
{
|
||||
if(backend.justHealed(player))
|
||||
if (backend.justHealed(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to heal too fast.",player,CheckType.FAST_HEAL);
|
||||
log("tried to heal too fast.", player, CheckType.FAST_HEAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -78,15 +77,15 @@ public class EntityListener extends EventListener
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if(event.getEntity() instanceof Player)
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_EAT))
|
||||
Player player = (Player) event.getEntity();
|
||||
if (checkManager.willCheck(player, CheckType.FAST_EAT))
|
||||
{
|
||||
if(backend.justStartedEating(player))
|
||||
if (backend.justStartedEating(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to eat too fast.",player,CheckType.FAST_EAT);
|
||||
log("tried to eat too fast.", player, CheckType.FAST_EAT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -103,21 +102,21 @@ public class EntityListener extends EventListener
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if(event.getEntity() instanceof Player)
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity();
|
||||
Player player = (Player) event.getEntity();
|
||||
if (e.getDamager() instanceof Player)
|
||||
{
|
||||
Player p = (Player)e.getDamager();
|
||||
Player p = (Player) e.getDamager();
|
||||
backend.logDamage(p);
|
||||
backend.logDamage(player);
|
||||
if(checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||
if (checkManager.willCheck(p, CheckType.LONG_REACH))
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(),p.getLocation());
|
||||
if(backend.checkLongReachDamage(distance.getXDifference(),distance.getYDifference(),distance.getZDifference()))
|
||||
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);
|
||||
log("tried to damage a player too far away from them.", p, CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
@@ -127,28 +126,28 @@ public class EntityListener extends EventListener
|
||||
backend.logDamage(player);
|
||||
}
|
||||
}
|
||||
if(e.getDamager() instanceof Player)
|
||||
if (e.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player) e.getDamager();
|
||||
if(checkManager.willCheck(player, CheckType.FORCEFIELD))
|
||||
if (checkManager.willCheck(player, CheckType.FORCEFIELD))
|
||||
{
|
||||
if(backend.justSprinted(player))
|
||||
if (backend.justSprinted(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to sprint & damage too fast.",player,CheckType.FORCEFIELD);
|
||||
log("tried to sprint & damage too fast.", player, CheckType.FORCEFIELD);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
if (checkManager.willCheck(player, CheckType.NO_SWING))
|
||||
{
|
||||
if(!backend.justAnimated(player))
|
||||
if (!backend.justAnimated(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to damage an entity without swinging their arm.",player,CheckType.NO_SWING);
|
||||
log("tried to damage an entity without swinging their arm.", player, CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if(noHack)
|
||||
if (noHack)
|
||||
{
|
||||
decrease(player);
|
||||
}
|
||||
|
||||
@@ -28,28 +28,28 @@ import org.bukkit.event.Listener;
|
||||
|
||||
public class EventListener implements Listener
|
||||
{
|
||||
private static final Map<CheckType,Integer> USAGE_LIST = new EnumMap<CheckType,Integer>(CheckType.class);
|
||||
private static final Map<String,Integer> DECREASE_LIST = new HashMap<String,Integer>();
|
||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||
private static final Map<String, Integer> DECREASE_LIST = new HashMap<String, Integer>();
|
||||
private static final 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)
|
||||
public void log(String message, Player player, CheckType type)
|
||||
{
|
||||
Anticheat.getManager().log(player.getName()+" "+message);
|
||||
Anticheat.getManager().log(player.getName() + " " + message);
|
||||
PLAYER_MANAGER.increaseLevel(player);
|
||||
removeDecrease(player);
|
||||
logCheat(type,player);
|
||||
logCheat(type, player);
|
||||
}
|
||||
|
||||
private void logCheat(CheckType type,Player player)
|
||||
private void logCheat(CheckType type, Player player)
|
||||
{
|
||||
USAGE_LIST.put(type, getCheats(type)+1);
|
||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||
type.logUse(player);
|
||||
if(Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||
if (Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0)
|
||||
{
|
||||
Anticheat.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks.");
|
||||
Anticheat.getManager().fileLog(player.getName() + " has triggered multiple " + type + " checks.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class EventListener implements Listener
|
||||
public int getCheats(CheckType type)
|
||||
{
|
||||
int x = 0;
|
||||
if(USAGE_LIST.get(type) != null)
|
||||
if (USAGE_LIST.get(type) != null)
|
||||
{
|
||||
x = USAGE_LIST.get(type);
|
||||
}
|
||||
@@ -71,11 +71,11 @@ public class EventListener implements Listener
|
||||
private static void removeDecrease(Player player)
|
||||
{
|
||||
int x = 0;
|
||||
if(DECREASE_LIST.get(player.getName()) != null)
|
||||
if (DECREASE_LIST.get(player.getName()) != null)
|
||||
{
|
||||
x = DECREASE_LIST.get(player.getName());
|
||||
x-=2;
|
||||
if(x < 0)
|
||||
x -= 2;
|
||||
if (x < 0)
|
||||
{
|
||||
x = 0;
|
||||
}
|
||||
@@ -86,16 +86,16 @@ public class EventListener implements Listener
|
||||
public static void decrease(Player player)
|
||||
{
|
||||
int x = 0;
|
||||
if(DECREASE_LIST.get(player.getName()) != null)
|
||||
if (DECREASE_LIST.get(player.getName()) != null)
|
||||
{
|
||||
x = DECREASE_LIST.get(player.getName());
|
||||
}
|
||||
x+=1;
|
||||
x += 1;
|
||||
DECREASE_LIST.put(player.getName(), x);
|
||||
if(x >= 10)
|
||||
if (x >= 10)
|
||||
{
|
||||
PLAYER_MANAGER.decreaseLevel(player);
|
||||
DECREASE_LIST.put(player.getName(),0);
|
||||
DECREASE_LIST.put(player.getName(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class EventListener implements Listener
|
||||
|
||||
public static AnticheatManager getManager()
|
||||
{
|
||||
return Anticheat.getManager();
|
||||
return Anticheat.getManager();
|
||||
}
|
||||
|
||||
public static Backend getBackend()
|
||||
@@ -114,8 +114,9 @@ public class EventListener implements Listener
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public static PlayerManager getPlayerManager() {
|
||||
return PLAYER_MANAGER;
|
||||
public static PlayerManager getPlayerManager()
|
||||
{
|
||||
return PLAYER_MANAGER;
|
||||
}
|
||||
|
||||
public static Anticheat getPlugin()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -34,7 +34,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@@ -49,13 +48,13 @@ public class PlayerListener extends EventListener
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam())
|
||||
if (checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam())
|
||||
{
|
||||
backend.logChat(player);
|
||||
if(backend.checkSpam(player, event.getMessage()))
|
||||
if (backend.checkSpam(player, event.getMessage()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"Please do not spam.");
|
||||
player.sendMessage(ChatColor.RED + "Please do not spam.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,21 +62,20 @@ public class PlayerListener extends EventListener
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event)
|
||||
{
|
||||
if(event.getEntity().getShooter() instanceof Player)
|
||||
if (event.getEntity().getShooter() instanceof Player)
|
||||
{
|
||||
Player player = (Player)event.getEntity().getShooter();
|
||||
if(checkManager.willCheck(player, CheckType.FAST_PROJECTILE))
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
if (checkManager.willCheck(player, CheckType.FAST_PROJECTILE))
|
||||
{
|
||||
backend.logProjectile(player,this);
|
||||
backend.logProjectile(player, this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
if(event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN)
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN)
|
||||
{
|
||||
backend.logTeleport(event.getPlayer());
|
||||
}
|
||||
@@ -86,13 +84,13 @@ public class PlayerListener extends EventListener
|
||||
@EventHandler
|
||||
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event)
|
||||
{
|
||||
backend.logTeleport(event.getPlayer());
|
||||
backend.logTeleport(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
|
||||
{
|
||||
if(event.isSneaking())
|
||||
if (event.isSneaking())
|
||||
{
|
||||
backend.logToggleSneak(event.getPlayer());
|
||||
}
|
||||
@@ -101,32 +99,32 @@ public class PlayerListener extends EventListener
|
||||
@EventHandler
|
||||
public void onPlayerVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY)) //@h31ix: Change if necessary. I'm not sure what perms should go here :3
|
||||
{
|
||||
if(backend.justVelocity(player))
|
||||
{
|
||||
if(backend.extendVelocityTime(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return; // don't log it lol.
|
||||
}
|
||||
}
|
||||
backend.logVelocity(player);
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY)) //@h31ix: Change if necessary. I'm not sure what perms should go here :3
|
||||
{
|
||||
if (backend.justVelocity(player))
|
||||
{
|
||||
if (backend.extendVelocityTime(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return; // don't log it lol.
|
||||
}
|
||||
}
|
||||
backend.logVelocity(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam())
|
||||
if (checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam())
|
||||
{
|
||||
backend.logChat(player);
|
||||
if(backend.checkSpam(player, event.getMessage()))
|
||||
if (backend.checkSpam(player, event.getMessage()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.RED+"Please do not spam.");
|
||||
player.sendMessage(ChatColor.RED + "Please do not spam.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,12 +139,12 @@ public class PlayerListener extends EventListener
|
||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.SPRINT))
|
||||
if (checkManager.willCheck(player, CheckType.SPRINT))
|
||||
{
|
||||
if(backend.checkSprint(event))
|
||||
if (backend.checkSprint(event))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("tried to sprint while hungry.",player,CheckType.SPRINT);
|
||||
log("tried to sprint while hungry.", player, CheckType.SPRINT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -160,44 +158,48 @@ public class PlayerListener extends EventListener
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
Material m = inv.getItemInHand().getType();
|
||||
if(m == Material.BOW)
|
||||
if (m == Material.BOW)
|
||||
{
|
||||
backend.logBowWindUp(player);
|
||||
}
|
||||
else if(Utilities.isFood(m))
|
||||
else if (Utilities.isFood(m))
|
||||
{
|
||||
backend.logEatingStart(player);
|
||||
}
|
||||
}
|
||||
if(event.getClickedBlock() != null)
|
||||
if (event.getClickedBlock() != null)
|
||||
{
|
||||
Distance distance = new Distance(player.getLocation(), event.getClickedBlock().getLocation());
|
||||
backend.checkLongReachBlock(player,distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
}
|
||||
|
||||
/* Interactions Check */
|
||||
//TODO: Extend this into block place/break and if working, change to visuals check.
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
||||
{
|
||||
// save load and actually call the backend check here.
|
||||
if(backend.checkInteraction(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("failed interaction check",player,CheckType.INTERACTION);
|
||||
}
|
||||
}
|
||||
if(block != null) {
|
||||
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
||||
{
|
||||
// save load and actually call the backend check here.
|
||||
if(backend.checkInteraction(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("failed interaction check",player,CheckType.INTERACTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(checkManager.willCheck(player, CheckType.ITEM_SPAM))
|
||||
if (checkManager.willCheck(player, CheckType.ITEM_SPAM))
|
||||
{
|
||||
if(backend.justDroppedItem(player))
|
||||
if (backend.justDroppedItem(player))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -232,20 +234,20 @@ public class PlayerListener extends EventListener
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
String section = "\u00a7";
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
||||
if (checkManager.willCheck(player, CheckType.ZOMBE_FLY))
|
||||
{
|
||||
player.sendMessage(section+"f "+section+"f "+section+"1 "+section+"0 "+section+"2 "+section+"4");
|
||||
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
||||
if (checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
|
||||
{
|
||||
player.sendMessage(section+"f "+section+"f "+section+"2 "+section+"0 "+section+"4 "+section+"8");
|
||||
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
||||
if (checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
|
||||
{
|
||||
player.sendMessage(section+"f "+section+"f "+section+"4 "+section+"0 "+section+"9 "+section+"6");
|
||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||
}
|
||||
backend.logJoin(event.getPlayer());
|
||||
if(!getPlayerManager().hasLevel(player))
|
||||
if (!getPlayerManager().hasLevel(player))
|
||||
{
|
||||
getPlayerManager().setLevel(player, getManager().getConfiguration().getLevel(player.getName()));
|
||||
}
|
||||
@@ -261,69 +263,70 @@ public class PlayerListener extends EventListener
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
backend.logAscension(player,from.getY(),to.getY());
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
||||
backend.logAscension(player, from.getY(), to.getY());
|
||||
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
||||
{
|
||||
from.setX(from.getX()-1);
|
||||
from.setY(from.getY()-1);
|
||||
from.setZ(from.getZ()-1);
|
||||
from.setX(from.getX() - 1);
|
||||
from.setY(from.getY() - 1);
|
||||
from.setZ(from.getZ() - 1);
|
||||
event.setTo(from);
|
||||
Block lower = player.getWorld().getHighestBlockAt(from);
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
||||
log("tried to fly.",player,CheckType.FLY);
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(), lower.getLocation().getY() + 2, lower.getLocation().getZ()));
|
||||
log("tried to fly.", player, CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player,from.getY(),to.getY())))
|
||||
if (checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player, from.getY(), to.getY())))
|
||||
{
|
||||
Block lower = player.getWorld().getHighestBlockAt(player.getLocation());
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(),lower.getLocation().getY()+2,lower.getLocation().getZ()));
|
||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||
Block lower = player.getWorld().getHighestBlockAt(player.getLocation());
|
||||
player.teleport(new Location(lower.getWorld(), lower.getLocation().getX(), lower.getLocation().getY() + 2, lower.getLocation().getZ()));
|
||||
log("tried to fly on y-axis", player, CheckType.FLY);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||
if (checkManager.willCheck(player, CheckType.SPEED) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY))
|
||||
{
|
||||
if(event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
|
||||
if (event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to ascend too fast.",player,CheckType.SPEED);
|
||||
log("tried to ascend too fast.", player, CheckType.SPEED);
|
||||
}
|
||||
if(backend.checkXZSpeed(player,x,z))
|
||||
if (backend.checkXZSpeed(player, x, z))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to move too fast.",player,CheckType.SPEED);
|
||||
log("tried to move too fast.", player, CheckType.SPEED);
|
||||
}
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.NOFALL) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && event.getFrom().getY() > event.getTo().getY() && backend.checkNoFall(player, y))
|
||||
if (checkManager.willCheck(player, CheckType.NOFALL) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && checkManager.willCheck(player, CheckType.FLY) && event.getFrom().getY() > event.getTo().getY() && backend.checkNoFall(player, y))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried avoid fall damage.",player,CheckType.NOFALL);
|
||||
log("tried avoid fall damage.", player, CheckType.NOFALL);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void checkSpeed(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
if(event.getTo() != event.getFrom())
|
||||
if (event.getTo() != event.getFrom())
|
||||
{
|
||||
Distance distance = new Distance(from, to);
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
if(checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player,x,z))
|
||||
if (checkManager.willCheck(player, CheckType.WATER_WALK) && backend.checkWaterWalk(player, x, z))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to walk on water.",player,CheckType.WATER_WALK);
|
||||
log("tried to walk on water.", player, CheckType.WATER_WALK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player,x,z))
|
||||
if (checkManager.willCheck(player, CheckType.SNEAK) && backend.checkSneak(player, x, z))
|
||||
{
|
||||
event.setTo(from);
|
||||
player.setSneaking(false);
|
||||
log("tried to sneak too fast.",player,CheckType.SNEAK);
|
||||
log("tried to sneak too fast.", player, CheckType.SNEAK);
|
||||
}
|
||||
if(checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
||||
if (checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y))
|
||||
{
|
||||
event.setTo(from);
|
||||
log("tried to climb a wall.",player,CheckType.SPIDER);
|
||||
log("tried to climb a wall.", player, CheckType.SPIDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,18 +31,18 @@ public class VehicleListener extends EventListener
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleEnter(VehicleEnterEvent event)
|
||||
{
|
||||
if(event.getEntered() instanceof Player)
|
||||
if (event.getEntered() instanceof Player)
|
||||
{
|
||||
backend.logEnterExit((Player)event.getEntered());
|
||||
backend.logEnterExit((Player) event.getEntered());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleExit(VehicleExitEvent event)
|
||||
{
|
||||
if(event.getExited() instanceof Player)
|
||||
if (event.getExited() instanceof Player)
|
||||
{
|
||||
backend.logEnterExit((Player)event.getExited());
|
||||
backend.logEnterExit((Player) event.getExited());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -56,14 +56,16 @@ public class AnticheatManager
|
||||
backend = new Backend(this);
|
||||
try
|
||||
{
|
||||
File file = new File(plugin.getDataFolder()+"/log");
|
||||
if(!file.exists())
|
||||
File file = new File(plugin.getDataFolder() + "/log");
|
||||
if (!file.exists())
|
||||
{
|
||||
file.mkdir();
|
||||
}
|
||||
fileHandler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log",true);
|
||||
fileHandler = new FileHandler(plugin.getDataFolder() + "/log/anticheat.log", true);
|
||||
fileHandler.setFormatter(new FileFormatter());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
FILE_LOGGER.setUseParentHandlers(false);
|
||||
@@ -72,11 +74,11 @@ public class AnticheatManager
|
||||
|
||||
public void log(String message)
|
||||
{
|
||||
if(getConfiguration().logConsole())
|
||||
if (getConfiguration().logConsole())
|
||||
{
|
||||
LOGGER.info("[AntiCheat] "+ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||
LOGGER.info("[AntiCheat] " + ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||
}
|
||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||
if (getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||
{
|
||||
fileLog(ChatColor.stripColor(message));
|
||||
}
|
||||
@@ -89,33 +91,34 @@ public class AnticheatManager
|
||||
|
||||
public Anticheat getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public Configuration getConfiguration()
|
||||
{
|
||||
return configuration;
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public XRayTracker getXRayTracker()
|
||||
{
|
||||
return xrayTracker;
|
||||
return xrayTracker;
|
||||
}
|
||||
|
||||
public PlayerManager getPlayerManager()
|
||||
{
|
||||
return playerManager;
|
||||
return playerManager;
|
||||
}
|
||||
|
||||
public CheckManager getCheckManager()
|
||||
{
|
||||
return checkManager;
|
||||
return checkManager;
|
||||
}
|
||||
|
||||
public Backend getBackend()
|
||||
{
|
||||
return backend;
|
||||
return backend;
|
||||
}
|
||||
|
||||
public static void close()
|
||||
{
|
||||
fileHandler.close();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -59,7 +59,7 @@ public class Backend
|
||||
private static final int FASTPLACE_MAXVIOLATIONS_CREATIVE = 3;
|
||||
private static final int FASTPLACE_MAXVIOLATIONTIME = 10000;
|
||||
|
||||
private static final int BLOCK_PUNCH_MIN = 5;
|
||||
private static final int BLOCK_PUNCH_MIN = 5;
|
||||
|
||||
private static final int PROJECTILE_MAX = 8;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class Backend
|
||||
private static final int BOW_MIN = 2;
|
||||
private static final int SPRINT_MIN = 2;
|
||||
private static final int BLOCK_BREAK_MIN = 1;
|
||||
private static final long BLOCK_PLACE_MIN = 1/3;
|
||||
private static final long BLOCK_PLACE_MIN = 1 / 3;
|
||||
|
||||
private static final double BLOCK_MAX_DISTANCE = 6.0;
|
||||
private static final double ENTITY_MAX_DISTANCE = 5.5;
|
||||
@@ -126,59 +126,59 @@ public class Backend
|
||||
private List<String> isAscending = new ArrayList<String>();
|
||||
private List<String> trackingProjectiles = new ArrayList<String>();
|
||||
private List<String> velocitizing = new ArrayList<String>();
|
||||
private Map<String,Integer> ascensionCount = new HashMap<String,Integer>();
|
||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
||||
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> yAxisViolations = new HashMap<String,Integer>();
|
||||
private Map<String,Long> yAxisLastViolation = new HashMap<String,Long>();
|
||||
private Map<String,Double> lastYcoord = new HashMap<String,Double>();
|
||||
private Map<String,Long> lastYtime = new HashMap<String,Long>();
|
||||
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> lastZeroHitPlace = new HashMap<String,Integer>();
|
||||
private Map<String,Long> lastBlockPlaced = new HashMap<String,Long>();
|
||||
private Map<String,Long> lastBlockPlaceTime = new HashMap<String,Long>();
|
||||
private Map<String,Integer> blockPunches = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterAscensionViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterSpeedViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> projectilesShot = new HashMap<String,Integer>();
|
||||
private Map<String,Long> velocitized = new HashMap<String,Long>();
|
||||
private Map<String,Integer> velocitytrack = new HashMap<String,Integer>();
|
||||
private Map<String,Location> animated = new HashMap<String,Location>();
|
||||
private Map<String, Integer> ascensionCount = new HashMap<String, Integer>();
|
||||
private Map<String, String> oldMessage = new HashMap<String, String>();
|
||||
private Map<String, String> lastMessage = new HashMap<String, String>();
|
||||
private Map<String, Integer> flightViolation = new HashMap<String, Integer>();
|
||||
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> yAxisViolations = new HashMap<String, Integer>();
|
||||
private Map<String, Long> yAxisLastViolation = new HashMap<String, Long>();
|
||||
private Map<String, Double> lastYcoord = new HashMap<String, Double>();
|
||||
private Map<String, Long> lastYtime = new HashMap<String, Long>();
|
||||
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> lastZeroHitPlace = new HashMap<String, Integer>();
|
||||
private Map<String, Long> lastBlockPlaced = new HashMap<String, Long>();
|
||||
private Map<String, Long> lastBlockPlaceTime = new HashMap<String, Long>();
|
||||
private Map<String, Integer> blockPunches = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> waterAscensionViolation = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> waterSpeedViolation = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> projectilesShot = new HashMap<String, Integer>();
|
||||
private Map<String, Long> velocitized = new HashMap<String, Long>();
|
||||
private Map<String, Integer> velocitytrack = new HashMap<String, Integer>();
|
||||
private Map<String, Location> animated = new HashMap<String, Location>();
|
||||
|
||||
public Backend(AnticheatManager instance)
|
||||
{
|
||||
micromanage = instance;
|
||||
micromanage = instance;
|
||||
}
|
||||
|
||||
public boolean checkLongReachBlock(Player player,double x,double y,double z)
|
||||
public boolean checkLongReachBlock(Player player, double x, double y, double z)
|
||||
{
|
||||
return !Utilities.isUsingMcMMOAbility(player) && (x >= BLOCK_MAX_DISTANCE || y > BLOCK_MAX_DISTANCE || z > BLOCK_MAX_DISTANCE);
|
||||
}
|
||||
|
||||
public boolean checkLongReachDamage(double x,double y,double z)
|
||||
public boolean checkLongReachDamage(double x, double y, double z)
|
||||
{
|
||||
return x >= ENTITY_MAX_DISTANCE || y > ENTITY_MAX_DISTANCE || z > ENTITY_MAX_DISTANCE;
|
||||
}
|
||||
|
||||
public boolean checkSpider(Player player,double y)
|
||||
public boolean checkSpider(Player player, double y)
|
||||
{
|
||||
if(y <= LADDER_Y_MAX && y >= LADDER_Y_MIN && !Utilities.isOnLadder(player))
|
||||
if (y <= LADDER_Y_MAX && y >= LADDER_Y_MIN && !Utilities.isOnLadder(player))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkYSpeed(Player player,double y)
|
||||
public boolean checkYSpeed(Player player, double y)
|
||||
{
|
||||
if(!player.isInsideVehicle() && y > Y_SPEED_MAX && !isVelocity(player) && !player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
if (!player.isInsideVehicle() && y > Y_SPEED_MAX && !isVelocity(player) && !player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -188,22 +188,22 @@ public class Backend
|
||||
public boolean checkNoFall(Player player, double y)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(player.getGameMode() != GameMode.CREATIVE && player.getVehicle() == null && !isMovingExempt(player))
|
||||
if (player.getGameMode() != GameMode.CREATIVE && player.getVehicle() == null && !isMovingExempt(player))
|
||||
{
|
||||
if(player.getFallDistance() == 0)
|
||||
if (player.getFallDistance() == 0)
|
||||
{
|
||||
if(nofallViolation.get(name) == null)
|
||||
if (nofallViolation.get(name) == null)
|
||||
{
|
||||
nofallViolation.put(name,1);
|
||||
nofallViolation.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
nofallViolation.put(name,nofallViolation.get(player.getName())+1);
|
||||
nofallViolation.put(name, nofallViolation.get(player.getName()) + 1);
|
||||
}
|
||||
|
||||
if(nofallViolation.get(name) >= NOFALL_LIMIT)
|
||||
if (nofallViolation.get(name) >= NOFALL_LIMIT)
|
||||
{
|
||||
nofallViolation.put(player.getName(),1);
|
||||
nofallViolation.put(player.getName(), 1);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -213,26 +213,26 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
nofallViolation.put(name,0);
|
||||
nofallViolation.put(name, 0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkXZSpeed(Player player,double x,double z)
|
||||
public boolean checkXZSpeed(Player player, double x, double z)
|
||||
{
|
||||
if(!isSpeedExempt(player) && player.getVehicle() == null)
|
||||
if (!isSpeedExempt(player) && player.getVehicle() == null)
|
||||
{
|
||||
if(player.isFlying())
|
||||
if (player.isFlying())
|
||||
{
|
||||
return x > XZ_SPEED_MAX_FLY || z > XZ_SPEED_MAX_FLY;
|
||||
}
|
||||
else if (player.hasPotionEffect(PotionEffectType.SPEED))
|
||||
{
|
||||
return x > XZ_SPEED_MAX_POTION || z > XZ_SPEED_MAX_POTION;
|
||||
return x > XZ_SPEED_MAX_POTION || z > XZ_SPEED_MAX_POTION;
|
||||
}
|
||||
else if(player.isSprinting())
|
||||
else if (player.isSprinting())
|
||||
{
|
||||
return x > XZ_SPEED_MAX_SPRINT || z > XZ_SPEED_MAX_SPRINT;
|
||||
}
|
||||
@@ -247,9 +247,9 @@ public class Backend
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkSneak(Player player,double x,double z)
|
||||
public boolean checkSneak(Player player, double x, double z)
|
||||
{
|
||||
if(player.isSneaking() && !player.isFlying() && !isMovingExempt(player))
|
||||
if (player.isSneaking() && !player.isFlying() && !isMovingExempt(player))
|
||||
{
|
||||
return x > XZ_SPEED_MAX_SNEAK || z > XZ_SPEED_MAX_SNEAK;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class Backend
|
||||
public boolean checkSprint(PlayerToggleSprintEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if(event.isSprinting())
|
||||
if (event.isSprinting())
|
||||
{
|
||||
return player.getFoodLevel() <= SPRINT_FOOD_MIN && player.getGameMode() != GameMode.CREATIVE;
|
||||
}
|
||||
@@ -300,38 +300,38 @@ public class Backend
|
||||
public boolean checkWaterWalk(Player player, double x, double z)
|
||||
{
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(player.getVehicle() == null && !player.isFlying())
|
||||
if (player.getVehicle() == null && !player.isFlying())
|
||||
{
|
||||
if(block.isLiquid() && block.getRelative(BlockFace.DOWN).isLiquid())
|
||||
if (block.isLiquid() && block.getRelative(BlockFace.DOWN).isLiquid())
|
||||
{
|
||||
if(isInWater.contains(player.getName()))
|
||||
if (isInWater.contains(player.getName()))
|
||||
{
|
||||
if(isInWaterCache.contains(player.getName()))
|
||||
if (isInWaterCache.contains(player.getName()))
|
||||
{
|
||||
if(player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||
if (player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||
{
|
||||
boolean b = false;
|
||||
if(!Utilities.sprintFly(player) && x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER)
|
||||
if (!Utilities.sprintFly(player) && x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||
else if (x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
if(b)
|
||||
if (b)
|
||||
{
|
||||
if(waterSpeedViolation.containsKey(player.getName()))
|
||||
if (waterSpeedViolation.containsKey(player.getName()))
|
||||
{
|
||||
int v = waterSpeedViolation.get(player.getName());
|
||||
if(v >= WATER_SPEED_VIOLATION_MAX)
|
||||
if (v >= WATER_SPEED_VIOLATION_MAX)
|
||||
{
|
||||
waterSpeedViolation.put(player.getName(), 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
waterSpeedViolation.put(player.getName(), v+1);
|
||||
waterSpeedViolation.put(player.getName(), v + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -355,17 +355,17 @@ public class Backend
|
||||
}
|
||||
else if (block.getRelative(BlockFace.DOWN).isLiquid() && isAscending(player) && Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
if(waterAscensionViolation.containsKey(player.getName()))
|
||||
if (waterAscensionViolation.containsKey(player.getName()))
|
||||
{
|
||||
int v = waterAscensionViolation.get(player.getName());
|
||||
if(v >= WATER_ASCENSION_VIOLATION_MAX)
|
||||
if (v >= WATER_ASCENSION_VIOLATION_MAX)
|
||||
{
|
||||
waterAscensionViolation.put(player.getName(), 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
waterAscensionViolation.put(player.getName(), v+1);
|
||||
waterAscensionViolation.put(player.getName(), v + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -384,16 +384,16 @@ public class Backend
|
||||
|
||||
public boolean checkYAxis(Player player, Distance distance)
|
||||
{
|
||||
if(distance.getYDifference() > 400)
|
||||
if (distance.getYDifference() > 400)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if(!isMovingExempt(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle() && !Utilities.isInWater(player))
|
||||
return false;
|
||||
}
|
||||
if (!isMovingExempt(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle() && !Utilities.isInWater(player))
|
||||
{
|
||||
double y1 = player.getLocation().getY();
|
||||
String name = player.getName();
|
||||
//Fix Y axis spam.
|
||||
if(!lastYcoord.containsKey(name) || !lastYtime.containsKey(name) || !yAxisLastViolation.containsKey(name) || !yAxisLastViolation.containsKey(name))
|
||||
if (!lastYcoord.containsKey(name) || !lastYtime.containsKey(name) || !yAxisLastViolation.containsKey(name) || !yAxisLastViolation.containsKey(name))
|
||||
{
|
||||
lastYcoord.put(name, y1);
|
||||
yAxisViolations.put(name, 0);
|
||||
@@ -402,14 +402,14 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
if(y1 > lastYcoord.get(name) && yAxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - yAxisLastViolation.get(name)) < Y_MAXVIOTIME)
|
||||
if (y1 > lastYcoord.get(name) && yAxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - yAxisLastViolation.get(name)) < Y_MAXVIOTIME)
|
||||
{
|
||||
Location g = player.getLocation();
|
||||
g.setY(lastYcoord.get(name));
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fly hacking on the y-axis detected. Please wait 5 seconds to prevent getting damage.");
|
||||
yAxisViolations.put(name, yAxisViolations.get(name)+1);
|
||||
yAxisViolations.put(name, yAxisViolations.get(name) + 1);
|
||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
if (g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
}
|
||||
@@ -417,19 +417,19 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
if(yAxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - yAxisLastViolation.get(name)) > Y_MAXVIOTIME)
|
||||
if (yAxisViolations.get(name) > Y_MAXVIOLATIONS && (System.currentTimeMillis() - yAxisLastViolation.get(name)) > Y_MAXVIOTIME)
|
||||
{
|
||||
yAxisViolations.put(name, 0);
|
||||
yAxisLastViolation.put(name, 0L);
|
||||
}
|
||||
}
|
||||
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME)
|
||||
if ((y1 - lastYcoord.get(name)) > Y_MAXDIFF && (System.currentTimeMillis() - lastYtime.get(name)) < Y_TIME)
|
||||
{
|
||||
Location g = player.getLocation();
|
||||
g.setY(lastYcoord.get(name));
|
||||
yAxisViolations.put(name, yAxisViolations.get(name)+1);
|
||||
yAxisViolations.put(name, yAxisViolations.get(name) + 1);
|
||||
yAxisLastViolation.put(name, System.currentTimeMillis());
|
||||
if(g.getBlock().getTypeId() == 0)
|
||||
if (g.getBlock().getTypeId() == 0)
|
||||
{
|
||||
player.teleport(g);
|
||||
}
|
||||
@@ -437,7 +437,7 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
if((y1 - lastYcoord.get(name)) > Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > Y_TIME)
|
||||
if ((y1 - lastYcoord.get(name)) > Y_MAXDIFF + 1 || (System.currentTimeMillis() - lastYtime.get(name)) > Y_TIME)
|
||||
{
|
||||
lastYtime.put(name, System.currentTimeMillis());
|
||||
lastYcoord.put(name, y1);
|
||||
@@ -445,48 +445,48 @@ public class Backend
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fix Y axis spam
|
||||
return false;
|
||||
//Fix Y axis spam
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkFlight(Player player, Distance distance)
|
||||
{
|
||||
if(distance.getYDifference() > 400)
|
||||
if (distance.getYDifference() > 400)
|
||||
{
|
||||
//This was a teleport, so we don't care about it.
|
||||
return false;
|
||||
}
|
||||
double y1 = distance.fromY();
|
||||
double y2 = distance.toY();
|
||||
}
|
||||
double y1 = distance.fromY();
|
||||
double y2 = distance.toY();
|
||||
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
if(y1 == y2 && !isMovingExempt(player) && !player.isInsideVehicle() && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player))
|
||||
if (y1 == y2 && !isMovingExempt(player) && !player.isInsideVehicle() && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player))
|
||||
{
|
||||
String name = player.getName();
|
||||
if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.isInWater(player))
|
||||
if (Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.isInWater(player))
|
||||
{
|
||||
int violation = 1;
|
||||
if(!flightViolation.containsKey(name))
|
||||
if (!flightViolation.containsKey(name))
|
||||
{
|
||||
flightViolation.put(name, violation);
|
||||
}
|
||||
else
|
||||
{
|
||||
violation = flightViolation.get(name)+1;
|
||||
violation = flightViolation.get(name) + 1;
|
||||
flightViolation.put(name, violation);
|
||||
}
|
||||
if(violation >= FLIGHT_LIMIT)
|
||||
if (violation >= FLIGHT_LIMIT)
|
||||
{
|
||||
flightViolation.put(name, 1);
|
||||
return true;
|
||||
}
|
||||
//Start Fly bypass patch.
|
||||
if(flightViolation.containsKey(name) && flightViolation.get(name) > 0)
|
||||
if (flightViolation.containsKey(name) && flightViolation.get(name) > 0)
|
||||
{
|
||||
for(int i=FLY_LOOP;i>0;i--)
|
||||
for (int i = FLY_LOOP; i > 0; i--)
|
||||
{
|
||||
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ());
|
||||
Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY() - i, player.getLocation().getZ());
|
||||
Block lower = newLocation.getBlock();
|
||||
if(lower.getTypeId() == 0)
|
||||
if (lower.getTypeId() == 0)
|
||||
{
|
||||
player.teleport(newLocation);
|
||||
break;
|
||||
@@ -502,7 +502,7 @@ public class Backend
|
||||
public void logAscension(Player player, double y1, double y2)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(y1 < y2)
|
||||
if (y1 < y2)
|
||||
{
|
||||
isAscending.add(name);
|
||||
}
|
||||
@@ -515,20 +515,20 @@ public class Backend
|
||||
public boolean checkAscension(Player player, double y1, double y2)
|
||||
{
|
||||
int max = ASCENSION_COUNT_MAX;
|
||||
if(player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP))
|
||||
{
|
||||
max+=12;
|
||||
max += 12;
|
||||
}
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(!isMovingExempt(player) && !Utilities.isInWater(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle())
|
||||
if (!isMovingExempt(player) && !Utilities.isInWater(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle())
|
||||
{
|
||||
String name = player.getName();
|
||||
if(y1 < y2)
|
||||
if (y1 < y2)
|
||||
{
|
||||
if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid())
|
||||
if (!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid())
|
||||
{
|
||||
increment(player, ascensionCount, max);
|
||||
if(ascensionCount.get(name) >= max)
|
||||
if (ascensionCount.get(name) >= max)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
ascensionCount.put(name,0);
|
||||
ascensionCount.put(name, 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -549,20 +549,20 @@ public class Backend
|
||||
|
||||
public boolean checkFastBreak(Player player, Block block)
|
||||
{
|
||||
if(!Utilities.isUsingMcMMOAbility(player))
|
||||
if (!Utilities.isUsingMcMMOAbility(player))
|
||||
{
|
||||
int violations = FASTBREAK_MAXVIOLATIONS;
|
||||
if(player.getGameMode() == GameMode.CREATIVE)
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
violations = FASTBREAK_MAXVIOLATIONS_CREATIVE;
|
||||
}
|
||||
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))
|
||||
if (!player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !isInstantBreakExempt(player) && !(player.getInventory().getItemInHand().getType() == Material.SHEARS && block.getType() == Material.LEAVES))
|
||||
{
|
||||
if(blockPunches.get(name) != null && player.getGameMode() != GameMode.CREATIVE)
|
||||
if (blockPunches.get(name) != null && player.getGameMode() != GameMode.CREATIVE)
|
||||
{
|
||||
int i = blockPunches.get(name);
|
||||
if(i < BLOCK_PUNCH_MIN)
|
||||
if (i < BLOCK_PUNCH_MIN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -574,20 +574,20 @@ public class Backend
|
||||
else
|
||||
{
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(fastBreakViolation.get(name) > violations && math < FASTBREAK_MAXVIOLATIONTIME)
|
||||
if (fastBreakViolation.get(name) > violations && math < FASTBREAK_MAXVIOLATIONTIME)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastbreaking detected. Please wait 10 seconds before breaking blocks.");
|
||||
return true;
|
||||
}
|
||||
else if(fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME)
|
||||
else if (fastBreakViolation.get(name) > 0 && math > FASTBREAK_MAXVIOLATIONTIME)
|
||||
{
|
||||
fastBreakViolation.put(name, 0);
|
||||
}
|
||||
}
|
||||
if (!blocksBroken.containsKey(name) || !lastBlockBroken.containsKey(name))
|
||||
{
|
||||
if(!lastBlockBroken.containsKey(name))
|
||||
if (!lastBlockBroken.containsKey(name))
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
}
|
||||
@@ -595,16 +595,16 @@ public class Backend
|
||||
}
|
||||
else
|
||||
{
|
||||
blocksBroken.put(name, blocksBroken.get(name)+1);
|
||||
blocksBroken.put(name, blocksBroken.get(name) + 1);
|
||||
Long math = System.currentTimeMillis() - lastBlockBroken.get(name);
|
||||
if(blocksBroken.get(name) > FASTBREAK_LIMIT && math < FASTBREAK_TIMEMAX)
|
||||
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);
|
||||
fastBreakViolation.put(name, fastBreakViolation.get(name) + 1);
|
||||
return true;
|
||||
}
|
||||
else if(blocksBroken.get(name) > FASTBREAK_LIMIT)
|
||||
else if (blocksBroken.get(name) > FASTBREAK_LIMIT)
|
||||
{
|
||||
lastBlockBroken.put(name, System.currentTimeMillis());
|
||||
blocksBroken.put(name, 0);
|
||||
@@ -618,24 +618,24 @@ public class Backend
|
||||
public boolean checkFastPlace(Player player)
|
||||
{
|
||||
int violations = FASTPLACE_MAXVIOLATIONS;
|
||||
if(player.getGameMode() == GameMode.CREATIVE)
|
||||
if (player.getGameMode() == GameMode.CREATIVE)
|
||||
{
|
||||
violations = FASTPLACE_MAXVIOLATIONS_CREATIVE;
|
||||
}
|
||||
long time = System.currentTimeMillis();
|
||||
String name = player.getName();
|
||||
if(!lastBlockPlaceTime.containsKey(name) || !fastPlaceViolation.containsKey(name))
|
||||
if (!lastBlockPlaceTime.containsKey(name) || !fastPlaceViolation.containsKey(name))
|
||||
{
|
||||
lastBlockPlaceTime.put(name, Long.parseLong("0"));
|
||||
if(!fastPlaceViolation.containsKey(name))
|
||||
if (!fastPlaceViolation.containsKey(name))
|
||||
{
|
||||
fastPlaceViolation.put(name, 0);
|
||||
fastPlaceViolation.put(name, 0);
|
||||
}
|
||||
}
|
||||
else if(fastPlaceViolation.containsKey(name) && fastPlaceViolation.get(name) > violations)
|
||||
else if (fastPlaceViolation.containsKey(name) && fastPlaceViolation.get(name) > violations)
|
||||
{
|
||||
Long math = System.currentTimeMillis() - lastBlockPlaced.get(name);
|
||||
if(lastBlockPlaced.get(name) > 0 && math < FASTPLACE_MAXVIOLATIONTIME)
|
||||
if (lastBlockPlaced.get(name) > 0 && math < FASTPLACE_MAXVIOLATIONTIME)
|
||||
{
|
||||
lastBlockPlaced.put(name, time);
|
||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Fastplacing detected. Please wait 10 seconds before placing blocks.");
|
||||
@@ -646,36 +646,35 @@ public class Backend
|
||||
fastPlaceViolation.put(name, 0);
|
||||
}
|
||||
}
|
||||
else if(lastBlockPlaced.containsKey(name))
|
||||
else if (lastBlockPlaced.containsKey(name))
|
||||
{
|
||||
long last = lastBlockPlaced.get(name);
|
||||
long lastTime = lastBlockPlaceTime.get(name);
|
||||
long thisTime = time-last;
|
||||
long thisTime = time - last;
|
||||
boolean nocheck = thisTime < 1 || lastTime < 1;
|
||||
if(!lastZeroHitPlace.containsKey(name))
|
||||
if (!lastZeroHitPlace.containsKey(name))
|
||||
{
|
||||
lastZeroHitPlace.put(name, 0);
|
||||
}
|
||||
if(nocheck)
|
||||
if (nocheck)
|
||||
{
|
||||
if(!lastZeroHitPlace.containsKey(name))
|
||||
if (!lastZeroHitPlace.containsKey(name))
|
||||
{
|
||||
lastZeroHitPlace.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
lastZeroHitPlace.put(name, lastZeroHitPlace.get(name)+1);
|
||||
lastZeroHitPlace.put(name, lastZeroHitPlace.get(name) + 1);
|
||||
}
|
||||
}
|
||||
if(thisTime < FASTPLACE_TIMEMAX && lastTime < FASTPLACE_TIMEMAX
|
||||
&& nocheck && lastZeroHitPlace.get(name) > FASTPLACE_ZEROLIMIT)
|
||||
if (thisTime < FASTPLACE_TIMEMAX && lastTime < FASTPLACE_TIMEMAX && nocheck && lastZeroHitPlace.get(name) > FASTPLACE_ZEROLIMIT)
|
||||
{
|
||||
lastBlockPlaceTime.put(name, (time-last));
|
||||
lastBlockPlaceTime.put(name, (time - last));
|
||||
lastBlockPlaced.put(name, time);
|
||||
fastPlaceViolation.put(name, fastPlaceViolation.get(name)+1);
|
||||
fastPlaceViolation.put(name, fastPlaceViolation.get(name) + 1);
|
||||
return true;
|
||||
}
|
||||
lastBlockPlaceTime.put(name, (time-last));
|
||||
lastBlockPlaceTime.put(name, (time - last));
|
||||
}
|
||||
lastBlockPlaced.put(name, time);
|
||||
return false;
|
||||
@@ -683,7 +682,7 @@ public class Backend
|
||||
|
||||
public void logBowWindUp(Player player)
|
||||
{
|
||||
logEvent(bowWindUp,player,BOW_MIN);
|
||||
logEvent(bowWindUp, player, BOW_MIN);
|
||||
}
|
||||
|
||||
public boolean justWoundUp(Player player)
|
||||
@@ -693,7 +692,7 @@ public class Backend
|
||||
|
||||
public void logEatingStart(Player player)
|
||||
{
|
||||
logEvent(startEat,player,EAT_MIN);
|
||||
logEvent(startEat, player, EAT_MIN);
|
||||
}
|
||||
|
||||
public boolean justStartedEating(Player player)
|
||||
@@ -703,7 +702,7 @@ public class Backend
|
||||
|
||||
public void logHeal(Player player)
|
||||
{
|
||||
logEvent(healed,player,HEAL_MIN);
|
||||
logEvent(healed, player, HEAL_MIN);
|
||||
}
|
||||
|
||||
public boolean justHealed(Player player)
|
||||
@@ -714,14 +713,14 @@ public class Backend
|
||||
public void logChat(Player player)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(chatLevel.get(name) == null)
|
||||
if (chatLevel.get(name) == null)
|
||||
{
|
||||
logEvent(chatLevel,player,1,CHAT_MIN);
|
||||
logEvent(chatLevel, player, 1, CHAT_MIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
int amount = chatLevel.get(name)+1;
|
||||
logEvent(chatLevel,player,amount,CHAT_MIN);
|
||||
int amount = chatLevel.get(name) + 1;
|
||||
logEvent(chatLevel, player, amount, CHAT_MIN);
|
||||
checkChatLevel(player, amount);
|
||||
}
|
||||
}
|
||||
@@ -729,22 +728,22 @@ public class Backend
|
||||
public boolean checkSpam(Player player, String msg)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(lastMessage.get(name) == null)
|
||||
if (lastMessage.get(name) == null)
|
||||
{
|
||||
logEvent(lastMessage,player,msg,CHAT_REPEAT_MIN);
|
||||
logEvent(lastMessage, player, msg, CHAT_REPEAT_MIN);
|
||||
//lastMessage.put(name, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(oldMessage.get(name) != null && lastMessage.get(name).equals(msg) && oldMessage.get(name).equals(msg))
|
||||
if (oldMessage.get(name) != null && lastMessage.get(name).equals(msg) && oldMessage.get(name).equals(msg))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
logEvent(oldMessage,player,lastMessage.get(name),CHAT_REPEAT_MIN);
|
||||
logEvent(oldMessage, player, lastMessage.get(name), CHAT_REPEAT_MIN);
|
||||
//oldMessage.put(name, lastMessage.get(name));
|
||||
logEvent(oldMessage,player,msg,CHAT_REPEAT_MIN);
|
||||
logEvent(oldMessage, player, msg, CHAT_REPEAT_MIN);
|
||||
//lastMessage.put(name, msg);
|
||||
return false;
|
||||
}
|
||||
@@ -759,7 +758,7 @@ public class Backend
|
||||
|
||||
public void logInstantBreak(final Player player)
|
||||
{
|
||||
logEvent(instantBreakExempt,player,INSTANT_BREAK_TIME);
|
||||
logEvent(instantBreakExempt, player, INSTANT_BREAK_TIME);
|
||||
}
|
||||
|
||||
public boolean isInstantBreakExempt(Player player)
|
||||
@@ -769,7 +768,7 @@ public class Backend
|
||||
|
||||
public void logSprint(final Player player)
|
||||
{
|
||||
logEvent(sprinted,player,SPRINT_MIN);
|
||||
logEvent(sprinted, player, SPRINT_MIN);
|
||||
}
|
||||
|
||||
public boolean justSprinted(Player player)
|
||||
@@ -779,7 +778,7 @@ public class Backend
|
||||
|
||||
public void logBlockBreak(final Player player)
|
||||
{
|
||||
logEvent(brokenBlock,player,BLOCK_BREAK_MIN);
|
||||
logEvent(brokenBlock, player, BLOCK_BREAK_MIN);
|
||||
resetAnimation(player);
|
||||
}
|
||||
|
||||
@@ -790,49 +789,50 @@ public class Backend
|
||||
|
||||
public void logVelocity(final Player player)
|
||||
{
|
||||
logEvent(velocitizing,player,VELOCITY_TIME);
|
||||
velocitized.put(player.getName(), System.currentTimeMillis());
|
||||
logEvent(velocitizing, player, VELOCITY_TIME);
|
||||
velocitized.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean justVelocity(Player player)
|
||||
{
|
||||
return isVelocity(player) || (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < VELOCITY_CHECKTIME : false);
|
||||
return isVelocity(player) || (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < VELOCITY_CHECKTIME : false);
|
||||
}
|
||||
|
||||
public boolean isVelocity(Player player)
|
||||
{
|
||||
return velocitizing.contains(player.getName());
|
||||
return velocitizing.contains(player.getName());
|
||||
}
|
||||
|
||||
public boolean extendVelocityTime(final Player player)
|
||||
{
|
||||
if(velocitytrack.containsKey(player.getName()))
|
||||
{
|
||||
velocitytrack.put(player.getName(), velocitytrack.get(player.getName()) + 1);
|
||||
if(velocitytrack.get(player.getName()) > VELOCITY_MAXTIMES) {
|
||||
velocitized.put(player.getName(), System.currentTimeMillis() + VELOCITY_PREVENT);
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
if (velocitytrack.containsKey(player.getName()))
|
||||
{
|
||||
velocitytrack.put(player.getName(), velocitytrack.get(player.getName()) + 1);
|
||||
if (velocitytrack.get(player.getName()) > VELOCITY_MAXTIMES)
|
||||
{
|
||||
velocitized.put(player.getName(), System.currentTimeMillis() + VELOCITY_PREVENT);
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
velocitytrack.put(player.getName(), 0);
|
||||
velocitytrack.put(player.getName(), 0);
|
||||
}
|
||||
}, VELOCITY_SCHETIME * 20L);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
velocitytrack.put(player.getName(), 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
velocitytrack.put(player.getName(), 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void logBlockPlace(final Player player)
|
||||
{
|
||||
logEvent(placedBlock,player,BLOCK_PLACE_MIN);
|
||||
logEvent(placedBlock, player, BLOCK_PLACE_MIN);
|
||||
}
|
||||
|
||||
public boolean justPlaced(Player player)
|
||||
@@ -842,8 +842,8 @@ public class Backend
|
||||
|
||||
public void logAnimation(final Player player)
|
||||
{
|
||||
logEvent(animated,player,player.getLocation(),ANIMATION_MIN);
|
||||
increment(player,blockPunches,BLOCK_PUNCH_MIN);
|
||||
logEvent(animated, player, player.getLocation(), ANIMATION_MIN);
|
||||
increment(player, blockPunches, BLOCK_PUNCH_MIN);
|
||||
}
|
||||
|
||||
public void resetAnimation(final Player player)
|
||||
@@ -859,8 +859,8 @@ public class Backend
|
||||
|
||||
public void logProjectile(final Player player, final EventListener e)
|
||||
{
|
||||
increment(player,projectilesShot,PROJECTILE_MAX);
|
||||
if(!trackingProjectiles.contains(player.getName()))
|
||||
increment(player, projectilesShot, PROJECTILE_MAX);
|
||||
if (!trackingProjectiles.contains(player.getName()))
|
||||
{
|
||||
trackingProjectiles.add(player.getName());
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
@@ -869,39 +869,39 @@ public class Backend
|
||||
public void run()
|
||||
{
|
||||
trackingProjectiles.remove(player.getName());
|
||||
if(projectilesShot.get(player.getName()) >= PROJECTILE_MAX)
|
||||
if (projectilesShot.get(player.getName()) >= PROJECTILE_MAX)
|
||||
{
|
||||
e.log("tried to fire projectiles too fast",player,CheckType.FAST_PROJECTILE);
|
||||
e.log("tried to fire projectiles too fast", player, CheckType.FAST_PROJECTILE);
|
||||
}
|
||||
projectilesShot.put(player.getName(),0);
|
||||
projectilesShot.put(player.getName(), 0);
|
||||
}
|
||||
}, PROJECTILE_TIME);
|
||||
}, PROJECTILE_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
public void logDamage(final Player player)
|
||||
{
|
||||
int time = DAMAGE_TIME;
|
||||
if(player.getInventory().getItemInHand().getEnchantments().containsKey(Enchantment.KNOCKBACK))
|
||||
if (player.getInventory().getItemInHand().getEnchantments().containsKey(Enchantment.KNOCKBACK))
|
||||
{
|
||||
time = KNOCKBACK_DAMAGE_TIME;
|
||||
}
|
||||
logEvent(movingExempt,player,time);
|
||||
logEvent(movingExempt, player, time);
|
||||
}
|
||||
|
||||
public void logEnterExit(final Player player)
|
||||
{
|
||||
logEvent(movingExempt,player,ENTERED_EXTITED_TIME);
|
||||
logEvent(movingExempt, player, ENTERED_EXTITED_TIME);
|
||||
}
|
||||
|
||||
public void logToggleSneak(final Player player)
|
||||
{
|
||||
logEvent(movingExempt,player,SNEAK_TIME);
|
||||
logEvent(movingExempt, player, SNEAK_TIME);
|
||||
}
|
||||
|
||||
public void logTeleport(final Player player)
|
||||
{
|
||||
logEvent(movingExempt,player,TELEPORT_TIME);
|
||||
logEvent(movingExempt, player, TELEPORT_TIME);
|
||||
|
||||
/* Data for fly/speed should be reset */
|
||||
nofallViolation.remove(player.getName());
|
||||
@@ -914,12 +914,12 @@ public class Backend
|
||||
|
||||
public void logExitFly(final Player player)
|
||||
{
|
||||
logEvent(movingExempt,player,EXIT_FLY_TIME);
|
||||
logEvent(movingExempt, player, EXIT_FLY_TIME);
|
||||
}
|
||||
|
||||
public void logJoin(final Player player)
|
||||
{
|
||||
logEvent(movingExempt,player,JOIN_TIME);
|
||||
logEvent(movingExempt, player, JOIN_TIME);
|
||||
}
|
||||
|
||||
public boolean isMovingExempt(Player player)
|
||||
@@ -934,12 +934,12 @@ public class Backend
|
||||
|
||||
public boolean isSpeedExempt(Player player)
|
||||
{
|
||||
return movingExempt.contains(player.getName()) || isVelocity(player);
|
||||
return movingExempt.contains(player.getName()) || isVelocity(player);
|
||||
}
|
||||
|
||||
public void logDroppedItem(final Player player)
|
||||
{
|
||||
logEvent(droppedItem,player,DROPPED_ITEM_TIME);
|
||||
logEvent(droppedItem, player, DROPPED_ITEM_TIME);
|
||||
}
|
||||
|
||||
public boolean justDroppedItem(Player player)
|
||||
@@ -958,19 +958,19 @@ public class Backend
|
||||
{
|
||||
list.remove(player.getName());
|
||||
}
|
||||
}, time);
|
||||
}, time);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void logEvent(@SuppressWarnings("rawtypes") final Map map, final Player player, final Object obj, long time)
|
||||
{
|
||||
map.put(player.getName(),obj);
|
||||
map.put(player.getName(), obj);
|
||||
micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if(map.get(player.getName()) == obj)
|
||||
if (map.get(player.getName()) == obj)
|
||||
{
|
||||
map.remove(player.getName());
|
||||
}
|
||||
@@ -979,53 +979,55 @@ public class Backend
|
||||
//Don't remove this, for some reason it's fixing chat bugs.
|
||||
}
|
||||
}
|
||||
}, time);
|
||||
}, time);
|
||||
}
|
||||
|
||||
private void checkChatLevel(Player player, int amount)
|
||||
{
|
||||
if(amount >= CHAT_WARN_LEVEL)
|
||||
if (amount >= CHAT_WARN_LEVEL)
|
||||
{
|
||||
player.sendMessage(ChatColor.RED+"Please stop flooding the server!");
|
||||
player.sendMessage(ChatColor.RED + "Please stop flooding the server!");
|
||||
}
|
||||
if (amount >= CHAT_KICK_LEVEL)
|
||||
{
|
||||
String name = player.getName();
|
||||
int kick;
|
||||
if(chatKicks.get(name) == null || chatKicks.get(name) == 0)
|
||||
if (chatKicks.get(name) == null || chatKicks.get(name) == 0)
|
||||
{
|
||||
kick = 1;
|
||||
chatKicks.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
kick = (int)chatKicks.get(name)+1;
|
||||
kick = (int) chatKicks.get(name) + 1;
|
||||
chatKicks.put(name, kick);
|
||||
}
|
||||
|
||||
if(chatKicks.get(name) <= CHAT_BAN_LEVEL)
|
||||
if (chatKicks.get(name) <= CHAT_BAN_LEVEL)
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Spamming, kick "+kick+"/3");
|
||||
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was kicked for spamming.");
|
||||
player.kickPlayer(ChatColor.RED + "Spamming, kick " + kick + "/3");
|
||||
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED + player.getName() + " was kicked for spamming.");
|
||||
}
|
||||
else
|
||||
{
|
||||
player.kickPlayer(ChatColor.RED+"Banned for spamming.");
|
||||
player.kickPlayer(ChatColor.RED + "Banned for spamming.");
|
||||
player.setBanned(true);
|
||||
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was banned for spamming.");
|
||||
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED + player.getName() + " was banned for spamming.");
|
||||
}
|
||||
}
|
||||
}
|
||||
public void increment(Player player, Map<String,Integer> map, int num)
|
||||
|
||||
public void increment(Player player, Map<String, Integer> map, int num)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(map.get(name) == null)
|
||||
if (map.get(name) == null)
|
||||
{
|
||||
map.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int amount = map.get(name)+1;
|
||||
if(amount < num+1)
|
||||
int amount = map.get(name) + 1;
|
||||
if (amount < num + 1)
|
||||
{
|
||||
map.put(name, amount);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,34 +26,35 @@ import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
||||
* The manager that AntiCheat will check with to see if it should watch certain
|
||||
* checks and certain players.
|
||||
*/
|
||||
|
||||
public class CheckManager
|
||||
{
|
||||
private AnticheatManager manager = null;
|
||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||
private static Multimap<String,CheckType> exemptList = ArrayListMultimap.create();
|
||||
private static Multimap<String, CheckType> exemptList = ArrayListMultimap.create();
|
||||
private static int disabled = 0;
|
||||
private static int exempt = 0;
|
||||
|
||||
public CheckManager(AnticheatManager instance)
|
||||
{
|
||||
manager = instance;
|
||||
manager = instance;
|
||||
}
|
||||
|
||||
public void activateCheck(CheckType type)
|
||||
{
|
||||
if(checkIgnoreList.contains(type))
|
||||
if (checkIgnoreList.contains(type))
|
||||
{
|
||||
manager.log("The "+type.toString()+" check was activated.");
|
||||
manager.log("The " + type.toString() + " check was activated.");
|
||||
checkIgnoreList.remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivateCheck(CheckType type)
|
||||
{
|
||||
manager.log("The "+type.toString()+" check was deactivated.");
|
||||
manager.log("The " + type.toString() + " check was deactivated.");
|
||||
checkIgnoreList.add(type);
|
||||
disabled++;
|
||||
}
|
||||
@@ -65,16 +66,16 @@ public class CheckManager
|
||||
|
||||
public void exemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
manager.log(player.getName()+" was exempted from the "+type.toString()+" check.");
|
||||
manager.log(player.getName() + " was exempted from the " + type.toString() + " check.");
|
||||
exemptList.put(player.getName(), type);
|
||||
exempt++;
|
||||
}
|
||||
|
||||
public void unexemptPlayer(Player player, CheckType type)
|
||||
{
|
||||
if(exemptList.containsEntry(player.getName(), type))
|
||||
if (exemptList.containsEntry(player.getName(), type))
|
||||
{
|
||||
manager.log(player.getName()+" was re-added to the "+type.toString()+" check.");
|
||||
manager.log(player.getName() + " was re-added to the " + type.toString() + " check.");
|
||||
exemptList.remove(player.getName(), type);
|
||||
}
|
||||
}
|
||||
@@ -86,10 +87,7 @@ public class CheckManager
|
||||
|
||||
public boolean willCheck(Player player, CheckType type)
|
||||
{
|
||||
return isActive(type)
|
||||
&& manager.getConfiguration().checkInWorld(player.getWorld())
|
||||
&& !isExempt(player, type)
|
||||
&& !type.checkPermission(player);
|
||||
return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) && !type.checkPermission(player);
|
||||
}
|
||||
|
||||
public int getExempt()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,13 +23,11 @@ import java.util.Map;
|
||||
import net.h31ix.anticheat.Permission;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* All the types of checks and their corresponding permission nodes.
|
||||
*/
|
||||
|
||||
|
||||
public enum CheckType
|
||||
{
|
||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||
@@ -44,6 +42,7 @@ public enum CheckType
|
||||
SPRINT(Permission.CHECK_SPRINT),
|
||||
SNEAK(Permission.CHECK_SNEAK),
|
||||
SPEED(Permission.CHECK_SPEED),
|
||||
INTERACTION(Permission.CHECK_INTERACTION),
|
||||
SPIDER(Permission.CHECK_SPIDER),
|
||||
NOFALL(Permission.CHECK_NOFALL),
|
||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||
@@ -56,7 +55,7 @@ public enum CheckType
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM);
|
||||
|
||||
private final Permission permission;
|
||||
private final Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||
|
||||
private CheckType(Permission perm)
|
||||
{
|
||||
@@ -71,13 +70,13 @@ public enum CheckType
|
||||
public void logUse(Player player)
|
||||
{
|
||||
String name = player.getName();
|
||||
if(level.get(name) == null)
|
||||
if (level.get(name) == null)
|
||||
{
|
||||
level.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int amount = level.get(name)+1;
|
||||
int amount = level.get(name) + 1;
|
||||
level.put(name, amount);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +89,7 @@ public enum CheckType
|
||||
public int getUses(Player player)
|
||||
{
|
||||
int use = 0;
|
||||
if(level.get(player.getName()) != null)
|
||||
if (level.get(player.getName()) != null)
|
||||
{
|
||||
use = level.get(player.getName());
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,7 +22,7 @@ import org.bukkit.Location;
|
||||
|
||||
public class Distance
|
||||
{
|
||||
private final Location l1,l2;
|
||||
private final Location l1, l2;
|
||||
|
||||
public Distance(Location from, Location to)
|
||||
{
|
||||
@@ -30,39 +30,28 @@ public class Distance
|
||||
l2 = from;
|
||||
}
|
||||
|
||||
public double fromX()
|
||||
{
|
||||
return l2.getX();
|
||||
}
|
||||
|
||||
public double fromY()
|
||||
{
|
||||
return l2.getY();
|
||||
}
|
||||
|
||||
public double fromZ()
|
||||
{
|
||||
return l2.getZ();
|
||||
return l2.getY();
|
||||
}
|
||||
|
||||
public double toY()
|
||||
{
|
||||
return l1.getY();
|
||||
return l1.getY();
|
||||
}
|
||||
|
||||
public double getXDifference()
|
||||
{
|
||||
return Math.abs(l1.getX()-l2.getX());
|
||||
return Math.abs(l1.getX() - l2.getX());
|
||||
}
|
||||
|
||||
public double getZDifference()
|
||||
{
|
||||
return Math.abs(l1.getZ()-l2.getZ());
|
||||
return Math.abs(l1.getZ() - l2.getZ());
|
||||
}
|
||||
|
||||
public double getYDifference()
|
||||
{
|
||||
return Math.abs(l1.getY()-l2.getY());
|
||||
return Math.abs(l1.getY() - l2.getY());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -29,13 +29,14 @@ import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The manager that AntiCheat will use to monitor player's hack levels and to execute events that the admin has set
|
||||
* The manager that AntiCheat will use to monitor player's hack levels and to
|
||||
* execute events that the admin has set
|
||||
*/
|
||||
|
||||
public class PlayerManager
|
||||
{
|
||||
|
||||
private static Map<String,Integer> level = new HashMap<String,Integer>();
|
||||
private static Map<String, Integer> level = new HashMap<String, Integer>();
|
||||
private static Configuration config = null;
|
||||
private static Language lang;
|
||||
private static final int MED_THRESHOLD = 20;
|
||||
@@ -43,45 +44,47 @@ public class PlayerManager
|
||||
private static final int LEVEL_MAX = 60;
|
||||
private static final int LEVEL_BOOST = 5;
|
||||
|
||||
public PlayerManager(AnticheatManager instance) {
|
||||
config = instance.getConfiguration();
|
||||
public PlayerManager(AnticheatManager instance)
|
||||
{
|
||||
config = instance.getConfiguration();
|
||||
lang = config.getLang();
|
||||
}
|
||||
|
||||
private static void reactMedium(Player player)
|
||||
{
|
||||
execute("Medium",player);
|
||||
Utilities.alert(formatArray(lang.getMediumAlert(),player,ChatColor.YELLOW));
|
||||
execute("Medium", player);
|
||||
Utilities.alert(formatArray(lang.getMediumAlert(), player, ChatColor.YELLOW));
|
||||
}
|
||||
|
||||
private static void reactHigh(Player player)
|
||||
{
|
||||
execute("High",player);
|
||||
Utilities.alert(formatArray(lang.getHighAlert(),player,ChatColor.RED));
|
||||
execute("High", player);
|
||||
Utilities.alert(formatArray(lang.getHighAlert(), player, ChatColor.RED));
|
||||
}
|
||||
|
||||
public void increaseLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) == null || level.get(name) == 0)
|
||||
if (level.get(name) == null || level.get(name) == 0)
|
||||
{
|
||||
level.put(name,1);
|
||||
level.put(name, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int playerLevel = level.get(name);
|
||||
level.put(name, playerLevel+1);
|
||||
if(playerLevel <= MED_THRESHOLD && playerLevel+1 > MED_THRESHOLD && playerLevel+1 <= HIGH_THRESHOLD)
|
||||
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)
|
||||
else if (playerLevel <= HIGH_THRESHOLD && playerLevel + 1 > HIGH_THRESHOLD)
|
||||
{
|
||||
reactHigh(player);
|
||||
level.put(player.getName(), MED_THRESHOLD+LEVEL_BOOST);
|
||||
level.put(player.getName(), MED_THRESHOLD + LEVEL_BOOST);
|
||||
}
|
||||
else if (playerLevel > LEVEL_MAX)
|
||||
{
|
||||
level.put(player.getName(), MED_THRESHOLD+LEVEL_BOOST);
|
||||
level.put(player.getName(), MED_THRESHOLD + LEVEL_BOOST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,9 +92,9 @@ public class PlayerManager
|
||||
public void decreaseLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) != null && level.get(name) != 0)
|
||||
if (level.get(name) != null && level.get(name) != 0)
|
||||
{
|
||||
int playerLevel = level.get(name)-1;
|
||||
int playerLevel = level.get(name) - 1;
|
||||
level.put(name, playerLevel);
|
||||
}
|
||||
}
|
||||
@@ -99,7 +102,7 @@ public class PlayerManager
|
||||
public int getLevel(Player player)
|
||||
{
|
||||
final String name = player.getName();
|
||||
if(level.get(name) != null)
|
||||
if (level.get(name) != null)
|
||||
{
|
||||
return level.get(name);
|
||||
}
|
||||
@@ -111,7 +114,7 @@ public class PlayerManager
|
||||
|
||||
public void setLevel(Player player, int x)
|
||||
{
|
||||
if(!(x > LEVEL_MAX && x < 0))
|
||||
if (!(x > LEVEL_MAX && x < 0))
|
||||
{
|
||||
level.put(player.getName(), x);
|
||||
}
|
||||
@@ -124,14 +127,14 @@ public class PlayerManager
|
||||
|
||||
public void reset(Player player)
|
||||
{
|
||||
level.put(player.getName(),0);
|
||||
for(CheckType type : CheckType.values())
|
||||
level.put(player.getName(), 0);
|
||||
for (CheckType type : CheckType.values())
|
||||
{
|
||||
type.clearUse(player);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String,Integer> getLevels()
|
||||
public Map<String, Integer> getLevels()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
@@ -139,41 +142,43 @@ public class PlayerManager
|
||||
private static void execute(String level, Player player)
|
||||
{
|
||||
String result = config.getResult(level);
|
||||
if(result.startsWith("COMMAND["))
|
||||
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"))
|
||||
else if (result.equalsIgnoreCase("KICK"))
|
||||
{
|
||||
player.kickPlayer(formatString(lang.getKickReason(),player,ChatColor.RED));
|
||||
player.getServer().broadcastMessage(formatString(lang.getKickBroadcast(),player,ChatColor.RED));
|
||||
player.kickPlayer(formatString(lang.getKickReason(), player, ChatColor.RED));
|
||||
player.getServer().broadcastMessage(formatString(lang.getKickBroadcast(), player, ChatColor.RED));
|
||||
}
|
||||
else if(result.equalsIgnoreCase("WARN"))
|
||||
else if (result.equalsIgnoreCase("WARN"))
|
||||
{
|
||||
String[] message = formatArray(lang.getWarning(),player,ChatColor.RED);
|
||||
for(String string : message)
|
||||
String[] message = formatArray(lang.getWarning(), player, ChatColor.RED);
|
||||
for (String string : message)
|
||||
{
|
||||
player.sendMessage(string);
|
||||
}
|
||||
}
|
||||
else if(result.equalsIgnoreCase("BAN"))
|
||||
else if (result.equalsIgnoreCase("BAN"))
|
||||
{
|
||||
player.setBanned(true);
|
||||
player.kickPlayer(formatString(lang.getBanReason(),player,ChatColor.RED));
|
||||
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(),player,ChatColor.RED));
|
||||
player.kickPlayer(formatString(lang.getBanReason(), player, ChatColor.RED));
|
||||
player.getServer().broadcastMessage(formatString(lang.getBanBroadcast(), player, ChatColor.RED));
|
||||
}
|
||||
}
|
||||
private static String [] formatArray(String [] array, Player player, ChatColor color)
|
||||
|
||||
private static String[] formatArray(String[] array, Player player, ChatColor color)
|
||||
{
|
||||
for(int i=0;i<array.length;i++)
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
array[i] = formatString(array[i],player,color);
|
||||
array[i] = formatString(array[i], player, color);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private static String formatString(String string, Player player, ChatColor color)
|
||||
{
|
||||
return color+string.replaceAll("&player", ChatColor.WHITE+player.getName()+color);
|
||||
return color + string.replaceAll("&player", ChatColor.WHITE + player.getName() + color);
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The metrics class obtains data about a plugin and submits statistics about it to the metrics backend.
|
||||
* The metrics class obtains data about a plugin and submits statistics about it
|
||||
* to the metrics backend.
|
||||
* </p>
|
||||
* <p>
|
||||
* Public methods provided by this class:
|
||||
@@ -52,7 +53,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
* void start(); <br/>
|
||||
* </code>
|
||||
*/
|
||||
public class Metrics {
|
||||
public class Metrics
|
||||
{
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
@@ -75,8 +77,8 @@ public class Metrics {
|
||||
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
||||
|
||||
/**
|
||||
* The separator to use for custom data. This MUST NOT change unless you are hosting your own
|
||||
* version of metrics and want to change it.
|
||||
* The separator to use for custom data. This MUST NOT change unless you are
|
||||
* hosting your own version of metrics and want to change it.
|
||||
*/
|
||||
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||
|
||||
@@ -96,7 +98,8 @@ public class Metrics {
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
|
||||
/**
|
||||
* The default graph, used for addCustomData when you don't want a specific graph
|
||||
* The default graph, used for addCustomData when you don't want a specific
|
||||
* graph
|
||||
*/
|
||||
private final Graph defaultGraph = new Graph("Default");
|
||||
|
||||
@@ -110,8 +113,10 @@ public class Metrics {
|
||||
*/
|
||||
private final String guid;
|
||||
|
||||
public Metrics(Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
public Metrics(Plugin plugin) throws IOException
|
||||
{
|
||||
if (plugin == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
|
||||
@@ -126,7 +131,8 @@ public class Metrics {
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
if (configuration.get("guid", null) == null)
|
||||
{
|
||||
configuration.options().header("http://metrics.griefcraft.com").copyDefaults(true);
|
||||
configuration.save(file);
|
||||
}
|
||||
@@ -136,14 +142,18 @@ public class Metrics {
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs
|
||||
* on the metrics website. Plotters can be added to the graph object returned.
|
||||
* Construct and create a Graph that can be used to separate specific
|
||||
* plotters to their own graphs on the metrics website. Plotters can be
|
||||
* added to the graph object returned.
|
||||
*
|
||||
* @param name
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
* @return Graph object created. Will never return NULL under normal
|
||||
* circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(String name) {
|
||||
if (name == null) {
|
||||
public Graph createGraph(String name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
|
||||
@@ -162,8 +172,10 @@ public class Metrics {
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void addCustomData(Plotter plotter) {
|
||||
if (plotter == null) {
|
||||
public void addCustomData(Plotter plotter)
|
||||
{
|
||||
if (plotter == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Plotter cannot be null");
|
||||
}
|
||||
|
||||
@@ -175,23 +187,29 @@ public class Metrics {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send
|
||||
* the initial data to the metrics backend, and then after that it will post in increments of
|
||||
* PING_INTERVAL * 1200 ticks.
|
||||
* Start measuring statistics. This will immediately create an async
|
||||
* repeating task as the plugin and send the initial data to the metrics
|
||||
* backend, and then after that it will post in increments of PING_INTERVAL
|
||||
* * 1200 ticks.
|
||||
*/
|
||||
public void start() {
|
||||
public void start()
|
||||
{
|
||||
// Did we opt out?
|
||||
if (configuration.getBoolean("opt-out", false)) {
|
||||
if (configuration.getBoolean("opt-out", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
||||
plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new Runnable()
|
||||
{
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
// We use the inverse of firstPost because if it is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to FALSE
|
||||
// Each time thereafter it will evaluate to TRUE, i.e PING!
|
||||
@@ -200,7 +218,9 @@ public class Metrics {
|
||||
// After the first post we set firstPost to false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.err.println("[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -210,35 +230,36 @@ public class Metrics {
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*/
|
||||
private void postPlugin(boolean isPing) throws IOException {
|
||||
private void postPlugin(boolean isPing) throws IOException
|
||||
{
|
||||
// The plugin's description file containg all of the plugin data such as name, version, author, etc
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
// Construct the post data
|
||||
String data = encode("guid") + '=' + encode(guid)
|
||||
+ encodeDataPair("version", description.getVersion().split("-b")[0])
|
||||
+ encodeDataPair("server", Bukkit.getVersion())
|
||||
+ encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length))
|
||||
+ encodeDataPair("revision", String.valueOf(REVISION));
|
||||
String data = encode("guid") + '=' + encode(guid) + encodeDataPair("version", description.getVersion().split("-b")[0]) + encodeDataPair("server", Bukkit.getVersion()) + encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length)) + encodeDataPair("revision", String.valueOf(REVISION));
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
if (isPing)
|
||||
{
|
||||
data += encodeDataPair("ping", "true");
|
||||
}
|
||||
|
||||
// Acquire a lock on the graphs, which lets us make the assumption we also lock everything
|
||||
// inside of the graph (e.g plotters)
|
||||
synchronized (graphs) {
|
||||
synchronized (graphs)
|
||||
{
|
||||
Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Graph graph = iter.next();
|
||||
|
||||
// Because we have a lock on the graphs set already, it is reasonable to assume
|
||||
// that our lock transcends down to the individual plotters in the graphs also.
|
||||
// Because our methods are private, no one but us can reasonably access this list
|
||||
// without reflection so this is a safe assumption without adding more code.
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
for (Plotter plotter : graph.getPlotters())
|
||||
{
|
||||
// The key name to send to the metrics server
|
||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator - is defined at the top
|
||||
// Legacy (R4) submitters use the format Custom%s, or CustomPLOTTERNAME
|
||||
@@ -262,9 +283,12 @@ public class Metrics {
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
if (isMineshafterPresent())
|
||||
{
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
@@ -283,18 +307,25 @@ public class Metrics {
|
||||
writer.close();
|
||||
reader.close();
|
||||
|
||||
if (response.startsWith("ERR")) {
|
||||
if (response.startsWith("ERR"))
|
||||
{
|
||||
throw new IOException(response); //Throw the exception
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
if (response.contains("OK This is your first update this hour"))
|
||||
{
|
||||
synchronized (graphs)
|
||||
{
|
||||
Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
for (Plotter plotter : graph.getPlotters())
|
||||
{
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
@@ -305,22 +336,29 @@ public class Metrics {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send
|
||||
* POST requests
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
private boolean isMineshafterPresent()
|
||||
{
|
||||
try
|
||||
{
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Encode a key/value data pair to be used in a HTTP post request. This INCLUDES a & so the first
|
||||
* key/value pair MUST be included manually, e.g:</p>
|
||||
* <p>
|
||||
* Encode a key/value data pair to be used in a HTTP post request. This
|
||||
* INCLUDES a & so the first key/value pair MUST be included manually, e.g:
|
||||
* </p>
|
||||
* <code>
|
||||
* String httpData = encode("guid") + '=' + encode("1234") + encodeDataPair("authors") + "..";
|
||||
* </code>
|
||||
@@ -329,7 +367,8 @@ public class Metrics {
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException {
|
||||
private static String encodeDataPair(String key, String value) throws UnsupportedEncodingException
|
||||
{
|
||||
return '&' + encode(key) + '=' + encode(value);
|
||||
}
|
||||
|
||||
@@ -339,18 +378,20 @@ public class Metrics {
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String encode(String text) throws UnsupportedEncodingException {
|
||||
private static String encode(String text) throws UnsupportedEncodingException
|
||||
{
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
public static class Graph
|
||||
{
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :)
|
||||
* If it does not comply to the above when submitted, it is rejected
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not
|
||||
* comply to the above when submitted, it is rejected
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@@ -359,7 +400,8 @@ public class Metrics {
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(String name) {
|
||||
private Graph(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -368,7 +410,8 @@ public class Metrics {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -377,7 +420,8 @@ public class Metrics {
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void addPlotter(Plotter plotter) {
|
||||
public void addPlotter(Plotter plotter)
|
||||
{
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
@@ -386,7 +430,8 @@ public class Metrics {
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void removePlotter(Plotter plotter) {
|
||||
public void removePlotter(Plotter plotter)
|
||||
{
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
@@ -395,18 +440,22 @@ public class Metrics {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
public Set<Plotter> getPlotters()
|
||||
{
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public int hashCode()
|
||||
{
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
if (!(object instanceof Graph))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -419,7 +468,8 @@ public class Metrics {
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
public static abstract class Plotter
|
||||
{
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
@@ -429,7 +479,8 @@ public class Metrics {
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
public Plotter()
|
||||
{
|
||||
this("Default");
|
||||
}
|
||||
|
||||
@@ -438,7 +489,8 @@ public class Metrics {
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public Plotter(String name) {
|
||||
public Plotter(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@@ -454,24 +506,29 @@ public class Metrics {
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
public String getColumnName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
public void reset()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public int hashCode()
|
||||
{
|
||||
return getColumnName().hashCode() + getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
public boolean equals(Object object)
|
||||
{
|
||||
if (!(object instanceof Plotter))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,7 +21,8 @@ package net.h31ix.anticheat.util;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class ConsoleFormatter extends Formatter {
|
||||
public class ConsoleFormatter extends Formatter
|
||||
{
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,22 +24,18 @@ import java.util.Date;
|
||||
import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class FileFormatter extends Formatter {
|
||||
public class FileFormatter extends Formatter
|
||||
{
|
||||
|
||||
private static final DateFormat format = new SimpleDateFormat("h:mm:ss");
|
||||
private static final String lineSep = System.getProperty("line.separator");
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
if(record.getMessage().startsWith("[AntiCheat]"))
|
||||
public String format(LogRecord record)
|
||||
{
|
||||
if (record.getMessage().startsWith("[AntiCheat]"))
|
||||
{
|
||||
StringBuilder output = new StringBuilder()
|
||||
.append("[")
|
||||
.append(record.getLevel()).append('|')
|
||||
.append(format.format(new Date(record.getMillis())))
|
||||
.append("]: ")
|
||||
.append(record.getMessage()).append(' ')
|
||||
.append(lineSep);
|
||||
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(format.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(lineSep);
|
||||
return output.toString();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -40,51 +39,62 @@ public final class Utilities
|
||||
{
|
||||
|
||||
}
|
||||
public static void alert(String [] message)
|
||||
|
||||
public static void alert(String[] message)
|
||||
{
|
||||
for(String msg : message)
|
||||
for (String msg : message)
|
||||
{
|
||||
Bukkit.broadcast(msg, "anticheat.alert");
|
||||
}
|
||||
if(Anticheat.getManager().getConfiguration().logConsole())
|
||||
if (Anticheat.getManager().getConfiguration().logConsole())
|
||||
{
|
||||
for(String msg : message)
|
||||
{
|
||||
Anticheat.getManager().log(msg);
|
||||
}
|
||||
for (String msg : message)
|
||||
{
|
||||
Anticheat.getManager().log(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean cantStandAt(Block block)
|
||||
{
|
||||
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
||||
}
|
||||
|
||||
public static boolean cantStandClose(Block block)
|
||||
{
|
||||
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
||||
}
|
||||
|
||||
public static boolean cantStandFar(Block block)
|
||||
{
|
||||
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
||||
}
|
||||
|
||||
public static boolean canStand(Block block)
|
||||
{
|
||||
return !(block.isLiquid() || block.getType() == Material.AIR);
|
||||
}
|
||||
|
||||
public static boolean isInstantBreak(Material m)
|
||||
{
|
||||
return INSTANT_BREAK.contains(m);
|
||||
}
|
||||
|
||||
public static boolean isFood(Material m)
|
||||
{
|
||||
return FOOD.contains(m);
|
||||
}
|
||||
public static boolean isInteractable(Material m) {
|
||||
|
||||
public static boolean isInteractable(Material m)
|
||||
{
|
||||
return INTERACTABLE.contains(m);
|
||||
}
|
||||
|
||||
public static boolean sprintFly(Player player)
|
||||
{
|
||||
return player.isSprinting() || player.isFlying();
|
||||
}
|
||||
|
||||
public static boolean isOnLilyPad(Player player)
|
||||
{
|
||||
Block block = player.getLocation().getBlock();
|
||||
@@ -95,9 +105,9 @@ public final class Utilities
|
||||
public static boolean isUsingMcMMOAbility(Player player)
|
||||
{
|
||||
boolean b = false;
|
||||
if(player.getServer().getPluginManager().getPlugin("mcMMO") != null)
|
||||
if (player.getServer().getPluginManager().getPlugin("mcMMO") != null)
|
||||
{
|
||||
if(mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BLAST_MINING))
|
||||
if (mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.TREE_FELLER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BERSERK) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || mcMMO.p.getPlayerProfile(player).getAbilityMode(AbilityType.BLAST_MINING))
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
@@ -105,96 +115,35 @@ public final class Utilities
|
||||
return b;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Credits to sk89q for the calculation of cardinal direction.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the cardinal compass direction of a player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static String getCardinalDirection(Player player) {
|
||||
double rot = (player.getLocation().getYaw() - 90) % 360;
|
||||
if (rot < 0) {
|
||||
rot += 360.0;
|
||||
}
|
||||
return getDirection(rot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cardinal compass direction of a location.
|
||||
*
|
||||
* @param location
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static String getCardinalDirectionLoc(Location player) {
|
||||
double rot = (player.getYaw() - 90) % 360;
|
||||
if (rot < 0) {
|
||||
rot += 360.0;
|
||||
}
|
||||
return getDirection(rot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a rotation to a cardinal direction name.
|
||||
*
|
||||
* @param rot
|
||||
* @return
|
||||
*/
|
||||
private static String getDirection(double rot) {
|
||||
if (0 <= rot && rot < 22.5) {
|
||||
return "N";
|
||||
} else if (22.5 <= rot && rot < 67.5) {
|
||||
return "NE";
|
||||
} else if (67.5 <= rot && rot < 112.5) {
|
||||
return "E";
|
||||
} else if (112.5 <= rot && rot < 157.5) {
|
||||
return "SE";
|
||||
} else if (157.5 <= rot && rot < 202.5) {
|
||||
return "S";
|
||||
} else if (202.5 <= rot && rot < 247.5) {
|
||||
return "SW";
|
||||
} else if (247.5 <= rot && rot < 292.5) {
|
||||
return "W";
|
||||
} else if (292.5 <= rot && rot < 337.5) {
|
||||
return "NW";
|
||||
} else if (337.5 <= rot && rot < 360.0) {
|
||||
return "N";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSubmersed(Player player)
|
||||
{
|
||||
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||
}
|
||||
|
||||
public static boolean isInWater(Player player)
|
||||
{
|
||||
return player.getLocation().getBlock().isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.DOWN).isLiquid() || player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||
}
|
||||
|
||||
public static boolean isOnLadder(Player player)
|
||||
{
|
||||
return player.getLocation().getBlock().getType() == Material.VINE || player.getLocation().getBlock().getType() == Material.LADDER;
|
||||
}
|
||||
|
||||
public static boolean isInt(String string)
|
||||
{
|
||||
boolean x = false;
|
||||
try {
|
||||
try
|
||||
{
|
||||
Integer.parseInt(string);
|
||||
x = true;
|
||||
}
|
||||
catch(Exception ex)
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
INSTANT_BREAK.add(Material.RED_MUSHROOM);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,7 +28,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class XRayListener implements Listener {
|
||||
public class XRayListener implements Listener
|
||||
{
|
||||
private XRayTracker tracker = Anticheat.getManager().getXRayTracker();
|
||||
private Configuration config = Anticheat.getManager().getConfiguration();
|
||||
private CheckManager checkManager = Anticheat.getManager().getCheckManager();
|
||||
@@ -36,38 +37,38 @@ public class XRayListener implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if(config.logXRay())
|
||||
if (config.logXRay())
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
String player = p.getName();
|
||||
if(checkManager.willCheck(p, CheckType.XRAY))
|
||||
if (checkManager.willCheck(p, CheckType.XRAY))
|
||||
{
|
||||
Material m = event.getBlock().getType();
|
||||
if(m == Material.DIAMOND_ORE)
|
||||
if (m == Material.DIAMOND_ORE)
|
||||
{
|
||||
tracker.addDiamond(player);
|
||||
}
|
||||
else if(m == Material.IRON_ORE)
|
||||
else if (m == Material.IRON_ORE)
|
||||
{
|
||||
tracker.addIron(player);
|
||||
}
|
||||
else if(m == Material.COAL_ORE)
|
||||
else if (m == Material.COAL_ORE)
|
||||
{
|
||||
tracker.addCoal(player);
|
||||
}
|
||||
else if(m == Material.GOLD_ORE)
|
||||
else if (m == Material.GOLD_ORE)
|
||||
{
|
||||
tracker.addGold(player);
|
||||
}
|
||||
else if(m == Material.LAPIS_ORE)
|
||||
else if (m == Material.LAPIS_ORE)
|
||||
{
|
||||
tracker.addLapis(player);
|
||||
}
|
||||
else if(m == Material.REDSTONE_ORE)
|
||||
else if (m == Material.REDSTONE_ORE)
|
||||
{
|
||||
tracker.addRedstone(player);
|
||||
}
|
||||
else if(m == Material.GOLD_ORE)
|
||||
else if (m == Material.GOLD_ORE)
|
||||
{
|
||||
tracker.addGold(player);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,7 +20,8 @@ package net.h31ix.anticheat.xray;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class XRayStats {
|
||||
public class XRayStats
|
||||
{
|
||||
private static final int DIVISOR = 100;
|
||||
private double t = 1;
|
||||
private double d = 0;
|
||||
@@ -31,39 +32,39 @@ public class XRayStats {
|
||||
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)
|
||||
public XRayStats(String player, Map<String, Integer> diamond, Map<String, Integer> gold, Map<String, Integer> iron, Map<String, Integer> coal, Map<String, Integer> lapis, Map<String, Integer> redstone, Map<String, Integer> other, Map<String, Integer> total)
|
||||
{
|
||||
if(total.get(player) != null)
|
||||
if (total.get(player) != null)
|
||||
{
|
||||
t = total.get(player);
|
||||
}
|
||||
if(diamond.get(player) != null)
|
||||
if (diamond.get(player) != null)
|
||||
{
|
||||
d = (diamond.get(player)/t)*DIVISOR;
|
||||
d = (diamond.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if(gold.get(player) != null)
|
||||
if (gold.get(player) != null)
|
||||
{
|
||||
g = (gold.get(player)/t)*DIVISOR;
|
||||
g = (gold.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if(iron.get(player) != null)
|
||||
if (iron.get(player) != null)
|
||||
{
|
||||
i = (iron.get(player)/t)*DIVISOR;
|
||||
i = (iron.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if(coal.get(player) != null)
|
||||
if (coal.get(player) != null)
|
||||
{
|
||||
c = (coal.get(player)/t)*DIVISOR;
|
||||
c = (coal.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if(lapis.get(player) != null)
|
||||
if (lapis.get(player) != null)
|
||||
{
|
||||
l = (lapis.get(player)/t)*DIVISOR;
|
||||
l = (lapis.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if(redstone.get(player) != null)
|
||||
if (redstone.get(player) != null)
|
||||
{
|
||||
r = (redstone.get(player)/t)*DIVISOR;
|
||||
r = (redstone.get(player) / t) * DIVISOR;
|
||||
}
|
||||
if(other.get(player) != null)
|
||||
if (other.get(player) != null)
|
||||
{
|
||||
o = (other.get(player)/t)*DIVISOR;
|
||||
o = (other.get(player) / t) * DIVISOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 H31IX http://h31ix.net
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,15 +25,16 @@ import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class XRayTracker {
|
||||
private Map<String,Integer> diamond = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> gold = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> iron = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> coal = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> lapis = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> redstone = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> block = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> totalblock = new HashMap<String,Integer>();
|
||||
public class XRayTracker
|
||||
{
|
||||
private Map<String, Integer> diamond = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> gold = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> iron = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> coal = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> lapis = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> redstone = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> block = new HashMap<String, Integer>();
|
||||
private Map<String, Integer> totalblock = new HashMap<String, Integer>();
|
||||
private List<String> alerted = new ArrayList<String>();
|
||||
private static final ChatColor GREEN = ChatColor.GREEN;
|
||||
private static final ChatColor WHITE = ChatColor.WHITE;
|
||||
@@ -55,23 +56,23 @@ public class XRayTracker {
|
||||
public void calculate(CommandSender cs, String player, double x, double b, String type)
|
||||
{
|
||||
ChatColor color = WHITE;
|
||||
if(x >= b/RATIO_DIVISOR)
|
||||
if (x >= b / RATIO_DIVISOR)
|
||||
{
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY+"Percent "+type+" ore: "+color+round(x)+"%");
|
||||
cs.sendMessage(GRAY + "Percent " + type + " ore: " + color + round(x) + "%");
|
||||
}
|
||||
|
||||
public boolean calculate(String player, double x, double b)
|
||||
{
|
||||
return x >= b/RATIO_DIVISOR;
|
||||
return x >= b / RATIO_DIVISOR;
|
||||
}
|
||||
|
||||
public boolean hasAbnormal(String player)
|
||||
{
|
||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,lapis,redstone,block,totalblock);
|
||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, coal, lapis, redstone, block, totalblock);
|
||||
double total = stats.getOther();
|
||||
return calculate(player,stats.getDiamond(),total) || calculate(player,stats.getGold(),total) || calculate(player,stats.getIron(),total) || calculate(player,stats.getCoal(),total) || calculate(player,stats.getLapis(),total) || calculate(player,stats.getRedstone(),total);
|
||||
return calculate(player, stats.getDiamond(), total) || calculate(player, stats.getGold(), total) || calculate(player, stats.getIron(), total) || calculate(player, stats.getCoal(), total) || calculate(player, stats.getLapis(), total) || calculate(player, stats.getRedstone(), total);
|
||||
}
|
||||
|
||||
public boolean hasAlerted(String player)
|
||||
@@ -86,97 +87,97 @@ public class XRayTracker {
|
||||
|
||||
public void sendStats(CommandSender cs, String player)
|
||||
{
|
||||
getStats(cs,player);
|
||||
getStats(cs, player);
|
||||
}
|
||||
|
||||
public void getStats(CommandSender cs, String player)
|
||||
{
|
||||
XRayStats stats = new XRayStats(player,diamond,gold,iron,coal,lapis,redstone,block,totalblock);
|
||||
XRayStats stats = new XRayStats(player, diamond, gold, iron, coal, lapis, redstone, block, totalblock);
|
||||
double total = stats.getOther();
|
||||
cs.sendMessage("--------------------["+GREEN+"X-Ray Stats"+WHITE+"]---------------------");
|
||||
cs.sendMessage(GRAY+"Player: "+WHITE+player);
|
||||
cs.sendMessage(GRAY+"Total blocks broken: "+WHITE+stats.getTotal());
|
||||
calculate(cs,player,stats.getDiamond(),total,"diamond");
|
||||
calculate(cs,player,stats.getGold(),total,"gold");
|
||||
calculate(cs,player,stats.getIron(),total,"iron");
|
||||
calculate(cs,player,stats.getCoal(),total,"coal");
|
||||
calculate(cs,player,stats.getLapis(),total,"lapis");
|
||||
calculate(cs,player,stats.getRedstone(),total,"redstone");
|
||||
cs.sendMessage(GRAY+"Percent all other blocks: "+WHITE+round(stats.getOther())+"%");
|
||||
cs.sendMessage("--------------------[" + GREEN + "X-Ray Stats" + WHITE + "]---------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + player);
|
||||
cs.sendMessage(GRAY + "Total blocks broken: " + WHITE + stats.getTotal());
|
||||
calculate(cs, player, stats.getDiamond(), total, "diamond");
|
||||
calculate(cs, player, stats.getGold(), total, "gold");
|
||||
calculate(cs, player, stats.getIron(), total, "iron");
|
||||
calculate(cs, player, stats.getCoal(), total, "coal");
|
||||
calculate(cs, player, stats.getLapis(), total, "lapis");
|
||||
calculate(cs, player, stats.getRedstone(), total, "redstone");
|
||||
cs.sendMessage(GRAY + "Percent all other blocks: " + WHITE + round(stats.getOther()) + "%");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
}
|
||||
|
||||
public void addDiamond(String player)
|
||||
{
|
||||
addOre(player,diamond);
|
||||
addOre(player, diamond);
|
||||
}
|
||||
|
||||
public void addGold(String player)
|
||||
{
|
||||
addOre(player,gold);
|
||||
addOre(player, gold);
|
||||
}
|
||||
|
||||
public void addCoal(String player)
|
||||
{
|
||||
addOre(player,coal);
|
||||
addOre(player, coal);
|
||||
}
|
||||
|
||||
public void addIron(String player)
|
||||
{
|
||||
addOre(player,iron);
|
||||
addOre(player, iron);
|
||||
}
|
||||
|
||||
public void addLapis(String player)
|
||||
{
|
||||
addOre(player,lapis);
|
||||
addOre(player, lapis);
|
||||
}
|
||||
|
||||
public void addRedstone(String player)
|
||||
{
|
||||
addOre(player,redstone);
|
||||
addOre(player, redstone);
|
||||
}
|
||||
|
||||
public void addBlock(String player)
|
||||
{
|
||||
addOre(player,block);
|
||||
addOre(player, block);
|
||||
}
|
||||
|
||||
public void addTotal(String player)
|
||||
{
|
||||
addOre(player,totalblock);
|
||||
addOre(player, totalblock);
|
||||
}
|
||||
|
||||
private void addOre(String player, Map<String,Integer> map)
|
||||
private void addOre(String player, Map<String, Integer> map)
|
||||
{
|
||||
if(map.get(player) == null || map.get(player) == 0)
|
||||
if (map.get(player) == null || map.get(player) == 0)
|
||||
{
|
||||
map.put(player,1);
|
||||
map.put(player, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int playerLevel = map.get(player);
|
||||
map.put(player, playerLevel+1);
|
||||
map.put(player, playerLevel + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private float round(double num)
|
||||
{
|
||||
double number = num;
|
||||
float p = (float)Math.pow(POWER,1);
|
||||
number*=p;
|
||||
float p = (float) Math.pow(POWER, 1);
|
||||
number *= p;
|
||||
float tmp = Math.round(number);
|
||||
return (float)tmp/p;
|
||||
return (float) tmp / p;
|
||||
}
|
||||
|
||||
public void reset(String player)
|
||||
{
|
||||
totalblock.put(player,1);
|
||||
diamond.put(player,0);
|
||||
iron.put(player,0);
|
||||
gold.put(player,0);
|
||||
coal.put(player,0);
|
||||
redstone.put(player,0);
|
||||
lapis.put(player,0);
|
||||
totalblock.put(player,0);
|
||||
totalblock.put(player, 1);
|
||||
diamond.put(player, 0);
|
||||
iron.put(player, 0);
|
||||
gold.put(player, 0);
|
||||
coal.put(player, 0);
|
||||
redstone.put(player, 0);
|
||||
lapis.put(player, 0);
|
||||
totalblock.put(player, 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user