mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-04 06:28:52 +00:00
I made it pretty
This commit is contained in:
1 parent
1f53f4d1cd
commit
7ad0f63c34
2 files changed
+11
-31
No files matched your search
@@ -156,6 +156,7 @@ public class PlayerListener extends EventListener
|
|||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
if(checkManager.willCheck(player, CheckType.INTERACTION) && Utilities.isInteractable(block.getType()))
|
||||||
{
|
{
|
||||||
|
System.out.println("checking interaction");
|
||||||
// save load and actually call the backend check here.
|
// save load and actually call the backend check here.
|
||||||
if(backend.checkInteraction(player, block))
|
if(backend.checkInteraction(player, block))
|
||||||
{
|
{
|
||||||
@@ -163,8 +164,6 @@ public class PlayerListener extends EventListener
|
|||||||
log("failed interaction check",player,CheckType.INTERACTION);
|
log("failed interaction check",player,CheckType.INTERACTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
|||||||
@@ -263,10 +263,8 @@ public class Backend
|
|||||||
|
|
||||||
public boolean checkInteraction(Player player, Block block)
|
public boolean checkInteraction(Player player, Block block)
|
||||||
{
|
{
|
||||||
// The most complicated check in the world...approaching nirvana.
|
|
||||||
int strikes = 0;
|
int strikes = 0;
|
||||||
|
|
||||||
// now let's swing the bat.
|
|
||||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
|
|
||||||
//player coords
|
//player coords
|
||||||
@@ -292,11 +290,9 @@ public class Backend
|
|||||||
|
|
||||||
if(direction != null)
|
if(direction != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(int g = 0; g < 2; g++)
|
for(int g = 0; g < 2; g++)
|
||||||
{
|
{
|
||||||
py = py+g;
|
py = py+g;
|
||||||
|
|
||||||
if(direction.equals("N") || direction.equals("NE"))
|
if(direction.equals("N") || direction.equals("NE"))
|
||||||
{
|
{
|
||||||
if(x > 0)
|
if(x > 0)
|
||||||
@@ -309,20 +305,16 @@ public class Backend
|
|||||||
{
|
{
|
||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Don't detect farther than we should be allowed to.
|
// Don't detect farther than we should be allowed to.
|
||||||
if(coords.getX() < block.getLocation().getX())
|
if(coords.getX() < block.getLocation().getX())
|
||||||
{
|
{
|
||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
//player.sendBlockChange(coords, 66, (byte) 0);
|
//player.sendBlockChange(coords, 66, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.getLocation().distance(coords) > 5D)
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
{
|
{
|
||||||
//player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
//player.sendMessage("Block detected at -X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
@@ -331,7 +323,6 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(z > 0)
|
if(z > 0)
|
||||||
{
|
{
|
||||||
boolean ignoreothers = false;
|
boolean ignoreothers = false;
|
||||||
@@ -342,18 +333,16 @@ public class Backend
|
|||||||
{
|
{
|
||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
if(block.getLocation().distance(coords) > 5D) {
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't detect farther than we should be allowed to.
|
// Don't detect farther than we should be allowed to.
|
||||||
if(coords.getZ() < block.getLocation().getZ())
|
if(coords.getZ() < block.getLocation().getZ())
|
||||||
{
|
{
|
||||||
ignoreothers = true;
|
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)
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
{
|
{
|
||||||
//player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
//player.sendMessage("Block detected at -Z: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
@@ -362,9 +351,7 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(direction.equals("E") || direction.equals("SE"))
|
if(direction.equals("E") || direction.equals("SE"))
|
||||||
{
|
{
|
||||||
if(x > 0)
|
if(x > 0)
|
||||||
@@ -377,18 +364,16 @@ public class Backend
|
|||||||
{
|
{
|
||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
if(block.getLocation().distance(coords) > 5D) {
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't detect farther than we should be allowed to.
|
// Don't detect farther than we should be allowed to.
|
||||||
if(coords.getX() < block.getLocation().getX())
|
if(coords.getX() < block.getLocation().getX())
|
||||||
{
|
{
|
||||||
ignoreothers = true;
|
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)
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId() && !ignoreothers)
|
||||||
{
|
{
|
||||||
//player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
//player.sendMessage("Block detected at +X: " + a + " Block: " + coords.getBlock().getType().toString());
|
||||||
@@ -397,7 +382,6 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(z > 0)
|
if(z > 0)
|
||||||
{
|
{
|
||||||
boolean ignoreothers = false;
|
boolean ignoreothers = false;
|
||||||
@@ -409,7 +393,8 @@ public class Backend
|
|||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.getLocation().distance(coords) > 5D) {
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,7 +414,6 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(direction.equals("S") || direction.equals("SW") || direction.equals("W"))
|
if(direction.equals("S") || direction.equals("SW") || direction.equals("W"))
|
||||||
{
|
{
|
||||||
if(x > 0)
|
if(x > 0)
|
||||||
@@ -445,7 +429,6 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(z > 0)
|
if(z > 0)
|
||||||
{
|
{
|
||||||
for(int a = 0; a < z + 1; a++)
|
for(int a = 0; a < z + 1; a++)
|
||||||
@@ -460,7 +443,6 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(direction.equals("NW"))
|
if(direction.equals("NW"))
|
||||||
{
|
{
|
||||||
if(x > 0)
|
if(x > 0)
|
||||||
@@ -474,7 +456,8 @@ public class Backend
|
|||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.getLocation().distance(coords) > 5D) {
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +469,6 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(z > 0)
|
if(z > 0)
|
||||||
{
|
{
|
||||||
boolean ignoreothers = false;
|
boolean ignoreothers = false;
|
||||||
@@ -498,7 +480,8 @@ public class Backend
|
|||||||
ignoreothers = true;
|
ignoreothers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(block.getLocation().distance(coords) > 5D) {
|
if(block.getLocation().distance(coords) > 5D)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,10 +496,8 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//player.sendMessage("Strikes: " + strikes + " Dir: " + direction);
|
//player.sendMessage("Strikes: " + strikes + " Dir: " + direction);
|
||||||
//player.sendMessage("X: " + x + " Y: " + y + " Z:" + z);
|
//player.sendMessage("X: " + x + " Y: " + y + " Z:" + z);
|
||||||
|
|
||||||
return strikes > 0;
|
return strikes > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user