From 517a12f339665e8667ad4751942fe692e38024b2 Mon Sep 17 00:00:00 2001 From: H31IX Date: Wed, 6 Jun 2012 00:04:22 -0400 Subject: [PATCH 01/39] Hopefully this adds the build number to dev builds, if not I'll look like a fool. --- src/main/java/net/h31ix/anticheat/Anticheat.java | 8 ++++---- src/main/resources/plugin.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java index 02b00e3..1b95df0 100644 --- a/src/main/java/net/h31ix/anticheat/Anticheat.java +++ b/src/main/java/net/h31ix/anticheat/Anticheat.java @@ -30,9 +30,9 @@ import java.util.logging.Logger; import net.h31ix.anticheat.event.*; import net.h31ix.anticheat.manage.AnticheatManager; import net.h31ix.anticheat.manage.CheckType; -import net.h31ix.anticheat.util.Utilities; import net.h31ix.anticheat.metrics.Metrics; import net.h31ix.anticheat.metrics.Metrics.Graph; +import net.h31ix.anticheat.util.Utilities; import net.h31ix.anticheat.xray.XRayListener; import net.h31ix.anticheat.xray.XRayTracker; import org.bukkit.ChatColor; @@ -249,7 +249,7 @@ public class Anticheat extends JavaPlugin } if (verbose) { - logger.log(Level.INFO,"[AC] 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."); } } } @@ -306,9 +306,9 @@ public class Anticheat extends JavaPlugin catch (Exception ex) { } - if (!this.getDescription().getVersion().equalsIgnoreCase(v)) + String version = this.getDescription().getVersion().split("-b")[0]; + if (!version.equalsIgnoreCase(v)) { - String version = this.getDescription().getVersion(); if (version.endsWith("-PRE") || version.endsWith("-DEV")) { if (version.replaceAll("-PRE", "").replaceAll("-DEV", "").equalsIgnoreCase(v)) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index df87b1c..9572995 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ name: AntiCheat softdepend: [AntiCheat] startup: postworld url: http://H31IX.NET/ -version: '1.3-DEV' +version: ${project.version}-b${BUILD_NUMBER} commands: anticheat: description: Control and view info about AntiCheat From e562d19ed9cf7e29d0011b8d0f381cf40d5b9114 Mon Sep 17 00:00:00 2001 From: Super Spy Date: Wed, 6 Jun 2012 10:37:03 -0500 Subject: [PATCH 02/39] McMMO: Fix issue #36 and fix a potential issue with blast mining. --- src/main/java/net/h31ix/anticheat/util/Utilities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/util/Utilities.java b/src/main/java/net/h31ix/anticheat/util/Utilities.java index 0c09181..a961c0e 100644 --- a/src/main/java/net/h31ix/anticheat/util/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/util/Utilities.java @@ -97,7 +97,7 @@ public final class Utilities boolean b = false; 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)) + 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; } From b8dd6b0f585cf9df1d83d0cde0784f533cd2f27a Mon Sep 17 00:00:00 2001 From: H31IX Date: Thu, 7 Jun 2012 17:56:12 -0400 Subject: [PATCH 03/39] Fix for bug #38, added ascension checking --- .../java/net/h31ix/anticheat/Anticheat.java | 1 + .../h31ix/anticheat/event/PlayerListener.java | 39 +++---------------- .../anticheat/manage/AnticheatManager.java | 4 ++ .../net/h31ix/anticheat/manage/Backend.java | 30 ++++++++++++-- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java index 1b95df0..8a7b319 100644 --- a/src/main/java/net/h31ix/anticheat/Anticheat.java +++ b/src/main/java/net/h31ix/anticheat/Anticheat.java @@ -56,6 +56,7 @@ public class Anticheat extends JavaPlugin @Override public void onDisable() { + AnticheatManager.close(); Map map = manager.getPlayerManager().getLevels(); Iterator set = map.keySet().iterator(); while (set.hasNext()) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index ef88b7b..22c3628 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -221,48 +221,21 @@ public class PlayerListener extends EventListener double x = distance.getXDifference(); double y = distance.getYDifference(); double z = distance.getZDifference(); - backend.checkAscension(player,from.getY(),to.getY()); + backend.logAscension(player,from.getY(),to.getY()); if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance)) { from.setX(from.getX()-1); from.setY(from.getY()-1); from.setZ(from.getZ()-1); event.setTo(from); - //Lets really give this flyer a real pushdown. - Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ()); - Block newBlock = newLocation.getBlock(); - if(newBlock.getTypeId() != 0) - { - event.setTo(newLocation); - } + 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); } - if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkYAxis(player, distance)) + if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && (backend.checkYAxis(player, distance) || backend.checkAscension(player,from.getY(),to.getY()))) { - from.setX(from.getX()-1); - from.setY(from.getY()-1); - from.setZ(from.getZ()-1); - if(from.getBlock().getTypeId() == 0) - { - event.setTo(from); - } - for(int i= 5;i>0;i--) - { - Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-i, player.getLocation().getZ()); - Block lower = newLocation.getBlock(); - if(lower.getTypeId() == 0) - { - player.teleport(newLocation); - break; - } - } - //Lets really give this flyer a real pushdown. - Location newLocation = new Location(player.getWorld(), player.getLocation().getX(), player.getLocation().getY()-2, player.getLocation().getZ()); - Block newBlock = newLocation.getBlock(); - if(newBlock.getTypeId() != 0) - { - event.setTo(newLocation); - } + 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)) diff --git a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java index 311bbbe..e557209 100644 --- a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java @@ -125,4 +125,8 @@ public class AnticheatManager { return backend; } + public static void close() + { + handler.close(); + } } diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 08479d5..aed4c06 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -72,6 +72,7 @@ public class Backend private static final int Y_MAXVIOTIME = 5000; private static final int NOFALL_LIMIT = 5; + private static final int ASCENSION_COUNT_MAX = 8; private static final int WATER_ASCENSION_VIOLATION_MAX = 13; private static final int WATER_SPEED_VIOLATION_MAX = 4; @@ -119,6 +120,7 @@ public class Backend private List instantBreakExempt = new ArrayList(); private List isAscending = new ArrayList(); private List trackingProjectiles = new ArrayList(); + private Map ascensionCount = new HashMap(); private Map oldMessage = new HashMap(); private Map lastMessage = new HashMap(); private Map flightViolation = new HashMap(); @@ -375,7 +377,7 @@ public class Backend yAxisLastViolation.put(name, System.currentTimeMillis()); if(g.getBlock().getTypeId() == 0) { - player.teleport(g); + player.teleport(g); } return true; } @@ -463,16 +465,38 @@ public class Backend return false; } - public void checkAscension(Player player, double y1, double y2) + public void logAscension(Player player, double y1, double y2) { + String name = player.getName(); if(y1 < y2) { - isAscending.add(player.getName()); + isAscending.add(name); } else { isAscending.remove(player.getName()); + } + } + + public boolean checkAscension(Player player, double y1, double y2) + { + if(!isMovingExempt(player)) + { + String name = player.getName(); + if(y1 < y2) + { + increment(player, ascensionCount, ASCENSION_COUNT_MAX); + if(ascensionCount.get(name) >= ASCENSION_COUNT_MAX) + { + return true; + } + } + else + { + ascensionCount.put(name,0); + } } + return false; } public boolean checkSwing(Player player, Block block) From 6db2d521ae04bc825310bd9aa0d2c0bd70780624 Mon Sep 17 00:00:00 2001 From: H31IX Date: Fri, 8 Jun 2012 15:42:57 -0400 Subject: [PATCH 04/39] Fix for bugs #40 and #41 - fixed false positives on normal ascension (ladder and swimming) --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 6 +++--- src/main/java/net/h31ix/anticheat/util/Utilities.java | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index aed4c06..b9e7f94 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -160,7 +160,7 @@ public class Backend public boolean checkSpider(Player player,double y) { - if(y <= LADDER_Y_MAX && y >= LADDER_Y_MIN && player.getLocation().getBlock().getType() != Material.VINE && player.getLocation().getBlock().getType() != Material.LADDER) + if(y <= LADDER_Y_MAX && y >= LADDER_Y_MIN && !Utilities.isOnLadder(player)) { return true; } @@ -354,7 +354,7 @@ public class Backend { return false; } - if(!isMovingExempt(player)) + if(!isMovingExempt(player) && !Utilities.isOnLadder(player)) { double y1 = player.getLocation().getY(); String name = player.getName(); @@ -480,7 +480,7 @@ public class Backend public boolean checkAscension(Player player, double y1, double y2) { - if(!isMovingExempt(player)) + if(!isMovingExempt(player) && !Utilities.isSubmersed(player) && !Utilities.isOnLadder(player)) { String name = player.getName(); if(y1 < y2) diff --git a/src/main/java/net/h31ix/anticheat/util/Utilities.java b/src/main/java/net/h31ix/anticheat/util/Utilities.java index a961c0e..37a8096 100644 --- a/src/main/java/net/h31ix/anticheat/util/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/util/Utilities.java @@ -108,6 +108,10 @@ public final class Utilities { return player.getLocation().getBlock().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; From daed22443948245361c7058c33155321fd0bb0fa Mon Sep 17 00:00:00 2001 From: H31IX Date: Fri, 8 Jun 2012 16:06:11 -0400 Subject: [PATCH 05/39] Fiixed bug #30 - fixed teleporting players down when they are not flying --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index b9e7f94..e6ac2ff 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -169,7 +169,7 @@ public class Backend public boolean checkYSpeed(Player player,double y) { - if(/*!player.isFlying() &&*/ player.getVehicle() == null && y > Y_SPEED_MAX) + if(player.getVehicle() == null && y > Y_SPEED_MAX) { return true; } @@ -397,7 +397,7 @@ public class Backend yAxisLastViolation.put(name, System.currentTimeMillis()); if(g.getBlock().getTypeId() == 0) { - player.teleport(g); + player.teleport(g); } return true; } @@ -425,10 +425,11 @@ public class Backend double y1 = distance.fromY(); double y2 = distance.toY(); Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + System.out.println("block below: "+block.getType()+" block at: "+player.getLocation().getBlock().getType()); if(y1 == y2 && !isMovingExempt(player) && player.getVehicle() == null && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player)) { String name = player.getName(); - if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && !Utilities.canStand(player.getLocation().getBlock()) && !Utilities.isSubmersed(player)) + if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.isSubmersed(player)) { int violation = 1; if(!flightViolation.containsKey(name)) From 8983ae24bbcf63dbf2b974603d229f1220df21ef Mon Sep 17 00:00:00 2001 From: H31IX Date: Fri, 8 Jun 2012 18:05:11 -0400 Subject: [PATCH 06/39] What have I done --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index e6ac2ff..afb8bb5 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -425,7 +425,6 @@ public class Backend double y1 = distance.fromY(); double y2 = distance.toY(); Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - System.out.println("block below: "+block.getType()+" block at: "+player.getLocation().getBlock().getType()); if(y1 == y2 && !isMovingExempt(player) && player.getVehicle() == null && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player)) { String name = player.getName(); From 13d909e8041ea210af1f8f57dfb374dd33b76b28 Mon Sep 17 00:00:00 2001 From: H31IX Date: Fri, 8 Jun 2012 18:58:32 -0400 Subject: [PATCH 07/39] Another small fix for water-related issues. --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 4 ++-- src/main/java/net/h31ix/anticheat/metrics/Metrics.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index afb8bb5..e44c14c 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -428,7 +428,7 @@ public class Backend if(y1 == y2 && !isMovingExempt(player) && player.getVehicle() == null && player.getFallDistance() == 0 && !Utilities.isOnLilyPad(player)) { String name = player.getName(); - if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.isSubmersed(player)) + if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER) { int violation = 1; if(!flightViolation.containsKey(name)) @@ -480,7 +480,7 @@ public class Backend public boolean checkAscension(Player player, double y1, double y2) { - if(!isMovingExempt(player) && !Utilities.isSubmersed(player) && !Utilities.isOnLadder(player)) + if(!isMovingExempt(player) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER && !Utilities.isOnLadder(player)) { String name = player.getName(); if(y1 < y2) diff --git a/src/main/java/net/h31ix/anticheat/metrics/Metrics.java b/src/main/java/net/h31ix/anticheat/metrics/Metrics.java index ab6d044..faccea4 100644 --- a/src/main/java/net/h31ix/anticheat/metrics/Metrics.java +++ b/src/main/java/net/h31ix/anticheat/metrics/Metrics.java @@ -213,7 +213,7 @@ public class Metrics { 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()) From 8d653bd03e95152f029e51572870214a8b2ac9e4 Mon Sep 17 00:00:00 2001 From: H31IX Date: Fri, 8 Jun 2012 18:58:48 -0400 Subject: [PATCH 08/39] Don't send metrics the build number with the version --- src/main/java/net/h31ix/anticheat/metrics/Metrics.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/metrics/Metrics.java b/src/main/java/net/h31ix/anticheat/metrics/Metrics.java index faccea4..48ce4df 100644 --- a/src/main/java/net/h31ix/anticheat/metrics/Metrics.java +++ b/src/main/java/net/h31ix/anticheat/metrics/Metrics.java @@ -216,7 +216,7 @@ public class Metrics { // Construct the post data String data = encode("guid") + '=' + encode(guid) - + encodeDataPair("version", description.getVersion()) + + encodeDataPair("version", description.getVersion().split("-b")[0]) + encodeDataPair("server", Bukkit.getVersion()) + encodeDataPair("players", Integer.toString(Bukkit.getServer().getOnlinePlayers().length)) + encodeDataPair("revision", String.valueOf(REVISION)); From d249924fe8853402241c92aa90a2124e0bc77071 Mon Sep 17 00:00:00 2001 From: Super Spy Date: Fri, 8 Jun 2012 20:39:04 -0500 Subject: [PATCH 09/39] Velocity checks, SHOULD fix #37. And fixed a bug where command spamming was possible (probably needs work). --- .../h31ix/anticheat/event/PlayerListener.java | 21 ++++++++ .../net/h31ix/anticheat/manage/Backend.java | 53 +++++++++++++++++-- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 22c3628..ff57eff 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -48,6 +48,11 @@ public class PlayerListener extends EventListener if(checkManager.willCheck(player, CheckType.SPAM)) { backend.logChat(player); + if(backend.checkSpam(player, event.getMessage())) + { + event.setCancelled(true); + player.sendMessage(ChatColor.RED+"Please do not spam."); + } } } @@ -88,6 +93,22 @@ 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)) + { + backend.extendVelocityTime(player); + event.setCancelled(true); + return; // don't log it lol. + } + backend.logVelocity(player); + } + } + @EventHandler(ignoreCancelled = true) public void onPlayerChat(PlayerChatEvent event) { diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index e44c14c..6bb4ac3 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -70,6 +70,10 @@ public class Backend private static final int FLIGHT_LIMIT = 4; private static final int Y_MAXVIOLATIONS = 1; private static final int Y_MAXVIOTIME = 5000; + private static final int VELOCITY_TIME = 1200; + private static final long VELOCITY_CHECKTIME = 2100; + private static final long VELOCITY_PREVENT = 5000; + private static final int VELOCITY_MAXTIMES = 2; private static final int NOFALL_LIMIT = 5; private static final int ASCENSION_COUNT_MAX = 8; @@ -120,6 +124,7 @@ public class Backend private List instantBreakExempt = new ArrayList(); private List isAscending = new ArrayList(); private List trackingProjectiles = new ArrayList(); + private List velocitizing = new ArrayList(); private Map ascensionCount = new HashMap(); private Map oldMessage = new HashMap(); private Map lastMessage = new HashMap(); @@ -142,6 +147,8 @@ public class Backend private Map waterAscensionViolation = new HashMap(); private Map waterSpeedViolation = new HashMap(); private Map projectilesShot = new HashMap(); + private Map velocitized = new HashMap(); + private Map velocitytrack = new HashMap(); public Backend(AnticheatManager instance) { @@ -740,7 +747,47 @@ public class Backend public boolean justBroke(Player player) { return brokenBlock.contains(player.getName()); - } + } + + public void logVelocity(final Player player) + { + 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); + } + + public boolean isVelocity(Player player) + { + return velocitizing.contains(player.getName()); + } + + public void 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() + { + @Override + public void run() + { + velocitytrack.put(player.getName(), 0); + } + }, VELOCITY_PREVENT); + return; + } + } + else + { + velocitytrack.put(player.getName(), 0); + } + } public void logBlockPlace(final Player player) { @@ -836,7 +883,7 @@ public class Backend public boolean isMovingExempt(Player player) { - return movingExempt.contains(player.getName()) || player.isFlying(); + return movingExempt.contains(player.getName()) || player.isFlying() || isVelocity(player); } public boolean isAscending(Player player) @@ -845,7 +892,7 @@ public class Backend } public boolean isSpeedExempt(Player player) { - return movingExempt.contains(player.getName()); + return movingExempt.contains(player.getName()) || isVelocity(player); } public void logDroppedItem(final Player player) From bf85d73fc3a72801142eda8a7f61688491e930a5 Mon Sep 17 00:00:00 2001 From: Super Spy Date: Fri, 8 Jun 2012 20:53:23 -0500 Subject: [PATCH 10/39] Add velocity check to speed checks. --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 6bb4ac3..8bffce0 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -176,7 +176,7 @@ public class Backend public boolean checkYSpeed(Player player,double y) { - if(player.getVehicle() == null && y > Y_SPEED_MAX) + if(player.getVehicle() == null && y > Y_SPEED_MAX && !isVelocity(player)) { return true; } From bd21fd9872ac2a761d2ed089f93d147daf0eb42c Mon Sep 17 00:00:00 2001 From: Super Spy Date: Fri, 8 Jun 2012 21:25:29 -0500 Subject: [PATCH 11/39] Dear god what have I done. --- .../net/h31ix/anticheat/event/PlayerListener.java | 8 +++++--- .../java/net/h31ix/anticheat/manage/Backend.java | 12 ++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index ff57eff..81d28e8 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -101,9 +101,11 @@ public class PlayerListener extends EventListener { if(backend.justVelocity(player)) { - backend.extendVelocityTime(player); - event.setCancelled(true); - return; // don't log it lol. + if(backend.extendVelocityTime(player)) + { + event.setCancelled(true); + return; // don't log it lol. + } } backend.logVelocity(player); } diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 8bffce0..d67feef 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -70,7 +70,8 @@ public class Backend private static final int FLIGHT_LIMIT = 4; private static final int Y_MAXVIOLATIONS = 1; private static final int Y_MAXVIOTIME = 5000; - private static final int VELOCITY_TIME = 1200; + private static final int VELOCITY_TIME = 60; + private static final long VELOCITY_SCHETIME = 2; private static final long VELOCITY_CHECKTIME = 2100; private static final long VELOCITY_PREVENT = 5000; private static final int VELOCITY_MAXTIMES = 2; @@ -757,6 +758,7 @@ public class Backend public boolean justVelocity(Player player) { + System.out.println(velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) : false); return isVelocity(player) || (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < VELOCITY_CHECKTIME : false); } @@ -765,7 +767,7 @@ public class Backend return velocitizing.contains(player.getName()); } - public void extendVelocityTime(final Player player) + public boolean extendVelocityTime(final Player player) { if(velocitytrack.containsKey(player.getName())) { @@ -779,14 +781,16 @@ public class Backend { velocitytrack.put(player.getName(), 0); } - }, VELOCITY_PREVENT); - return; + }, VELOCITY_SCHETIME * 20L); + return true; } } else { velocitytrack.put(player.getName(), 0); } + + return false; } public void logBlockPlace(final Player player) From 982a9b9637e4ac20d184bfe8426e017c5038d968 Mon Sep 17 00:00:00 2001 From: Super Spy Date: Fri, 8 Jun 2012 21:27:51 -0500 Subject: [PATCH 12/39] Oh my god. Now i'm derping like H31IX too. --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index d67feef..358ba63 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -758,7 +758,6 @@ public class Backend public boolean justVelocity(Player player) { - System.out.println(velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) : false); return isVelocity(player) || (velocitized.containsKey(player.getName()) ? (System.currentTimeMillis() - velocitized.get(player.getName())) < VELOCITY_CHECKTIME : false); } From 7454edf8d6e1c26ad44986c9417945a6ddf782cd Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 10:23:56 -0400 Subject: [PATCH 13/39] Fix for issue #44 --- src/main/java/net/h31ix/anticheat/manage/Backend.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 358ba63..56e7f66 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -177,7 +177,7 @@ public class Backend public boolean checkYSpeed(Player player,double y) { - if(player.getVehicle() == null && y > Y_SPEED_MAX && !isVelocity(player)) + if(!player.isInsideVehicle() && y > Y_SPEED_MAX && !isVelocity(player)) { return true; } @@ -362,7 +362,7 @@ public class Backend { return false; } - if(!isMovingExempt(player) && !Utilities.isOnLadder(player)) + if(!isMovingExempt(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle()) { double y1 = player.getLocation().getY(); String name = player.getName(); @@ -433,7 +433,7 @@ public class Backend double y1 = distance.fromY(); double y2 = distance.toY(); Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - if(y1 == y2 && !isMovingExempt(player) && player.getVehicle() == null && 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()) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER) @@ -488,7 +488,7 @@ public class Backend public boolean checkAscension(Player player, double y1, double y2) { - if(!isMovingExempt(player) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER && !Utilities.isOnLadder(player)) + if(!isMovingExempt(player) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER && !Utilities.isOnLadder(player) && !player.isInsideVehicle()) { String name = player.getName(); if(y1 < y2) From 0b6339a529ac97c9a370149e27feac604fd6e5a0 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 10:38:44 -0400 Subject: [PATCH 14/39] Option to disable chat and command spam, fixes issue #45 --- .../net/h31ix/anticheat/Configuration.java | 26 ++++++++++++++++++- .../h31ix/anticheat/event/PlayerListener.java | 9 ++++--- src/main/resources/config.yml | 6 ++++- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Configuration.java b/src/main/java/net/h31ix/anticheat/Configuration.java index cfae76d..6a94818 100644 --- a/src/main/java/net/h31ix/anticheat/Configuration.java +++ b/src/main/java/net/h31ix/anticheat/Configuration.java @@ -45,6 +45,8 @@ public class Configuration private boolean alertXRay; private boolean autoUpdate; private boolean verboseStartup; + private boolean chatSpam; + private boolean commandSpam; private int fileLogLevel = 0; private String updateFolder; private static Language language; @@ -97,6 +99,16 @@ public class Configuration return verboseStartup; } + public boolean chatSpam() + { + return chatSpam; + } + + public boolean commandSpam() + { + return commandSpam; + } + public String updateFolder() { return updateFolder; @@ -170,7 +182,19 @@ public class Configuration config.set("System.File log level", 1); save(); } - fileLogLevel = config.getInt("System.File log level"); + fileLogLevel = config.getInt("System.File log level"); + 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) + { + config.set("System.Block command spam", true); + save(); + } + commandSpam = config.getBoolean("System.Block command spam"); } public String getResult(String event) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 81d28e8..3d227ca 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -18,6 +18,8 @@ package net.h31ix.anticheat.event; +import net.h31ix.anticheat.Anticheat; +import net.h31ix.anticheat.Configuration; import net.h31ix.anticheat.manage.Backend; import net.h31ix.anticheat.manage.CheckManager; import net.h31ix.anticheat.manage.CheckType; @@ -39,13 +41,14 @@ import org.bukkit.inventory.PlayerInventory; public class PlayerListener extends EventListener { private final Backend backend = getBackend(); - private final CheckManager checkManager = getCheckManager(); + private final CheckManager checkManager = getCheckManager(); + private final Configuration config = Anticheat.getManager().getConfiguration(); @EventHandler public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); - if(checkManager.willCheck(player, CheckType.SPAM)) + if(checkManager.willCheck(player, CheckType.SPAM) && config.commandSpam()) { backend.logChat(player); if(backend.checkSpam(player, event.getMessage())) @@ -115,7 +118,7 @@ public class PlayerListener extends EventListener public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); - if(checkManager.willCheck(player, CheckType.SPAM)) + if(checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam()) { backend.logChat(player); if(backend.checkSpam(player, event.getMessage())) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3806b1c..986bdab 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -19,4 +19,8 @@ System: #Should AntiCheat log to files? #0 = off, 1 = log when an event takes place, 2 = more detailed logs, 3 = most detailed logs File log level: 1 - Verbose startup: false \ No newline at end of file + Verbose startup: false + #Should AntiCheat block when players spam messages in chat? + Block chat spam: true + #Should AntiCheat block when players spam commands in chat? + Block command spam: true \ No newline at end of file From 830a223f0e9cbb010d55a2edd58c70165ba103b9 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 11:13:03 -0400 Subject: [PATCH 15/39] Possible fix for issue #46 - ignore plugins that reset the player's location as a "freeze" --- .../h31ix/anticheat/event/PlayerListener.java | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 3d227ca..f0fad85 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -283,31 +283,34 @@ public class PlayerListener extends EventListener log("tried avoid fall damage.",player,CheckType.NOFALL); } } - @EventHandler(ignoreCancelled = true) + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void checkSpeed(PlayerMoveEvent event) { Player player = event.getPlayer(); Location from = event.getFrom(); - Location to = event.getTo(); - 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)) + Location to = event.getTo(); + if(event.getTo() != event.getFrom()) { - event.setTo(from); - log("tried to walk on water.",player,CheckType.WATER_WALK); - } - 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); - } - if(checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y)) - { - event.setTo(from); - log("tried to climb a wall.",player,CheckType.SPIDER); - } + 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)) + { + event.setTo(from); + log("tried to walk on water.",player,CheckType.WATER_WALK); + } + 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); + } + if(checkManager.willCheck(player, CheckType.SPIDER) && backend.checkSpider(player, y)) + { + event.setTo(from); + log("tried to climb a wall.",player,CheckType.SPIDER); + } + } } } \ No newline at end of file From aa7e9b733ea8777f9be7235b37570598eb2ef6e1 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 13:15:41 -0400 Subject: [PATCH 16/39] Another fix for issue #40 - allow players to swim up waterfalls (even if they are not technically in it, but swimming on it's side) --- .../java/net/h31ix/anticheat/manage/Backend.java | 16 ++++++++++------ .../java/net/h31ix/anticheat/util/Utilities.java | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 56e7f66..f075876 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -362,7 +362,7 @@ public class Backend { return false; } - if(!isMovingExempt(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle()) + if(!isMovingExempt(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle() && !Utilities.isInWater(player)) { double y1 = player.getLocation().getY(); String name = player.getName(); @@ -436,7 +436,7 @@ public class Backend 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()) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER) + if(Utilities.cantStandAt(block) && !Utilities.isOnLilyPad(player) && Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.isInWater(player)) { int violation = 1; if(!flightViolation.containsKey(name)) @@ -488,15 +488,19 @@ public class Backend public boolean checkAscension(Player player, double y1, double y2) { - if(!isMovingExempt(player) && player.getLocation().getBlock().getType() != Material.WATER && player.getLocation().getBlock().getType() != Material.STATIONARY_WATER && !Utilities.isOnLadder(player) && !player.isInsideVehicle()) + Block block = player.getLocation().getBlock(); + if(!isMovingExempt(player) && !Utilities.isInWater(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle()) { String name = player.getName(); if(y1 < y2) { - increment(player, ascensionCount, ASCENSION_COUNT_MAX); - if(ascensionCount.get(name) >= ASCENSION_COUNT_MAX) + if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid()) { - return true; + increment(player, ascensionCount, ASCENSION_COUNT_MAX); + if(ascensionCount.get(name) >= ASCENSION_COUNT_MAX) + { + return true; + } } } else diff --git a/src/main/java/net/h31ix/anticheat/util/Utilities.java b/src/main/java/net/h31ix/anticheat/util/Utilities.java index 37a8096..eedf74b 100644 --- a/src/main/java/net/h31ix/anticheat/util/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/util/Utilities.java @@ -108,6 +108,10 @@ public final class Utilities { 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; From f6ddb4c9b8b04c05fc90b4a92c0e676e19fb5f29 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 18:52:19 -0400 Subject: [PATCH 17/39] Fix for issue #47 - only remove values from maps if they are the same as when we put it there. --- src/main/java/net/h31ix/anticheat/Anticheat.java | 8 ++++---- .../h31ix/anticheat/manage/AnticheatManager.java | 2 +- .../java/net/h31ix/anticheat/manage/Backend.java | 13 ++++++++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java index 8a7b319..3251c1c 100644 --- a/src/main/java/net/h31ix/anticheat/Anticheat.java +++ b/src/main/java/net/h31ix/anticheat/Anticheat.java @@ -207,10 +207,10 @@ public class Anticheat extends JavaPlugin logger.log(Level.INFO, "Data for "+player.getName()+" re-applied from flatfile"); } } - if (verbose) - { - logger.log(Level.INFO, "Finished loading."); - } + if (verbose) + { + logger.log(Level.INFO, "Finished loading."); + } } private void saveFile(String file, String url) diff --git a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java index e557209..fd82571 100644 --- a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java @@ -83,7 +83,7 @@ public class AnticheatManager { if(getConfiguration().logConsole()) { - LOGGER.info(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) { diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index f075876..f369598 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -112,7 +112,6 @@ public class Backend private AnticheatManager micromanage = null; private List droppedItem = new ArrayList(); - private List animated = new ArrayList(); private List movingExempt = new ArrayList(); private List brokenBlock = new ArrayList(); private List placedBlock = new ArrayList(); @@ -150,6 +149,7 @@ public class Backend private Map projectilesShot = new HashMap(); private Map velocitized = new HashMap(); private Map velocitytrack = new HashMap(); + private Map animated = new HashMap(); public Backend(AnticheatManager instance) { @@ -808,7 +808,7 @@ public class Backend public void logAnimation(final Player player) { - logEvent(animated,player,ANIMATION_MIN); + logEvent(animated,player,player.getLocation(),ANIMATION_MIN); increment(player,blockPunches,BLOCK_PUNCH_MIN); } @@ -820,7 +820,7 @@ public class Backend public boolean justAnimated(Player player) { - return animated.contains(player.getName()); + return animated.containsKey(player.getName()); } public void logProjectile(final Player player, final EventListener e) @@ -929,13 +929,16 @@ public class Backend @SuppressWarnings("unchecked") private void logEvent(@SuppressWarnings("rawtypes") final Map map, final Player player, final Object obj, long time) { - map.put(player,obj); + map.put(player.getName(),obj); micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable() { @Override public void run() { - map.remove(player); + if(map.get(player.getName()) == obj) + { + map.remove(player.getName()); + } } }, time); } From c1677c0207fefdd6affc07ea696af05447dd6f3c Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 19:24:19 -0400 Subject: [PATCH 18/39] Fix for issue #25 - fixed logger --- .../anticheat/manage/AnticheatManager.java | 25 ++++++++----------- .../anticheat/util/ConsoleFormatter.java | 7 +++--- .../h31ix/anticheat/util/FileFormatter.java | 24 +++++++++++------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java index fd82571..ebb2107 100644 --- a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java @@ -42,15 +42,16 @@ public class AnticheatManager private CheckManager checkManager = null; private Backend backend = null; private static Logger LOGGER, FILE_LOGGER; - private static Handler handler; + private static Handler fileHandler; + private static Handler consoleHandler; private static final int LOG_LEVEL_HIGH = 3; public AnticheatManager(Anticheat instance) { plugin = instance; // now load all the others!!!!! - LOGGER = plugin.getAnticheatLogger(); - FILE_LOGGER = LOGGER; + LOGGER = Logger.getLogger("Minecraft"); + FILE_LOGGER = Logger.getLogger("Minecraft"); configuration = new Configuration(this); xrayTracker = new XRayTracker(); playerManager = new PlayerManager(this); @@ -63,20 +64,13 @@ public class AnticheatManager { file.mkdir(); } - handler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log.%u.txt",true); - handler.setFormatter(new FileFormatter()); - handler.setLevel(Level.INFO); - } catch (IOException ex) { - LOGGER.log(Level.SEVERE, null, ex); - } catch (SecurityException ex) { + fileHandler = new FileHandler(plugin.getDataFolder()+"/log/anticheat.log",true); + fileHandler.setFormatter(new FileFormatter()); + } catch (Exception ex) { LOGGER.log(Level.SEVERE, null, ex); } FILE_LOGGER.setUseParentHandlers(false); - FILE_LOGGER.addHandler(handler); - LOGGER.setUseParentHandlers(false); - Handler chandler = new ConsoleHandler(); - chandler.setFormatter(new ConsoleFormatter()); - LOGGER.addHandler(chandler); + FILE_LOGGER.addHandler(fileHandler); } public void log(String message) @@ -127,6 +121,7 @@ public class AnticheatManager } public static void close() { - handler.close(); + fileHandler.close(); + consoleHandler.close(); } } diff --git a/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java b/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java index 8a6d309..c1b82f2 100644 --- a/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java +++ b/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java @@ -6,10 +6,9 @@ import java.util.logging.LogRecord; public class ConsoleFormatter extends Formatter { @Override - public String format(LogRecord record) { - StringBuilder output = new StringBuilder() - .append(record.getMessage()).append(' '); + public String format(LogRecord record) + { + StringBuilder output = new StringBuilder().append(record.getMessage()).append(' '); return output.toString(); } - } \ No newline at end of file diff --git a/src/main/java/net/h31ix/anticheat/util/FileFormatter.java b/src/main/java/net/h31ix/anticheat/util/FileFormatter.java index 54cf362..c5dc69e 100644 --- a/src/main/java/net/h31ix/anticheat/util/FileFormatter.java +++ b/src/main/java/net/h31ix/anticheat/util/FileFormatter.java @@ -13,14 +13,20 @@ public class FileFormatter extends Formatter { @Override public String format(LogRecord record) { - StringBuilder output = new StringBuilder() - .append("[") - .append(record.getLevel()).append('|') - .append(format.format(new Date(record.getMillis()))) - .append("]: ") - .append(record.getMessage()).append(' ') - .append(lineSep); - return output.toString(); + 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); + return output.toString(); + } + else + { + return ""; + } } - } \ No newline at end of file From 3ee17d684764c56e1e11f1552dd2c1398371ab88 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 21:19:02 -0400 Subject: [PATCH 19/39] AntiCheat v1.3 --- pom.xml | 6 +++--- src/main/java/net/h31ix/anticheat/event/PlayerListener.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 9216d3a..1001149 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.h31ix.anticheat AntiCheat - 1.3-DEV + 1.3 AntiCheat http://H31IX.NET/ @@ -42,14 +42,14 @@ org.bukkit craftbukkit - 1.2.5-R3.0 + 1.2.5-R4.0 jar compile org.bukkit bukkit - 1.2.5-R3.0 + 1.2.5-R4.0 jar compile diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index f0fad85..05da5e2 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -29,6 +29,7 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.Sign; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; From 49d6bc441cf14545226185c260820dae0d9147ae Mon Sep 17 00:00:00 2001 From: H31IX Date: Sat, 9 Jun 2012 21:57:35 -0400 Subject: [PATCH 20/39] Fixed NPE on disable --- pom.xml | 2 +- src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1001149..4fe6d2e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.h31ix.anticheat AntiCheat - 1.3 + 1.3.1-DEV AntiCheat http://H31IX.NET/ diff --git a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java index ebb2107..42c4112 100644 --- a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java @@ -122,6 +122,5 @@ public class AnticheatManager public static void close() { fileHandler.close(); - consoleHandler.close(); } } From 58bd06536040d85165ee03c88e929f4f86241920 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 00:43:52 -0400 Subject: [PATCH 21/39] Fix for issue #51 - chat levels should not be subjected to identity checking before removal --- .../java/net/h31ix/anticheat/manage/Backend.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index f369598..84192ae 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -685,7 +685,7 @@ public class Backend String name = player.getName(); if(chatLevel.get(name) == null) { - logEvent(chatLevel,player,1,CHAT_MIN); + logEventNoCheck(chatLevel,player,1,CHAT_MIN); } else { @@ -942,6 +942,19 @@ public class Backend } }, time); } + @SuppressWarnings("unchecked") + private void logEventNoCheck(@SuppressWarnings("rawtypes") final Map map, final Player player, final Object obj, long time) + { + map.put(player.getName(),obj); + micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable() + { + @Override + public void run() + { + map.remove(player.getName()); + } + }, time); + } private void checkChatLevel(Player player, int amount) { if(amount >= CHAT_WARN_LEVEL) From 33d0188a9e46eb301d4fa0003b8c7737afe6fe68 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 01:51:31 -0400 Subject: [PATCH 22/39] More chat fix bugs --- .../java/net/h31ix/anticheat/Language.java | 1 - .../h31ix/anticheat/event/PlayerListener.java | 1 - .../net/h31ix/anticheat/manage/Backend.java | 23 ++++++------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Language.java b/src/main/java/net/h31ix/anticheat/Language.java index ef6637d..55f94cc 100644 --- a/src/main/java/net/h31ix/anticheat/Language.java +++ b/src/main/java/net/h31ix/anticheat/Language.java @@ -1,6 +1,5 @@ package net.h31ix.anticheat; -import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; public class Language diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 05da5e2..f0fad85 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -29,7 +29,6 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; -import org.bukkit.block.Sign; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 84192ae..77b3166 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -685,12 +685,12 @@ public class Backend String name = player.getName(); if(chatLevel.get(name) == null) { - logEventNoCheck(chatLevel,player,1,CHAT_MIN); + logEvent(chatLevel,player,1,CHAT_MIN); } else { int amount = chatLevel.get(name)+1; - chatLevel.put(name, amount); + logEvent(chatLevel,player,amount,CHAT_MIN); checkChatLevel(player, amount); } } @@ -939,22 +939,13 @@ public class Backend { map.remove(player.getName()); } + else + { + //Don't remove this, for some reason it's fixing chat bugs. + } } }, time); - } - @SuppressWarnings("unchecked") - private void logEventNoCheck(@SuppressWarnings("rawtypes") final Map map, final Player player, final Object obj, long time) - { - map.put(player.getName(),obj); - micromanage.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(micromanage.getPlugin(), new Runnable() - { - @Override - public void run() - { - map.remove(player.getName()); - } - }, time); - } + } private void checkChatLevel(Player player, int amount) { if(amount >= CHAT_WARN_LEVEL) From d74af58127d6c6764ba3781beb83bdb238354a7b Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 02:12:47 -0400 Subject: [PATCH 23/39] 1.3.1 and event priority modifications --- pom.xml | 2 +- src/main/java/net/h31ix/anticheat/event/PlayerListener.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 4fe6d2e..fd8f154 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.h31ix.anticheat AntiCheat - 1.3.1-DEV + 1.3.1 AntiCheat http://H31IX.NET/ diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index f0fad85..a18d7c2 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -44,7 +44,7 @@ public class PlayerListener extends EventListener private final CheckManager checkManager = getCheckManager(); private final Configuration config = Anticheat.getManager().getConfiguration(); - @EventHandler + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); @@ -114,7 +114,7 @@ public class PlayerListener extends EventListener } } - @EventHandler(ignoreCancelled = true) + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); From 985ba2faeb00e018ce789fb5d6d801bf53648656 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 10:41:41 -0400 Subject: [PATCH 24/39] Updated to new mcMMO API --- pom.xml | 2 +- src/main/resources/plugin.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fd8f154..30eed17 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ com.gmail.nossr50 mcMMO - 1.3.08 + 1.3.09-dev jar compile diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9572995..bdce6e2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ name: AntiCheat softdepend: [AntiCheat] startup: postworld url: http://H31IX.NET/ -version: ${project.version}-b${BUILD_NUMBER} +version: ${project.version} commands: anticheat: description: Control and view info about AntiCheat From f70a9ae4daa3194c923b79d2af617bbb7c0f5695 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 10:54:43 -0400 Subject: [PATCH 25/39] Build number put back in --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index bdce6e2..9572995 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -6,7 +6,7 @@ name: AntiCheat softdepend: [AntiCheat] startup: postworld url: http://H31IX.NET/ -version: ${project.version} +version: ${project.version}-b${BUILD_NUMBER} commands: anticheat: description: Control and view info about AntiCheat From 410211c86e18ee8ad48ed3f723a63b2f6a226043 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 14:00:23 -0400 Subject: [PATCH 26/39] Support Jump potion --- .../net/h31ix/anticheat/event/PlayerListener.java | 5 ++++- src/main/java/net/h31ix/anticheat/manage/Backend.java | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index a18d7c2..983191f 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -37,6 +37,8 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.*; import org.bukkit.inventory.PlayerInventory; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; public class PlayerListener extends EventListener { @@ -118,6 +120,7 @@ public class PlayerListener extends EventListener public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 100, 3)); if(checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam()) { backend.logChat(player); @@ -269,7 +272,7 @@ public class PlayerListener extends EventListener if(event.getFrom().getY() < event.getTo().getY() && backend.checkYSpeed(player, y)) { event.setTo(from); - log("tried to ascend to fast.",player,CheckType.SPEED); + log("tried to ascend too fast.",player,CheckType.SPEED); } if(backend.checkXZSpeed(player,x,z)) { diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 77b3166..fa84693 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -177,7 +177,7 @@ public class Backend public boolean checkYSpeed(Player player,double y) { - if(!player.isInsideVehicle() && y > Y_SPEED_MAX && !isVelocity(player)) + if(!player.isInsideVehicle() && y > Y_SPEED_MAX && !isVelocity(player) && !player.hasPotionEffect(PotionEffectType.JUMP)) { return true; } @@ -488,6 +488,11 @@ public class Backend public boolean checkAscension(Player player, double y1, double y2) { + int max = ASCENSION_COUNT_MAX; + if(player.hasPotionEffect(PotionEffectType.JUMP)) + { + max+=12; + } Block block = player.getLocation().getBlock(); if(!isMovingExempt(player) && !Utilities.isInWater(player) && !Utilities.isOnLadder(player) && !player.isInsideVehicle()) { @@ -496,8 +501,8 @@ public class Backend { if(!block.getRelative(BlockFace.NORTH).isLiquid() && !block.getRelative(BlockFace.SOUTH).isLiquid() && !block.getRelative(BlockFace.EAST).isLiquid() && !block.getRelative(BlockFace.WEST).isLiquid()) { - increment(player, ascensionCount, ASCENSION_COUNT_MAX); - if(ascensionCount.get(name) >= ASCENSION_COUNT_MAX) + increment(player, ascensionCount, max); + if(ascensionCount.get(name) >= max) { return true; } From 81ddcb06156646e2a64bb9b21f27b857fae3c769 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 14:02:10 -0400 Subject: [PATCH 27/39] I knew I was going to forget to remove that :3 --- src/main/java/net/h31ix/anticheat/event/PlayerListener.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 983191f..84d49ce 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -120,7 +120,6 @@ public class PlayerListener extends EventListener public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 100, 3)); if(checkManager.willCheck(player, CheckType.SPAM) && config.chatSpam()) { backend.logChat(player); From c20cc44460c8fb24e67ed577322218c7798abebd Mon Sep 17 00:00:00 2001 From: Super Spy Date: Sun, 10 Jun 2012 13:13:17 -0500 Subject: [PATCH 28/39] The logical speed check errors.. They're everywhere! --- .../java/net/h31ix/anticheat/manage/Backend.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index fa84693..5e04f55 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -227,17 +227,17 @@ public class Backend { return x > XZ_SPEED_MAX_FLY || z > XZ_SPEED_MAX_FLY; } - if(!player.isSprinting()) - { - return x > XZ_SPEED_MAX || z > XZ_SPEED_MAX; - } else if (player.hasPotionEffect(PotionEffectType.SPEED)) { return x > XZ_SPEED_MAX_POTION || z > XZ_SPEED_MAX_POTION; } + else if(player.isSprinting()) + { + return x > XZ_SPEED_MAX_SPRINT || z > XZ_SPEED_MAX_SPRINT; + } else { - return x > XZ_SPEED_MAX_SPRINT || z > XZ_SPEED_MAX_SPRINT; + return x > XZ_SPEED_MAX || z > XZ_SPEED_MAX; } } else @@ -903,7 +903,8 @@ public class Backend return isAscending.contains(player.getName()); } - public boolean isSpeedExempt(Player player) { + public boolean isSpeedExempt(Player player) + { return movingExempt.contains(player.getName()) || isVelocity(player); } From c8f97ca6391f39791c5c73ac5bd5cf00e5418860 Mon Sep 17 00:00:00 2001 From: H31IX Date: Sun, 10 Jun 2012 14:28:25 -0400 Subject: [PATCH 29/39] Repeated messages are forgotten after a time --- .../java/net/h31ix/anticheat/event/PlayerListener.java | 2 -- src/main/java/net/h31ix/anticheat/manage/Backend.java | 10 +++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index 84d49ce..4d474f2 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -37,8 +37,6 @@ import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.*; import org.bukkit.inventory.PlayerInventory; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; public class PlayerListener extends EventListener { diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index fa84693..d8ed3c9 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -86,6 +86,7 @@ public class Backend private static final int HEAL_MIN = 35; private static final int ANIMATION_MIN = 60; private static final int CHAT_MIN = 100; + private static final int CHAT_REPEAT_MIN = 260; private static final int BOW_MIN = 2; private static final int SPRINT_MIN = 2; private static final int BLOCK_BREAK_MIN = 1; @@ -705,7 +706,8 @@ public class Backend String name = player.getName(); if(lastMessage.get(name) == null) { - lastMessage.put(name, msg); + logEvent(lastMessage,player,msg,CHAT_REPEAT_MIN); + //lastMessage.put(name, msg); } else { @@ -715,8 +717,10 @@ public class Backend } else { - oldMessage.put(name, lastMessage.get(name)); - lastMessage.put(name, msg); + logEvent(oldMessage,player,lastMessage.get(name),CHAT_REPEAT_MIN); + //oldMessage.put(name, lastMessage.get(name)); + logEvent(oldMessage,player,msg,CHAT_REPEAT_MIN); + //lastMessage.put(name, msg); return false; } } From 698209f86ab0370436ad6eb7fb1f000857840b5b Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Mon, 11 Jun 2012 21:10:47 -0400 Subject: [PATCH 30/39] Unused imports cleanup --- src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java index 42c4112..e1a7ceb 100644 --- a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java @@ -19,11 +19,9 @@ package net.h31ix.anticheat.manage; import java.io.File; -import java.io.IOException; import java.util.logging.*; import net.h31ix.anticheat.Anticheat; import net.h31ix.anticheat.Configuration; -import net.h31ix.anticheat.util.ConsoleFormatter; import net.h31ix.anticheat.util.FileFormatter; import net.h31ix.anticheat.xray.XRayTracker; import org.bukkit.ChatColor; From f7036ab360020a20c41e43c97dac734edc00c0e0 Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Mon, 11 Jun 2012 21:11:49 -0400 Subject: [PATCH 31/39] Static access for static methods --- src/main/java/net/h31ix/anticheat/event/EventListener.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/event/EventListener.java b/src/main/java/net/h31ix/anticheat/event/EventListener.java index 9a1a40f..46dfd43 100644 --- a/src/main/java/net/h31ix/anticheat/event/EventListener.java +++ b/src/main/java/net/h31ix/anticheat/event/EventListener.java @@ -47,9 +47,9 @@ public class EventListener implements Listener { USAGE_LIST.put(type, getCheats(type)+1); type.logUse(player); - if(PLUGIN.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0) + if(Anticheat.getManager().getConfiguration().getFileLogLevel() == 2 && type.getUses(player) % 10 == 0) { - PLUGIN.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks."); + Anticheat.getManager().fileLog(player.getName()+" has triggered multiple "+type+" checks."); } } From 9c1bb413e1ec47d90c90b0747fc63bba90dd4700 Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Mon, 11 Jun 2012 21:12:14 -0400 Subject: [PATCH 32/39] Remove unused variable --- src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java index e1a7ceb..570c321 100644 --- a/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/AnticheatManager.java @@ -41,7 +41,6 @@ public class AnticheatManager private Backend backend = null; private static Logger LOGGER, FILE_LOGGER; private static Handler fileHandler; - private static Handler consoleHandler; private static final int LOG_LEVEL_HIGH = 3; public AnticheatManager(Anticheat instance) From e87cfd6dc1c48a35cbf0efab4f5f67bbed5df9eb Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Mon, 11 Jun 2012 21:16:33 -0400 Subject: [PATCH 33/39] get a String list if we're going to cast to that anyway --- src/main/java/net/h31ix/anticheat/Configuration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/Configuration.java b/src/main/java/net/h31ix/anticheat/Configuration.java index 6a94818..db3708c 100644 --- a/src/main/java/net/h31ix/anticheat/Configuration.java +++ b/src/main/java/net/h31ix/anticheat/Configuration.java @@ -152,7 +152,7 @@ public class Configuration config.set("Enable in", w); save(); } - worlds = (List)(config.getList("Enable in")); + worlds = config.getStringList("Enable in"); if(config.getString("XRay.Log xray stats") == null) { config.set("XRay.Log xray stats", true); From 14c1f635e16ec043933603077823f92a62d8c921 Mon Sep 17 00:00:00 2001 From: Super Spy Date: Mon, 11 Jun 2012 20:34:18 -0500 Subject: [PATCH 34/39] But mbaxter..why!!!! --- src/main/java/net/h31ix/anticheat/event/EventListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/h31ix/anticheat/event/EventListener.java b/src/main/java/net/h31ix/anticheat/event/EventListener.java index 46dfd43..0ed408e 100644 --- a/src/main/java/net/h31ix/anticheat/event/EventListener.java +++ b/src/main/java/net/h31ix/anticheat/event/EventListener.java @@ -104,7 +104,8 @@ public class EventListener implements Listener return CHECK_MANAGER; } - public static AnticheatManager getManager() { + public static AnticheatManager getManager() + { return Anticheat.getManager(); } From 74a6a8e862f84834bb39b0a754a5641b5f3eff81 Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Mon, 11 Jun 2012 22:04:21 -0400 Subject: [PATCH 35/39] Register permissions Parent nodes define inheritance, simplifying perm checks. Registration makes some systems happy --- .../net/h31ix/anticheat/CommandHandler.java | 31 ++--- .../h31ix/anticheat/manage/CheckManager.java | 7 +- .../net/h31ix/anticheat/util/Utilities.java | 12 +- src/main/resources/plugin.yml | 129 +++++++++++++++++- 4 files changed, 141 insertions(+), 38 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/CommandHandler.java b/src/main/java/net/h31ix/anticheat/CommandHandler.java index 7931a93..89b05d9 100644 --- a/src/main/java/net/h31ix/anticheat/CommandHandler.java +++ b/src/main/java/net/h31ix/anticheat/CommandHandler.java @@ -52,13 +52,11 @@ public class CommandHandler implements CommandExecutor 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 ADMIN_PERM = "anticheat.admin"; - private static final String MOD_PERM = "anticheat.mod"; private static final String PERMISSIONS_ERROR = RED+"Insufficient Permissions."; public void handleLog(CommandSender cs, String [] args) { - if(hasPermission(cs,"system.log") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.log")) { if(args[1].equalsIgnoreCase("enable")) { @@ -97,7 +95,7 @@ public class CommandHandler implements CommandExecutor public void handleXRay(CommandSender cs, String [] args) { - if(hasPermission(cs,"system.xray") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.xray")) { if(config.logXRay()) { @@ -142,7 +140,7 @@ public class CommandHandler implements CommandExecutor public void handleReset(CommandSender cs, String [] args) { - if(hasPermission(cs,"system.reset") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.reset")) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -180,7 +178,7 @@ public class CommandHandler implements CommandExecutor if(cs instanceof Player) { Player sender = (Player)cs; - if(hasPermission(cs,"system.spy") || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.spy")) { if(!args[1].equalsIgnoreCase("off")) { @@ -236,7 +234,7 @@ public class CommandHandler implements CommandExecutor public void handleHelp(CommandSender cs) { - if(hasPermission(cs,"system.help") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.help")) { String base = "/AntiCheat "; cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------"); @@ -259,7 +257,7 @@ public class CommandHandler implements CommandExecutor public void handleUpdate(CommandSender cs) { - if(hasPermission(cs,"system.update") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.update")) { cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion()); cs.sendMessage("-----------------------------------------------------"); @@ -289,7 +287,7 @@ public class CommandHandler implements CommandExecutor public void handleReport(CommandSender cs) { - if(hasPermission(cs,"system.report") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.report")) { getPlayers(); if(!low.isEmpty()) @@ -325,7 +323,7 @@ public class CommandHandler implements CommandExecutor public void handlePlayerReport(CommandSender cs,String [] args) { - if(hasPermission(cs,"system.report") || hasPermission(cs,ADMIN_PERM) || hasPermission(cs,MOD_PERM)) + if(cs.hasPermission("system.report")) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -439,7 +437,7 @@ public class CommandHandler implements CommandExecutor public void handleReload(CommandSender cs) { - if(hasPermission(cs,"system.reload") || hasPermission(cs,ADMIN_PERM)) + if(cs.hasPermission("system.reload")) { config.load(); cs.sendMessage(GREEN+"AntiCheat configuration reloaded."); @@ -517,17 +515,6 @@ public class CommandHandler implements CommandExecutor return true; } - public boolean hasPermission(CommandSender cs, String permission) - { - if(cs instanceof Player) - { - return ((Player)cs).hasPermission("anticheat."+permission); - } - else - { - return true; - } - } public void getPlayers() { high.clear(); diff --git a/src/main/java/net/h31ix/anticheat/manage/CheckManager.java b/src/main/java/net/h31ix/anticheat/manage/CheckManager.java index 4c6d41b..0e3c816 100644 --- a/src/main/java/net/h31ix/anticheat/manage/CheckManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/CheckManager.java @@ -84,17 +84,12 @@ public class CheckManager return exemptList.containsEntry(player.getName(), type); } - private boolean hasPermission(Player player, String permission) - { - return player.hasPermission(permission) || player.hasPermission("anticheat.exempt"); - } - public boolean willCheck(Player player, CheckType type) { return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) - && !hasPermission(player, type.getPermission()); + && !player.hasPermission(type.getPermission()); } public int getExempt() diff --git a/src/main/java/net/h31ix/anticheat/util/Utilities.java b/src/main/java/net/h31ix/anticheat/util/Utilities.java index eedf74b..24f152d 100644 --- a/src/main/java/net/h31ix/anticheat/util/Utilities.java +++ b/src/main/java/net/h31ix/anticheat/util/Utilities.java @@ -40,16 +40,10 @@ public final class Utilities } public static void alert(String [] message) { - for(Player p : Bukkit.getServer().getOnlinePlayers()) + for(String msg : message) { - if(p.hasPermission("anticheat.alert") || p.hasPermission("anticheat.admin") || p.hasPermission("anticheat.mod") || p.isOp()) - { - for(String msg : message) - { - p.sendMessage(msg); - } - } - } + Bukkit.broadcast(msg, "anticheat.alert"); + } if(Anticheat.getManager().getConfiguration().logConsole()) { for(String msg : message) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9572995..4e42b58 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -11,4 +11,131 @@ commands: anticheat: description: Control and view info about AntiCheat usage: /anticheat help - aliases: anti \ No newline at end of file + aliases: anti +permissions: + anticheat.alert: + description: Get alerts + anticheat.system.help: + description: Help access + anticheat.system.report: + description: Reports access + anticheat.system.spy: + description: Spy system access + anticheat.system.xray: + description: XRay info access + anticheat.mod: + description: Mod helper perm + children: + anticheat.alert: true + anticheat.system.help: true + anticheat.system.report: true + anticheat.system.spy: true + anticheat.system.xray: true + anticheat.system.log: + description: Log access + anticheat.system.reload: + description: Reload access + anticheat.system.reset: + description: Reset access + anticheat.system.update: + description: Update access + anticheat.admin: + description: Admin helper perm + children: + anticheat.mod: true + anticheat.system.log: true + anticheat.system.reload: true + anticheat.system.reset: true + anticheat.system.update: true + anticheat.zombe.fly: + description: Allow players to use zombe flymod + default: false + anticheat.zombe.noclip: + description: Allow players to use zombe noclip hack + default: false + anticheat.zombe.cheat: + description: Allow players to use zombe cheat hack + default: false + anticheat.fly: + description: Allow players to fly + default: false + anticheat.waterwalk: + description: Allow players to walk on water + default: false + anticheat.noswing: + description: Allow players to not ever swing their arm + default: false + anticheat.fastbreak: + description: Allow players to quickly break blocks + default: false + anticheat.fastplace: + description: Allow players to use build hacks and fastplace + default: false + anticheat.spam: + description: Allow players to spam the server + default: false + anticheat.sprint: + description: Allow players to sprint when hungry + default: false + anticheat.sneak: + description: Allow players to use auto-sneak + default: false + anticheat.speed: + description: Use this with anticheat.flyhack to allow more speed + default: false + anticheat.spider: + description: Allow players to climb non-climbable surfaces + default: false + anticheat.nofall: + description: Allow players to avoid fall damage + default: false + anticheat.fastbow: + description: Allow players to quickly fire bows + default: false + anticheat.fasteat: + description: Allow players to eat food instantly + default: false + anticheat.fastheal: + description: Allow players to heal up instantly + default: false + anticheat.forcefield: + description: Allow players to use a forcefield + default: false + anticheat.xray: + description: Allow players to bypass xray stats + default: false + anticheat.longreach: + description: Allow players to use longreaching hacks + default: false + anticheat.projectile: + description: Allow players to quickly launch projectiles + default: false + anticheat.itemspam: + description: Allow players to use inventory drop spam hacks + default: false + anticheat.exempt: + description: Total exemption from checks + default: false + children: + anticheat.zombe.fly: true + anticheat.zombe.noclip: true + anticheat.zombe.cheat: true + anticheat.fly: true + anticheat.waterwalk: true + anticheat.noswing: true + anticheat.fastbreak: true + anticheat.fastplace: true + anticheat.spam: true + anticheat.sprint: true + anticheat.sneak: true + anticheat.speed: true + anticheat.spider: true + anticheat.nofall: true + anticheat.fastbow: true + anticheat.fasteat: true + anticheat.fastheal: true + anticheat.forcefield: true + anticheat.xray: true + anticheat.longreach: true + anticheat.projectile: true + anticheat.itemspam: true \ No newline at end of file From 618f63b0a06587cb47fc8ec472787756f3835f93 Mon Sep 17 00:00:00 2001 From: Super Spy Date: Mon, 11 Jun 2012 22:06:24 -0500 Subject: [PATCH 36/39] Rewrote Permissions to make our lives that easier. --- .../net/h31ix/anticheat/CommandHandler.java | 18 ++--- .../java/net/h31ix/anticheat/Permissions.java | 79 +++++++++++++++++++ .../net/h31ix/anticheat/api/AnticheatAPI.java | 2 +- .../h31ix/anticheat/manage/CheckManager.java | 2 +- .../net/h31ix/anticheat/manage/CheckType.java | 57 ++++++------- 5 files changed, 120 insertions(+), 38 deletions(-) create mode 100644 src/main/java/net/h31ix/anticheat/Permissions.java diff --git a/src/main/java/net/h31ix/anticheat/CommandHandler.java b/src/main/java/net/h31ix/anticheat/CommandHandler.java index 89b05d9..ded9626 100644 --- a/src/main/java/net/h31ix/anticheat/CommandHandler.java +++ b/src/main/java/net/h31ix/anticheat/CommandHandler.java @@ -56,7 +56,7 @@ public class CommandHandler implements CommandExecutor public void handleLog(CommandSender cs, String [] args) { - if(cs.hasPermission("system.log")) + if(Permissions.SYSTEM_LOG.get(cs)) { if(args[1].equalsIgnoreCase("enable")) { @@ -95,7 +95,7 @@ public class CommandHandler implements CommandExecutor public void handleXRay(CommandSender cs, String [] args) { - if(cs.hasPermission("system.xray")) + if(Permissions.SYSTEM_XRAY.get(cs)) { if(config.logXRay()) { @@ -140,7 +140,7 @@ public class CommandHandler implements CommandExecutor public void handleReset(CommandSender cs, String [] args) { - if(cs.hasPermission("system.reset")) + if(Permissions.SYSTEM_RESET.get(cs)) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -178,7 +178,7 @@ public class CommandHandler implements CommandExecutor if(cs instanceof Player) { Player sender = (Player)cs; - if(cs.hasPermission("system.spy")) + if(Permissions.SYSTEM_SPY.get(cs)) { if(!args[1].equalsIgnoreCase("off")) { @@ -234,7 +234,7 @@ public class CommandHandler implements CommandExecutor public void handleHelp(CommandSender cs) { - if(cs.hasPermission("system.help")) + if(Permissions.SYSTEM_HELP.get(cs)) { String base = "/AntiCheat "; cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------"); @@ -257,7 +257,7 @@ public class CommandHandler implements CommandExecutor public void handleUpdate(CommandSender cs) { - if(cs.hasPermission("system.update")) + if(Permissions.SYSTEM_UPDATE.get(cs)) { cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion()); cs.sendMessage("-----------------------------------------------------"); @@ -287,7 +287,7 @@ public class CommandHandler implements CommandExecutor public void handleReport(CommandSender cs) { - if(cs.hasPermission("system.report")) + if(Permissions.SYSTEM_REPORT.get(cs)) { getPlayers(); if(!low.isEmpty()) @@ -323,7 +323,7 @@ public class CommandHandler implements CommandExecutor public void handlePlayerReport(CommandSender cs,String [] args) { - if(cs.hasPermission("system.report")) + if(Permissions.SYSTEM_REPORT.get(cs)) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -437,7 +437,7 @@ public class CommandHandler implements CommandExecutor public void handleReload(CommandSender cs) { - if(cs.hasPermission("system.reload")) + if(Permissions.SYSTEM_RELOAD.get(cs)) { config.load(); cs.sendMessage(GREEN+"AntiCheat configuration reloaded."); diff --git a/src/main/java/net/h31ix/anticheat/Permissions.java b/src/main/java/net/h31ix/anticheat/Permissions.java new file mode 100644 index 0000000..11e441c --- /dev/null +++ b/src/main/java/net/h31ix/anticheat/Permissions.java @@ -0,0 +1,79 @@ +package net.h31ix.anticheat; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public enum Permissions { + + /* Check Nodes */ + ZOMBE_FLY("zombe.fly", true), + ZOMBE_NOCLIP("zombe.noclip", true), + ZOMBE_CHEAT("zombe.chest", true), + FLY("", true), + WATER_WALK("", true), + NO_SWING("", true), + FAST_BREAK("", true), + FAST_PLACE("", true), + SPAM("", true), + SPRINT("", true), + SNEAK("", true), + SPEED("", true), + SPIDER("", true), + NOFALL("", true), + FAST_BOW("", true), + FAST_EAT("", true), + FAST_HEAL("", true), + FORCEFIELD("", true), + XRAY("", true), + LONG_REACH("", true), + FAST_PROJECTILE("", true), + ITEM_SPAM("", true), + + /* System Nodes */ + SYSTEM_LOG("system.log", false), + SYSTEM_XRAY("system.xray", false), + SYSTEM_RESET("system.reset", false), + SYSTEM_SPY("system.spy", false), + SYSTEM_HELP("system.help", false), + SYSTEM_UPDATE("system.update", false), + SYSTEM_REPORT("system.report", false), + SYSTEM_RELOAD("system.reload", false); + + + String permnode = ""; + boolean isCheckType; + Permissions(String node, boolean isCheckTypeNode) + { + permnode = node; + isCheckType = isCheckTypeNode; + } + + public boolean get(CommandSender player) + { + return getPermission(player); + } + + public boolean getPermission(CommandSender player) + { + return player.hasPermission(parsePermissionNode()); + } + + private String parsePermissionNode() + { + if(!isCheckType) + { + return "anticheat." + permnode; + } + else + { + return "anticheat.checks." + parseEnum(); + } + } + + private String parseEnum() + { + return this.name().toLowerCase().replace("_", ""); + } + + +} diff --git a/src/main/java/net/h31ix/anticheat/api/AnticheatAPI.java b/src/main/java/net/h31ix/anticheat/api/AnticheatAPI.java index e351b4e..323b00b 100644 --- a/src/main/java/net/h31ix/anticheat/api/AnticheatAPI.java +++ b/src/main/java/net/h31ix/anticheat/api/AnticheatAPI.java @@ -114,7 +114,7 @@ public class AnticheatAPI */ public boolean willCheck(Player player, CheckType type) { - return chk.willCheck(player, type); + return chk.willCheck(player, type); } //PlayerManager API diff --git a/src/main/java/net/h31ix/anticheat/manage/CheckManager.java b/src/main/java/net/h31ix/anticheat/manage/CheckManager.java index 0e3c816..0c61949 100644 --- a/src/main/java/net/h31ix/anticheat/manage/CheckManager.java +++ b/src/main/java/net/h31ix/anticheat/manage/CheckManager.java @@ -89,7 +89,7 @@ public class CheckManager return isActive(type) && manager.getConfiguration().checkInWorld(player.getWorld()) && !isExempt(player, type) - && !player.hasPermission(type.getPermission()); + && !type.checkPermission(player); } public int getExempt() diff --git a/src/main/java/net/h31ix/anticheat/manage/CheckType.java b/src/main/java/net/h31ix/anticheat/manage/CheckType.java index 47b8b30..aace43c 100644 --- a/src/main/java/net/h31ix/anticheat/manage/CheckType.java +++ b/src/main/java/net/h31ix/anticheat/manage/CheckType.java @@ -20,6 +20,9 @@ package net.h31ix.anticheat.manage; import java.util.HashMap; import java.util.Map; + +import net.h31ix.anticheat.Permissions; + import org.bukkit.entity.Player; @@ -31,40 +34,40 @@ import org.bukkit.entity.Player; public enum CheckType { - ZOMBE_FLY("anticheat.zombe.fly"), - ZOMBE_NOCLIP("anticheat.zombe.noclip"), - ZOMBE_CHEAT("anticheat.zombe.cheat"), - FLY("anticheat.fly"), - WATER_WALK("anticheat.waterwalk"), - NO_SWING("anticheat.noswing"), - FAST_BREAK("anticheat.fastbreak"), - FAST_PLACE("anticheat.fastplace"), - SPAM("anticheat.spam"), - SPRINT("anticheat.sprint"), - SNEAK("anticheat.sneak"), - SPEED("anticheat.speed"), - SPIDER("anticheat.spider"), - NOFALL("anticheat.nofall"), - FAST_BOW("anticheat.fastbow"), - FAST_EAT("anticheat.fasteat"), - FAST_HEAL("anticheat.fastheal"), - FORCEFIELD("anticheat.forcefield"), - XRAY("anticheat.xray"), - LONG_REACH("anticheat.longreach"), - FAST_PROJECTILE("anticheat.projectile"), - ITEM_SPAM("anticheat.itemspam"); + ZOMBE_FLY(Permissions.ZOMBE_FLY), + ZOMBE_NOCLIP(Permissions.ZOMBE_NOCLIP), + ZOMBE_CHEAT(Permissions.ZOMBE_CHEAT), + FLY(Permissions.FLY), + WATER_WALK(Permissions.WATER_WALK), + NO_SWING(Permissions.NO_SWING), + FAST_BREAK(Permissions.FAST_BREAK), + FAST_PLACE(Permissions.FAST_PLACE), + SPAM(Permissions.SPAM), + SPRINT(Permissions.SPRINT), + SNEAK(Permissions.SNEAK), + SPEED(Permissions.SPEED), + SPIDER(Permissions.SPIDER), + NOFALL(Permissions.NOFALL), + FAST_BOW(Permissions.FAST_BOW), + FAST_EAT(Permissions.FAST_EAT), + FAST_HEAL(Permissions.FAST_HEAL), + FORCEFIELD(Permissions.FORCEFIELD), + XRAY(Permissions.XRAY), + LONG_REACH(Permissions.LONG_REACH), + FAST_PROJECTILE(Permissions.FAST_PROJECTILE), + ITEM_SPAM(Permissions.ITEM_SPAM); - private final String permission; + private final Permissions permission; private final Map level = new HashMap(); - private CheckType(String permission) + private CheckType(Permissions perm) { - this.permission = permission; + this.permission = perm; } - public String getPermission() + public boolean checkPermission(Player player) { - return this.permission; + return permission.get(player); } public void logUse(Player player) From ae14ff694b6d7876ef9e389d1a541ea2f101239f Mon Sep 17 00:00:00 2001 From: H31IX Date: Mon, 11 Jun 2012 23:28:46 -0400 Subject: [PATCH 37/39] Permissions updated --- pom.xml | 2 +- .../java/net/h31ix/anticheat/Anticheat.java | 2 +- .../net/h31ix/anticheat/CommandHandler.java | 18 ++--- .../java/net/h31ix/anticheat/Permission.java | 56 +++++++++++++ .../java/net/h31ix/anticheat/Permissions.java | 79 ------------------- .../net/h31ix/anticheat/manage/CheckType.java | 52 ++++++------ 6 files changed, 92 insertions(+), 117 deletions(-) create mode 100644 src/main/java/net/h31ix/anticheat/Permission.java delete mode 100644 src/main/java/net/h31ix/anticheat/Permissions.java diff --git a/pom.xml b/pom.xml index 30eed17..7f07dd3 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.h31ix.anticheat AntiCheat - 1.3.1 + 1.3.2-DEV AntiCheat http://H31IX.NET/ diff --git a/src/main/java/net/h31ix/anticheat/Anticheat.java b/src/main/java/net/h31ix/anticheat/Anticheat.java index 3251c1c..9fc1f32 100644 --- a/src/main/java/net/h31ix/anticheat/Anticheat.java +++ b/src/main/java/net/h31ix/anticheat/Anticheat.java @@ -210,7 +210,7 @@ public class Anticheat extends JavaPlugin if (verbose) { logger.log(Level.INFO, "Finished loading."); - } + } } private void saveFile(String file, String url) diff --git a/src/main/java/net/h31ix/anticheat/CommandHandler.java b/src/main/java/net/h31ix/anticheat/CommandHandler.java index ded9626..2ed9cdf 100644 --- a/src/main/java/net/h31ix/anticheat/CommandHandler.java +++ b/src/main/java/net/h31ix/anticheat/CommandHandler.java @@ -56,7 +56,7 @@ public class CommandHandler implements CommandExecutor public void handleLog(CommandSender cs, String [] args) { - if(Permissions.SYSTEM_LOG.get(cs)) + if(Permission.SYSTEM_LOG.get(cs)) { if(args[1].equalsIgnoreCase("enable")) { @@ -95,7 +95,7 @@ public class CommandHandler implements CommandExecutor public void handleXRay(CommandSender cs, String [] args) { - if(Permissions.SYSTEM_XRAY.get(cs)) + if(Permission.SYSTEM_XRAY.get(cs)) { if(config.logXRay()) { @@ -140,7 +140,7 @@ public class CommandHandler implements CommandExecutor public void handleReset(CommandSender cs, String [] args) { - if(Permissions.SYSTEM_RESET.get(cs)) + if(Permission.SYSTEM_RESET.get(cs)) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -178,7 +178,7 @@ public class CommandHandler implements CommandExecutor if(cs instanceof Player) { Player sender = (Player)cs; - if(Permissions.SYSTEM_SPY.get(cs)) + if(Permission.SYSTEM_SPY.get(cs)) { if(!args[1].equalsIgnoreCase("off")) { @@ -234,7 +234,7 @@ public class CommandHandler implements CommandExecutor public void handleHelp(CommandSender cs) { - if(Permissions.SYSTEM_HELP.get(cs)) + if(Permission.SYSTEM_HELP.get(cs)) { String base = "/AntiCheat "; cs.sendMessage("----------------------["+GREEN+"AntiCheat"+WHITE+"]----------------------"); @@ -257,7 +257,7 @@ public class CommandHandler implements CommandExecutor public void handleUpdate(CommandSender cs) { - if(Permissions.SYSTEM_UPDATE.get(cs)) + if(Permission.SYSTEM_UPDATE.get(cs)) { cs.sendMessage("Running "+GREEN+"AntiCheat "+WHITE+"v"+GREEN+Anticheat.getVersion()); cs.sendMessage("-----------------------------------------------------"); @@ -287,7 +287,7 @@ public class CommandHandler implements CommandExecutor public void handleReport(CommandSender cs) { - if(Permissions.SYSTEM_REPORT.get(cs)) + if(Permission.SYSTEM_REPORT.get(cs)) { getPlayers(); if(!low.isEmpty()) @@ -323,7 +323,7 @@ public class CommandHandler implements CommandExecutor public void handlePlayerReport(CommandSender cs,String [] args) { - if(Permissions.SYSTEM_REPORT.get(cs)) + if(Permission.SYSTEM_REPORT.get(cs)) { List list = SERVER.matchPlayer(args[1]); if(list.size() == 1) @@ -437,7 +437,7 @@ public class CommandHandler implements CommandExecutor public void handleReload(CommandSender cs) { - if(Permissions.SYSTEM_RELOAD.get(cs)) + if(Permission.SYSTEM_RELOAD.get(cs)) { config.load(); cs.sendMessage(GREEN+"AntiCheat configuration reloaded."); diff --git a/src/main/java/net/h31ix/anticheat/Permission.java b/src/main/java/net/h31ix/anticheat/Permission.java new file mode 100644 index 0000000..aca7759 --- /dev/null +++ b/src/main/java/net/h31ix/anticheat/Permission.java @@ -0,0 +1,56 @@ +package net.h31ix.anticheat; + +import org.bukkit.command.CommandSender; + +public enum Permission +{ + /* Check Nodes */ + CHECK_ZOMBE_FLY, + CHECK_ZOMBE_NOCLIP, + CHECK_ZOMBE_CHEAT, + CHECK_FLY, + CHECK_WATERWALK, + CHECK_NOSWING, + CHECK_FASTBREAK, + CHECK_FASTPLACE, + CHECK_SPAM, + CHECK_SPRINT, + CHECK_SNEAK, + CHECK_SPEED, + CHECK_SPIDER, + CHECK_NOFALL, + CHECK_FASTBOW, + CHECK_FASTEAT, + CHECK_FASTHEAL, + CHECK_FORCEFIELD, + CHECK_XRAY, + CHECK_LONGREACH, + CHECK_FASTPROJECTILE, + CHECK_ITEMSPAM, + + /* System Nodes */ + SYSTEM_LOG, + SYSTEM_XRAY, + SYSTEM_RESET, + SYSTEM_SPY, + SYSTEM_HELP, + SYSTEM_UPDATE, + SYSTEM_REPORT, + SYSTEM_RELOAD; + + public boolean get(CommandSender cs) + { + return cs.hasPermission(parsePermissionNode()); + } + + private String parsePermissionNode() + { + return "anticheat." + parse(); + } + + private String parse() + { + return this.name().toLowerCase().replace("_", "."); + } + +} \ No newline at end of file diff --git a/src/main/java/net/h31ix/anticheat/Permissions.java b/src/main/java/net/h31ix/anticheat/Permissions.java deleted file mode 100644 index 11e441c..0000000 --- a/src/main/java/net/h31ix/anticheat/Permissions.java +++ /dev/null @@ -1,79 +0,0 @@ -package net.h31ix.anticheat; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -public enum Permissions { - - /* Check Nodes */ - ZOMBE_FLY("zombe.fly", true), - ZOMBE_NOCLIP("zombe.noclip", true), - ZOMBE_CHEAT("zombe.chest", true), - FLY("", true), - WATER_WALK("", true), - NO_SWING("", true), - FAST_BREAK("", true), - FAST_PLACE("", true), - SPAM("", true), - SPRINT("", true), - SNEAK("", true), - SPEED("", true), - SPIDER("", true), - NOFALL("", true), - FAST_BOW("", true), - FAST_EAT("", true), - FAST_HEAL("", true), - FORCEFIELD("", true), - XRAY("", true), - LONG_REACH("", true), - FAST_PROJECTILE("", true), - ITEM_SPAM("", true), - - /* System Nodes */ - SYSTEM_LOG("system.log", false), - SYSTEM_XRAY("system.xray", false), - SYSTEM_RESET("system.reset", false), - SYSTEM_SPY("system.spy", false), - SYSTEM_HELP("system.help", false), - SYSTEM_UPDATE("system.update", false), - SYSTEM_REPORT("system.report", false), - SYSTEM_RELOAD("system.reload", false); - - - String permnode = ""; - boolean isCheckType; - Permissions(String node, boolean isCheckTypeNode) - { - permnode = node; - isCheckType = isCheckTypeNode; - } - - public boolean get(CommandSender player) - { - return getPermission(player); - } - - public boolean getPermission(CommandSender player) - { - return player.hasPermission(parsePermissionNode()); - } - - private String parsePermissionNode() - { - if(!isCheckType) - { - return "anticheat." + permnode; - } - else - { - return "anticheat.checks." + parseEnum(); - } - } - - private String parseEnum() - { - return this.name().toLowerCase().replace("_", ""); - } - - -} diff --git a/src/main/java/net/h31ix/anticheat/manage/CheckType.java b/src/main/java/net/h31ix/anticheat/manage/CheckType.java index aace43c..77e8fe0 100644 --- a/src/main/java/net/h31ix/anticheat/manage/CheckType.java +++ b/src/main/java/net/h31ix/anticheat/manage/CheckType.java @@ -20,9 +20,7 @@ package net.h31ix.anticheat.manage; import java.util.HashMap; import java.util.Map; - -import net.h31ix.anticheat.Permissions; - +import net.h31ix.anticheat.Permission; import org.bukkit.entity.Player; @@ -34,33 +32,33 @@ import org.bukkit.entity.Player; public enum CheckType { - ZOMBE_FLY(Permissions.ZOMBE_FLY), - ZOMBE_NOCLIP(Permissions.ZOMBE_NOCLIP), - ZOMBE_CHEAT(Permissions.ZOMBE_CHEAT), - FLY(Permissions.FLY), - WATER_WALK(Permissions.WATER_WALK), - NO_SWING(Permissions.NO_SWING), - FAST_BREAK(Permissions.FAST_BREAK), - FAST_PLACE(Permissions.FAST_PLACE), - SPAM(Permissions.SPAM), - SPRINT(Permissions.SPRINT), - SNEAK(Permissions.SNEAK), - SPEED(Permissions.SPEED), - SPIDER(Permissions.SPIDER), - NOFALL(Permissions.NOFALL), - FAST_BOW(Permissions.FAST_BOW), - FAST_EAT(Permissions.FAST_EAT), - FAST_HEAL(Permissions.FAST_HEAL), - FORCEFIELD(Permissions.FORCEFIELD), - XRAY(Permissions.XRAY), - LONG_REACH(Permissions.LONG_REACH), - FAST_PROJECTILE(Permissions.FAST_PROJECTILE), - ITEM_SPAM(Permissions.ITEM_SPAM); + ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY), + ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP), + ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT), + FLY(Permission.CHECK_FLY), + WATER_WALK(Permission.CHECK_WATERWALK), + NO_SWING(Permission.CHECK_NOSWING), + FAST_BREAK(Permission.CHECK_FASTBREAK), + FAST_PLACE(Permission.CHECK_FASTPLACE), + SPAM(Permission.CHECK_SPAM), + SPRINT(Permission.CHECK_SPRINT), + SNEAK(Permission.CHECK_SNEAK), + SPEED(Permission.CHECK_SPEED), + SPIDER(Permission.CHECK_SPIDER), + NOFALL(Permission.CHECK_NOFALL), + FAST_BOW(Permission.CHECK_FASTBOW), + FAST_EAT(Permission.CHECK_FASTEAT), + FAST_HEAL(Permission.CHECK_FASTHEAL), + FORCEFIELD(Permission.CHECK_FORCEFIELD), + XRAY(Permission.CHECK_XRAY), + LONG_REACH(Permission.CHECK_LONGREACH), + FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE), + ITEM_SPAM(Permission.CHECK_ITEMSPAM); - private final Permissions permission; + private final Permission permission; private final Map level = new HashMap(); - private CheckType(Permissions perm) + private CheckType(Permission perm) { this.permission = perm; } From 7c904bbeda49342d8111138ab398b69f01ed9725 Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Mon, 11 Jun 2012 23:57:34 -0400 Subject: [PATCH 38/39] Permission update for plugin.yml Also updated Permission to have a toString that gives the full node in case another dev wishes to check anticheat perms via hooking Yay --- .../java/net/h31ix/anticheat/Permission.java | 24 ++--- src/main/resources/plugin.yml | 92 +++++++++---------- 2 files changed, 56 insertions(+), 60 deletions(-) diff --git a/src/main/java/net/h31ix/anticheat/Permission.java b/src/main/java/net/h31ix/anticheat/Permission.java index aca7759..15557cb 100644 --- a/src/main/java/net/h31ix/anticheat/Permission.java +++ b/src/main/java/net/h31ix/anticheat/Permission.java @@ -1,7 +1,7 @@ package net.h31ix.anticheat; - + import org.bukkit.command.CommandSender; - + public enum Permission { /* Check Nodes */ @@ -27,7 +27,7 @@ public enum Permission CHECK_LONGREACH, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, - + /* System Nodes */ SYSTEM_LOG, SYSTEM_XRAY, @@ -37,20 +37,16 @@ public enum Permission SYSTEM_UPDATE, SYSTEM_REPORT, SYSTEM_RELOAD; - + public boolean get(CommandSender cs) { - return cs.hasPermission(parsePermissionNode()); + return cs.hasPermission(toString()); } - - private String parsePermissionNode() + + @Override + public String toString() { - return "anticheat." + parse(); + return "anticheat." + this.name().toLowerCase().replace("_", "."); } - - private String parse() - { - return this.name().toLowerCase().replace("_", "."); - } - + } \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4e42b58..6a72a7f 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -47,95 +47,95 @@ permissions: anticheat.system.reload: true anticheat.system.reset: true anticheat.system.update: true - anticheat.zombe.fly: + anticheat.check.zombe.fly: description: Allow players to use zombe flymod default: false - anticheat.zombe.noclip: + anticheat.check.zombe.noclip: description: Allow players to use zombe noclip hack default: false - anticheat.zombe.cheat: + anticheat.check.zombe.cheat: description: Allow players to use zombe cheat hack default: false - anticheat.fly: + anticheat.check.fly: description: Allow players to fly default: false - anticheat.waterwalk: + anticheat.check.waterwalk: description: Allow players to walk on water default: false - anticheat.noswing: + anticheat.check.noswing: description: Allow players to not ever swing their arm default: false - anticheat.fastbreak: + anticheat.check.fastbreak: description: Allow players to quickly break blocks default: false - anticheat.fastplace: + anticheat.check.fastplace: description: Allow players to use build hacks and fastplace default: false - anticheat.spam: + anticheat.check.spam: description: Allow players to spam the server default: false - anticheat.sprint: + anticheat.check.sprint: description: Allow players to sprint when hungry default: false - anticheat.sneak: + anticheat.check.sneak: description: Allow players to use auto-sneak default: false - anticheat.speed: - description: Use this with anticheat.flyhack to allow more speed + anticheat.check.speed: + description: Use this with anticheat.check.flyhack to allow more speed default: false - anticheat.spider: + anticheat.check.spider: description: Allow players to climb non-climbable surfaces default: false - anticheat.nofall: + anticheat.check.nofall: description: Allow players to avoid fall damage default: false - anticheat.fastbow: + anticheat.check.fastbow: description: Allow players to quickly fire bows default: false - anticheat.fasteat: + anticheat.check.fasteat: description: Allow players to eat food instantly default: false - anticheat.fastheal: + anticheat.check.fastheal: description: Allow players to heal up instantly default: false - anticheat.forcefield: + anticheat.check.forcefield: description: Allow players to use a forcefield default: false - anticheat.xray: + anticheat.check.xray: description: Allow players to bypass xray stats default: false - anticheat.longreach: + anticheat.check.longreach: description: Allow players to use longreaching hacks default: false - anticheat.projectile: + anticheat.check.projectile: description: Allow players to quickly launch projectiles default: false - anticheat.itemspam: + anticheat.check.itemspam: description: Allow players to use inventory drop spam hacks default: false - anticheat.exempt: + anticheat.check.exempt: description: Total exemption from checks default: false children: - anticheat.zombe.fly: true - anticheat.zombe.noclip: true - anticheat.zombe.cheat: true - anticheat.fly: true - anticheat.waterwalk: true - anticheat.noswing: true - anticheat.fastbreak: true - anticheat.fastplace: true - anticheat.spam: true - anticheat.sprint: true - anticheat.sneak: true - anticheat.speed: true - anticheat.spider: true - anticheat.nofall: true - anticheat.fastbow: true - anticheat.fasteat: true - anticheat.fastheal: true - anticheat.forcefield: true - anticheat.xray: true - anticheat.longreach: true - anticheat.projectile: true - anticheat.itemspam: true \ No newline at end of file + anticheat.check.zombe.fly: true + anticheat.check.zombe.noclip: true + anticheat.check.zombe.cheat: true + anticheat.check.fly: true + anticheat.check.waterwalk: true + anticheat.check.noswing: true + anticheat.check.fastbreak: true + anticheat.check.fastplace: true + anticheat.check.spam: true + anticheat.check.sprint: true + anticheat.check.sneak: true + anticheat.check.speed: true + anticheat.check.spider: true + anticheat.check.nofall: true + anticheat.check.fastbow: true + anticheat.check.fasteat: true + anticheat.check.fastheal: true + anticheat.check.forcefield: true + anticheat.check.xray: true + anticheat.check.longreach: true + anticheat.check.projectile: true + anticheat.check.itemspam: true \ No newline at end of file From be474a2aad94dbb75ad2d83441afe6d8a3891438 Mon Sep 17 00:00:00 2001 From: Matt Baxter Date: Tue, 12 Jun 2012 07:38:21 -0400 Subject: [PATCH 39/39] GPL comments to missing files --- .../java/net/h31ix/anticheat/Language.java | 18 ++++++++++++++++++ .../java/net/h31ix/anticheat/Permission.java | 18 ++++++++++++++++++ .../h31ix/anticheat/util/ConsoleFormatter.java | 18 ++++++++++++++++++ .../h31ix/anticheat/util/FileFormatter.java | 18 ++++++++++++++++++ 4 files changed, 72 insertions(+) diff --git a/src/main/java/net/h31ix/anticheat/Language.java b/src/main/java/net/h31ix/anticheat/Language.java index 55f94cc..6edc9c7 100644 --- a/src/main/java/net/h31ix/anticheat/Language.java +++ b/src/main/java/net/h31ix/anticheat/Language.java @@ -1,3 +1,21 @@ +/* + * AntiCheat for Bukkit. + * Copyright (C) 2012 H31IX http://h31ix.net + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.h31ix.anticheat; import org.bukkit.configuration.file.FileConfiguration; diff --git a/src/main/java/net/h31ix/anticheat/Permission.java b/src/main/java/net/h31ix/anticheat/Permission.java index 15557cb..cf94dbc 100644 --- a/src/main/java/net/h31ix/anticheat/Permission.java +++ b/src/main/java/net/h31ix/anticheat/Permission.java @@ -1,3 +1,21 @@ +/* + * AntiCheat for Bukkit. + * Copyright (C) 2012 H31IX http://h31ix.net + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.h31ix.anticheat; import org.bukkit.command.CommandSender; diff --git a/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java b/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java index c1b82f2..cb7dfd5 100644 --- a/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java +++ b/src/main/java/net/h31ix/anticheat/util/ConsoleFormatter.java @@ -1,3 +1,21 @@ +/* + * AntiCheat for Bukkit. + * Copyright (C) 2012 H31IX http://h31ix.net + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.h31ix.anticheat.util; import java.util.logging.Formatter; diff --git a/src/main/java/net/h31ix/anticheat/util/FileFormatter.java b/src/main/java/net/h31ix/anticheat/util/FileFormatter.java index c5dc69e..6b77e3d 100644 --- a/src/main/java/net/h31ix/anticheat/util/FileFormatter.java +++ b/src/main/java/net/h31ix/anticheat/util/FileFormatter.java @@ -1,3 +1,21 @@ +/* + * AntiCheat for Bukkit. + * Copyright (C) 2012 H31IX http://h31ix.net + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.h31ix.anticheat.util; import java.text.DateFormat;