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 @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(PlayerJoinEvent event)
{ {
//Disable zombe's mods Player player = event.getPlayer();
event.getPlayer().sendMessage("§f §f §1 §0 §2 §4"); if(!player.hasPermission("anticheat.zombe"))
event.getPlayer().sendMessage("§f §f §2 §0 §4 §8"); {
event.getPlayer().sendMessage("§f §f §4 §0 §9 §6"); 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 @EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) public void onPlayerDropItem(PlayerDropItemEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(!player.hasPermission("anticheat.spamdrop"))
{
if(!im.hasDropped(player)) if(!im.hasDropped(player))
{ {
//Make sure the player isn't spamming drops //Make sure the player isn't spamming drops
@@ -81,6 +86,7 @@ public class PlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
}
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerAnimation(PlayerAnimationEvent event) public void onPlayerAnimation(PlayerAnimationEvent event)
@@ -104,6 +110,9 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
Player player = event.getPlayer();
if(!player.hasPermission("anticheat.spam"))
{ {
if(!plugin.lagged) if(!plugin.lagged)
{ {
@@ -111,11 +120,14 @@ public class PlayerListener implements Listener {
plugin.cm.addChat(event.getPlayer()); plugin.cm.addChat(event.getPlayer());
} }
} }
}
@EventHandler @EventHandler
public void onPlayerChat(PlayerChatEvent event) public void onPlayerChat(PlayerChatEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(!player.hasPermission("anticheat.spam"))
{
if(player.getLocation().equals(player.getWorld().getSpawnLocation())) if(player.getLocation().equals(player.getWorld().getSpawnLocation()))
{ {
//Make sure the player is not a potential spambot //Make sure the player is not a potential spambot
@@ -128,6 +140,7 @@ public class PlayerListener implements Listener {
plugin.cm.addChat(player); plugin.cm.addChat(player);
} }
} }
}
@EventHandler @EventHandler
public void onPlayerKick(PlayerKickEvent event) public void onPlayerKick(PlayerKickEvent event)
@@ -163,6 +176,8 @@ public class PlayerListener implements Listener {
} }
} }
else if(xd > 0.19D || zd > 0.19D) 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 //Otherwise check for normal walking speeds, making sure they aren't using 'jesus' hacks
if(!player.isSprinting() && !player.isFlying()) if(!player.isSprinting() && !player.isFlying())
@@ -172,7 +187,10 @@ public class PlayerListener implements Listener {
event.setTo(event.getFrom().clone()); event.setTo(event.getFrom().clone());
} }
} }
}
else else
{
if(!player.hasPermission("anticheat.waterwalk"))
{ {
//If they are flying/sprinting give them a bit of slack //If they are flying/sprinting give them a bit of slack
if(xd > 0.3D || zd > 0.3D) if(xd > 0.3D || zd > 0.3D)
@@ -183,6 +201,7 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
else else
{ {
//Are they in a vehicle? //Are they in a vehicle?
@@ -201,6 +220,8 @@ public class PlayerListener implements Listener {
} }
//Otherwise, are they sneaking? //Otherwise, are they sneaking?
else if(player.isSneaking()) else if(player.isSneaking())
{
if(!player.hasPermission("anticheat.sneakhack"))
{ {
//Make sure they are at normal sneak speeds. (not using sneak hacks) //Make sure they are at normal sneak speeds. (not using sneak hacks)
if(xd > 0.2D || zd > 0.2D) if(xd > 0.2D || zd > 0.2D)
@@ -212,8 +233,11 @@ public class PlayerListener implements Listener {
player.setSneaking(false); player.setSneaking(false);
} }
} }
}
//Otherwise set a hardcoded limit to any other traveling //Otherwise set a hardcoded limit to any other traveling
else if(xd > 0.4D || zd > 0.4D) else if(xd > 0.4D || zd > 0.4D)
{
if(!player.hasPermission("anticheat.speedhack"))
{ {
if(!player.isFlying() && !player.hasPotionEffect(PotionEffectType.SPEED)) if(!player.isFlying() && !player.hasPotionEffect(PotionEffectType.SPEED))
{ {
@@ -235,12 +259,15 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
//If the player is ascending //If the player is ascending
if(event.getFrom().getY() < event.getTo().getY()) if(event.getFrom().getY() < event.getTo().getY())
{ {
//TODO: This is a little hacky. Any better way to figure this out? //TODO: This is a little hacky. Any better way to figure this out?
//Are they climbing something? //Are they climbing something?
if(yd <= 0.11761 && yd >= 0.11759) 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(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()); event.setTo(event.getFrom().clone());
} }
} }
}
else if(!player.isFlying() && player.getVehicle() == null) else if(!player.isFlying() && player.getVehicle() == null)
{
if(!player.hasPermission("anticheat.flyhack"))
{ {
//Otherwise check for fast ascension //Otherwise check for fast ascension
if(yd > 0.5D) if(yd > 0.5D)
@@ -261,11 +291,14 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
//If they are falling //If they are falling
else if(event.getFrom().getY() > event.getTo().getY()) else if(event.getFrom().getY() > event.getTo().getY())
{ {
//Ignore players in creative or in vehicles, they give a fall distance of 0 naturally. //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.getGameMode() != GameMode.CREATIVE && player.getVehicle() == null)
{
if(!player.hasPermission("anticheat.nofall"))
{ {
hm.log(player); hm.log(player);
//Log health (for nofall detection) //Log health (for nofall detection)
@@ -277,11 +310,14 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
//No change in Y //No change in Y
else else
{ {
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); 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(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)) if (fm.checkFly(player))
{ {
@@ -298,4 +334,5 @@ public class PlayerListener implements Listener {
} }
} }
} }
}
} }