mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Screw it, i'm calling it the interactables check. Only blocks that can be "switched" in anyway are blocked.
This commit is contained in:
1 parent
3a8c591c5b
commit
dcb7795f4f
4 files changed
+52
-36
No files matched your search
@@ -152,20 +152,17 @@ public class PlayerListener extends EventListener
|
||||
backend.checkLongReachBlock(player,distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
}
|
||||
|
||||
/* Visuals Check */
|
||||
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
/* Interactions Check */
|
||||
Block block = event.getClickedBlock();
|
||||
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
||||
{
|
||||
Block block = event.getClickedBlock();
|
||||
if(checkManager.willCheck(player, CheckType.VISUALS))
|
||||
// save load and actually call the backend check here.
|
||||
if(backend.checkInteraction(player, block))
|
||||
{
|
||||
// save load and actually call the backend check here.
|
||||
if(backend.checkVisuals(player, block))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
log("failed visuals check",player,CheckType.VISUALS);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
log("failed interaction check",player,CheckType.INTERACTION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public class Backend
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkVisuals(Player player, Block block)
|
||||
public boolean checkInteraction(Player player, Block block)
|
||||
{
|
||||
// The most complicated check in the world...approaching nirvana.
|
||||
int strikes = 0;
|
||||
@@ -292,6 +292,7 @@ public class Backend
|
||||
|
||||
if(direction != null)
|
||||
{
|
||||
|
||||
for(int g = 0; g < 2; g++)
|
||||
{
|
||||
py = py+g;
|
||||
@@ -314,7 +315,7 @@ public class Backend
|
||||
if(coords.getX() < block.getLocation().getX())
|
||||
{
|
||||
ignoreothers = true;
|
||||
player.sendBlockChange(coords, 66, (byte) 0);
|
||||
//player.sendBlockChange(coords, 66, (byte) 0);
|
||||
}
|
||||
|
||||
if(block.getLocation().distance(coords) > 5D)
|
||||
@@ -324,8 +325,8 @@ public class Backend
|
||||
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||
{
|
||||
player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -350,13 +351,13 @@ public class Backend
|
||||
if(coords.getZ() < block.getLocation().getZ())
|
||||
{
|
||||
ignoreothers = true;
|
||||
player.sendBlockChange(coords, 66, (byte) 0);
|
||||
//player.sendBlockChange(coords, 66, (byte) 0);
|
||||
}
|
||||
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||
{
|
||||
player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -385,13 +386,13 @@ public class Backend
|
||||
if(coords.getX() < block.getLocation().getX())
|
||||
{
|
||||
ignoreothers = true;
|
||||
player.sendBlockChange(coords, 66, (byte) 0);
|
||||
//player.sendBlockChange(coords, 66, (byte) 0);
|
||||
}
|
||||
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||
{
|
||||
player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -416,13 +417,13 @@ public class Backend
|
||||
if(coords.getZ() < block.getLocation().getZ())
|
||||
{
|
||||
ignoreothers = true;
|
||||
player.sendBlockChange(coords, 66, (byte) 0);
|
||||
//player.sendBlockChange(coords, 66, (byte) 0);
|
||||
}
|
||||
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||
{
|
||||
player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -438,8 +439,8 @@ public class Backend
|
||||
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||
{
|
||||
player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -452,8 +453,8 @@ public class Backend
|
||||
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||
{
|
||||
player.sendMessage("Block detected at +Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at +Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -479,8 +480,8 @@ public class Backend
|
||||
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||
{
|
||||
player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -503,8 +504,8 @@ public class Backend
|
||||
|
||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||
{
|
||||
player.sendMessage("Block detected at +Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
player.sendBlockChange(coords, 46, (byte) 0);
|
||||
//player.sendMessage("Block detected at +Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||
//player.sendBlockChange(coords, 46, (byte) 0);
|
||||
strikes++;
|
||||
}
|
||||
}
|
||||
@@ -513,8 +514,8 @@ public class Backend
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage("Strikes: " + strikes + " Dir: " + direction);
|
||||
player.sendMessage("X: " + x + " Y: " + y + " Z:" + z);
|
||||
//player.sendMessage("Strikes: " + strikes + " Dir: " + direction);
|
||||
//player.sendMessage("X: " + x + " Y: " + y + " Z:" + z);
|
||||
|
||||
return strikes > 0;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public enum CheckType
|
||||
WATER_WALK("anticheat.waterwalk"),
|
||||
NO_SWING("anticheat.noswing"),
|
||||
FAST_BREAK("anticheat.fastbreak"),
|
||||
VISUALS("anticheat.visuals"),
|
||||
INTERACTION("anticheat.interaction"),
|
||||
FAST_PLACE("anticheat.fastplace"),
|
||||
SPAM("anticheat.spam"),
|
||||
SPRINT("anticheat.sprint"),
|
||||
|
||||
@@ -34,6 +34,7 @@ public final class Utilities
|
||||
{
|
||||
private static final List<Material> INSTANT_BREAK = new ArrayList<Material>();
|
||||
private static final List<Material> FOOD = new ArrayList<Material>();
|
||||
private static final List<Material> INTERACTABLE = new ArrayList<Material>();
|
||||
|
||||
private Utilities()
|
||||
{
|
||||
@@ -82,7 +83,10 @@ public final class Utilities
|
||||
public static boolean isFood(Material m)
|
||||
{
|
||||
return FOOD.contains(m);
|
||||
}
|
||||
}
|
||||
public static boolean isInteractable(Material m) {
|
||||
return INTERACTABLE.contains(m);
|
||||
}
|
||||
public static boolean sprintFly(Player player)
|
||||
{
|
||||
return player.isSprinting() || player.isFlying();
|
||||
@@ -197,6 +201,20 @@ public final class Utilities
|
||||
INSTANT_BREAK.add(Material.CROPS);
|
||||
INSTANT_BREAK.add(Material.SNOW);
|
||||
INSTANT_BREAK.add(Material.TNT);
|
||||
INTERACTABLE.add(Material.STONE_BUTTON);
|
||||
INTERACTABLE.add(Material.LEVER);
|
||||
INTERACTABLE.add(Material.CHEST);
|
||||
INTERACTABLE.add(Material.DISPENSER);
|
||||
INTERACTABLE.add(Material.CAULDRON);
|
||||
INTERACTABLE.add(Material.ENCHANTMENT_TABLE);
|
||||
INTERACTABLE.add(Material.WOOD_DOOR);
|
||||
INTERACTABLE.add(Material.IRON_DOOR);
|
||||
INTERACTABLE.add(Material.WORKBENCH);
|
||||
INTERACTABLE.add(Material.CAKE_BLOCK);
|
||||
INTERACTABLE.add(Material.STONE_PLATE);
|
||||
INTERACTABLE.add(Material.FENCE_GATE);
|
||||
INTERACTABLE.add(Material.TRAP_DOOR);
|
||||
//INTERACTABLE.add(Material. - placeholder.
|
||||
FOOD.add(Material.COOKED_BEEF);
|
||||
FOOD.add(Material.COOKED_CHICKEN);
|
||||
FOOD.add(Material.COOKED_FISH);
|
||||
|
||||
Reference in new issue
Block a user