diff --git a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java index cc723d5..ebe4f40 100644 --- a/src/main/java/net/h31ix/anticheat/event/PlayerListener.java +++ b/src/main/java/net/h31ix/anticheat/event/PlayerListener.java @@ -176,15 +176,15 @@ public class PlayerListener extends EventListener Distance distance = new Distance(player.getLocation(), event.getClickedBlock().getLocation()); backend.checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference()); } - + /* Interactions Check */ - - Block block = event.getClickedBlock(); - if(block != null) + + Block block = event.getClickedBlock(); + if (block != null) { - if(checkManager.willCheck(player, CheckType.VISUAL)) + if (checkManager.willCheck(player, CheckType.VISUAL)) { - if(backend.checkInteraction(player, block, playerClick)) + if (backend.checkInteraction(player, block, playerClick)) { event.setCancelled(true); log("tried to interact with an object that they couldn't see", player, CheckType.VISUAL); //boring description though. diff --git a/src/main/java/net/h31ix/anticheat/manage/Backend.java b/src/main/java/net/h31ix/anticheat/manage/Backend.java index 6666185..da0352d 100644 --- a/src/main/java/net/h31ix/anticheat/manage/Backend.java +++ b/src/main/java/net/h31ix/anticheat/manage/Backend.java @@ -58,7 +58,7 @@ public class Backend private static final int FASTPLACE_MAXVIOLATIONS = 2; private static final int FASTPLACE_MAXVIOLATIONS_CREATIVE = 3; private static final int FASTPLACE_MAXVIOLATIONTIME = 10000; - + private static final double VISUALS_MAXOFFSET = 2; private static final int BLOCK_PUNCH_MIN = 5; @@ -273,23 +273,23 @@ public class Backend return false; } } - - public boolean checkInteraction(Player player, Block targetBlock, Block playerClick) + + public boolean checkInteraction(Player player, Block targetBlock, Block playerClick) { - int strikes = 0; - - double x = targetBlock.getX() - playerClick.getX() * ((targetBlock.getX() - playerClick.getX() * 1) < 0 ? -1 : 1); - double y = targetBlock.getY() - playerClick.getY() * ((targetBlock.getY() - playerClick.getY() * 1) < 0 ? -1 : 1); - double z = targetBlock.getZ() - playerClick.getZ() * ((targetBlock.getZ() - playerClick.getZ() * 1) < 0 ? -1 : 1); - - player.sendMessage("X: " + x + " Y: " + y + " Z: " + z); - - if (x >= VISUALS_MAXOFFSET) strikes++; - if (y >= VISUALS_MAXOFFSET) strikes++; - if (z >= VISUALS_MAXOFFSET) strikes++; - - - return strikes > 0; + int strikes = 0; + + double x = targetBlock.getX() - playerClick.getX() * ((targetBlock.getX() - playerClick.getX() * 1) < 0 ? -1 : 1); + double y = targetBlock.getY() - playerClick.getY() * ((targetBlock.getY() - playerClick.getY() * 1) < 0 ? -1 : 1); + double z = targetBlock.getZ() - playerClick.getZ() * ((targetBlock.getZ() - playerClick.getZ() * 1) < 0 ? -1 : 1); + + if (x >= VISUALS_MAXOFFSET) + strikes++; + if (y >= VISUALS_MAXOFFSET) + strikes++; + if (z >= VISUALS_MAXOFFSET) + strikes++; + + return strikes > 0; } public boolean checkWaterWalk(Player player, double x, double z) @@ -699,7 +699,7 @@ public class Backend { logEvent(healed, player, HEAL_MIN); } - + public boolean justHealed(Player player) { return healed.contains(player.getName());