Added permissions to allow certain users to avoid checks.

This commit is contained in:
Adam committed 2012-04-27 17:54:32 -04:00
1 parent 6188216f97
commit b6caa519b9
1 file changed
+41 -4
@@ -59,16 +59,21 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
//Disable zombe's mods
event.getPlayer().sendMessage("§f §f §1 §0 §2 §4");
event.getPlayer().sendMessage("§f §f §2 §0 §4 §8");
event.getPlayer().sendMessage("§f §f §4 §0 §9 §6");
Player player = event.getPlayer();
if(!player.hasPermission("anticheat.zombe"))
{
player.sendMessage("§f §f §1 §0 §2 §4");
player.sendMessage("§f §f §2 §0 §4 §8");
player.sendMessage("§f §f §4 §0 §9 §6");
}
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
if(!player.hasPermission("anticheat.spamdrop"))
{
if(!im.hasDropped(player))
{
//Make sure the player isn't spamming drops
@@ -81,6 +86,7 @@ public class PlayerListener implements Listener {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerAnimation(PlayerAnimationEvent event)
@@ -104,6 +110,9 @@ public class PlayerListener implements Listener {
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
if(!player.hasPermission("anticheat.spam"))
{
if(!plugin.lagged)
{
@@ -111,11 +120,14 @@ public class PlayerListener implements Listener {
plugin.cm.addChat(event.getPlayer());
}
}
}
@EventHandler
public void onPlayerChat(PlayerChatEvent event)
{
Player player = event.getPlayer();
if(!player.hasPermission("anticheat.spam"))
{
if(player.getLocation().equals(player.getWorld().getSpawnLocation()))
{
//Make sure the player is not a potential spambot
@@ -128,6 +140,7 @@ public class PlayerListener implements Listener {
plugin.cm.addChat(player);
}
}
}
@EventHandler
public void onPlayerKick(PlayerKickEvent event)
@@ -163,6 +176,8 @@ public class PlayerListener implements Listener {
}
}
else if(xd > 0.19D || zd > 0.19D)
{
if(!player.hasPermission("anticheat.waterwalk"))
{
//Otherwise check for normal walking speeds, making sure they aren't using 'jesus' hacks
if(!player.isSprinting() && !player.isFlying())
@@ -172,7 +187,10 @@ public class PlayerListener implements Listener {
event.setTo(event.getFrom().clone());
}
}
}
else
{
if(!player.hasPermission("anticheat.waterwalk"))
{
//If they are flying/sprinting give them a bit of slack
if(xd > 0.3D || zd > 0.3D)
@@ -183,6 +201,7 @@ public class PlayerListener implements Listener {
}
}
}
}
else
{
//Are they in a vehicle?
@@ -201,6 +220,8 @@ public class PlayerListener implements Listener {
}
//Otherwise, are they sneaking?
else if(player.isSneaking())
{
if(!player.hasPermission("anticheat.sneakhack"))
{
//Make sure they are at normal sneak speeds. (not using sneak hacks)
if(xd > 0.2D || zd > 0.2D)
@@ -212,8 +233,11 @@ public class PlayerListener implements Listener {
player.setSneaking(false);
}
}
}
//Otherwise set a hardcoded limit to any other traveling
else if(xd > 0.4D || zd > 0.4D)
{
if(!player.hasPermission("anticheat.speedhack"))
{
if(!player.isFlying() && !player.hasPotionEffect(PotionEffectType.SPEED))
{
@@ -235,12 +259,15 @@ public class PlayerListener implements Listener {
}
}
}
}
//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)
{
if(!player.hasPermission("anticheat.spider"))
{
if(player.getLocation().getBlock().getType() != Material.VINE && player.getLocation().getBlock().getType() != Material.LADDER)
{
@@ -250,7 +277,10 @@ public class PlayerListener implements Listener {
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)
@@ -261,11 +291,14 @@ public class PlayerListener implements Listener {
}
}
}
}
//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)
@@ -277,11 +310,14 @@ public class PlayerListener implements Listener {
}
}
}
}
//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))
{
@@ -298,4 +334,5 @@ public class PlayerListener implements Listener {
}
}
}
}
}