From 6f617c91629eaa8c342b347b2b1a7401609e6de8 Mon Sep 17 00:00:00 2001 From: Adam Date: Sat, 28 Apr 2012 00:47:11 -0400 Subject: [PATCH] Fixed water walking and flying, now it does checks for Y value situations even if you are in water. --- README.md | 46 ++++++ .../h31ix/anticheat/event/PlayerListener.java | 154 ++++++++++-------- 2 files changed, 131 insertions(+), 69 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..215d4f2 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +AntiCheat +============= + +Stop hackers and cheaters in their tracks! + +Usage +------- + +Simply drag and drop the plugin into your Plugins folder. Optional configuration and permissions are avaliable: + +Config.yml +------- + +Logging: + Log to console: `true if every violation should be printed to console, false to suppress these warnings.` +Events: + Level Medium: `NONE to do nothing, WARN to send the player a warning, KICK to kick the player, BAN to ban them.` + Level High: `NONE to do nothing, WARN to send the player a warning, KICK to kick the player, BAN to ban them.` + +Permissions +------- + +anticheat.zombe - `Allow use of zombe's mods` +anticheat.spamdrop - `Allow players to use inventory drop spam hacks` +anticheat.spam - `Allow players to spam the server` +anticheat.waterwalk - `Allow players to walk on water` +anticheat.sneakhack - `Allow players to use auto-sneak` +anticheat.flyhack - `Allow players to fly ` +anticheat.speedhack - `Use this with anticheat.flyhack to allow more speed` +anticheat.spider - `Allow players to climb non-climbable surfaces` +anticheat.nofall - `Allow players to avoid fall damage` +anticheat.autofire - `Allow players to spam bows using autofire` +anticheat.longreach - `Allow players to use longreaching hacks` +anticheat.noswing - `Allow players to not ever swing their arm` + +Bug Reporting/Support/Questions +------------ + +Feel free to leave a DETAILED comment describing the problem, the steps you take to re-create the problem, the result you got, and the result you EXPECTED to get on my BukkitDev page (see below). If you do that I'll be sure to reply back and take a look at the bug. +I'm also around a lot in IRC. Feel free to join me in #anticheat on irc.esper.net and ping me to report a game-breaking bug, or just to ask questions, get support, etc. + + +Resources +------- +BukkitDev --- http://dev.bukkit.org/server-mods/anticheat/ +Jenkins (Downloads) --- http://ci.h31ix.net/job/AntiCheat/ \ No newline at end of file diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index a0be854..ac7b1a3 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -260,79 +260,95 @@ public class PlayerListener implements Listener { } } } - //If the player is ascending - if(event.getFrom().getY() < event.getTo().getY()) + } + //If the player is ascending + if(event.getFrom().getY() < event.getTo().getY()) + { + //TODO: This is a little hacky. Any better way to figure this out? + //Are they climbing something? + if(yd <= 0.11761 && yd >= 0.11759) { - //TODO: This is a little hacky. Any better way to figure this out? - //Are they climbing something? - if(yd <= 0.11761 && yd >= 0.11759) - { - if(!player.hasPermission("anticheat.spider")) - { - if(player.getLocation().getBlock().getType() != Material.VINE && player.getLocation().getBlock().getType() != Material.LADDER) - { - //If it's not climbable, block it. - plugin.log(player.getName()+" tried to climb a wall!"); - tracker.increaseLevel(player); - event.setTo(event.getFrom().clone()); - } - } - } - else if(!player.isFlying() && player.getVehicle() == null) - { - if(!player.hasPermission("anticheat.flyhack")) - { - //Otherwise check for fast ascension - if(yd > 0.5D) - { - tracker.increaseLevel(player); - plugin.log(player.getName()+" is ascending too fast! YSpeed="+yd); - event.setTo(event.getFrom().clone()); - } - } - } - } - //If they are falling - else if(event.getFrom().getY() > event.getTo().getY()) - { - //Ignore players in creative or in vehicles, they give a fall distance of 0 naturally. - if(player.getGameMode() != GameMode.CREATIVE && player.getVehicle() == null) - { - if(!player.hasPermission("anticheat.nofall")) - { - hm.log(player); - //Log health (for nofall detection) - if(hm.checkFall(player)) - { - //If the player is falling but has a 0 fall distance - plugin.log(player.getName()+" tried to avoid fall damage!"); - tracker.increaseLevel(player); - } - } - } - } - //No change in Y - else - { - Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); - if(block.getType() == Material.AIR && block.getRelative(BlockFace.NORTH).getType() == Material.AIR && block.getRelative(BlockFace.EAST).getType() == Material.AIR && block.getRelative(BlockFace.SOUTH).getType() == Material.AIR && block.getRelative(BlockFace.WEST).getType() == Material.AIR) - { - if(!player.hasPermission("anticheat.flyhack")) - { - if (fm.checkFly(player)) - { - event.setTo(event.getFrom().clone()); - plugin.log(player.getName()+" tried to fly!"); - tracker.increaseLevel(player); - } - else - { - tracker.decreaseLevel(player); - } + if(!player.hasPermission("anticheat.spider")) + { + if(player.getLocation().getBlock().getType() != Material.VINE && player.getLocation().getBlock().getType() != Material.LADDER) + { + //If it's not climbable, block it. + plugin.log(player.getName()+" tried to climb a wall!"); + tracker.increaseLevel(player); + event.setTo(event.getFrom().clone()); } } } - } + else if(!player.isFlying() && player.getVehicle() == null) + { + if(!player.hasPermission("anticheat.flyhack")) + { + //Otherwise check for fast ascension + if(yd > 0.5D) + { + tracker.increaseLevel(player); + plugin.log(player.getName()+" is ascending too fast! YSpeed="+yd); + event.setTo(event.getFrom().clone()); + } + } + } + } + //If they are falling + else if(event.getFrom().getY() > event.getTo().getY()) + { + //Ignore players in creative or in vehicles, they give a fall distance of 0 naturally. + if(player.getGameMode() != GameMode.CREATIVE && player.getVehicle() == null) + { + if(!player.hasPermission("anticheat.nofall")) + { + hm.log(player); + //Log health (for nofall detection) + if(hm.checkFall(player)) + { + //If the player is falling but has a 0 fall distance + plugin.log(player.getName()+" tried to avoid fall damage!"); + tracker.increaseLevel(player); + } + } + } + } + //No change in Y + else + { + Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); + if(!canStand(block) && !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH))&& !canStand(block.getRelative(BlockFace.WEST))) + { + if(!player.hasPermission("anticheat.flyhack")) + { + if (fm.checkFly(player)) + { + event.setTo(event.getFrom().clone()); + plugin.log(player.getName()+" tried to fly!"); + tracker.increaseLevel(player); + } + else + { + tracker.decreaseLevel(player); + } + } + } + } } } + + public boolean canStand(Block block) + { + if(block.isLiquid()) + { + return false; + } + else if (block.getType() == Material.AIR) + { + return false; + } + else + { + return true; + } + } }