mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 22:16:03 +00:00
[BLEEDING] New Chest Visuals Check. There is false positives.
This commit is contained in:
1 parent
ba33955442
commit
6fa61cb254
6 files changed
+227
-4
No files matched your search
@@ -32,6 +32,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@@ -62,6 +63,7 @@ public class PlayerListener extends EventListener
|
|||||||
backend.logProjectile(player,this);
|
backend.logProjectile(player,this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@@ -149,6 +151,23 @@ public class PlayerListener extends EventListener
|
|||||||
Distance distance = new Distance(player.getLocation(), event.getClickedBlock().getLocation());
|
Distance distance = new Distance(player.getLocation(), event.getClickedBlock().getLocation());
|
||||||
backend.checkLongReachBlock(player,distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
backend.checkLongReachBlock(player,distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Chest Cheat Check */
|
||||||
|
if(event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
|
{
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if(((block.getType()) == Material.CHEST) && checkManager.willCheck(player, CheckType.CHEST_HACK))
|
||||||
|
{
|
||||||
|
// save load and actually call the backend check here.
|
||||||
|
if(backend.checkChestCheat(player, block))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
log("tried to use freecam chest hack",player,CheckType.CHEST_HACK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class AnticheatManager
|
|||||||
{
|
{
|
||||||
if(getConfiguration().logConsole())
|
if(getConfiguration().logConsole())
|
||||||
{
|
{
|
||||||
LOGGER.info(ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
LOGGER.log(Level.WARNING, ChatColor.stripColor(message)); //This is temporary. Is something wrong with jline?
|
||||||
}
|
}
|
||||||
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
if(getConfiguration().getFileLogLevel() == LOG_LEVEL_HIGH)
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ public class AnticheatManager
|
|||||||
|
|
||||||
public void fileLog(String message)
|
public void fileLog(String message)
|
||||||
{
|
{
|
||||||
FILE_LOGGER.info(message);
|
FILE_LOGGER.log(Level.WARNING, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Anticheat getPlugin()
|
public Anticheat getPlugin()
|
||||||
|
|||||||
@@ -261,6 +261,141 @@ public class Backend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkChestCheat(Player player, Block block)
|
||||||
|
{
|
||||||
|
// The most complicated check in the world...approaching nirvana.
|
||||||
|
int strikes = 0;
|
||||||
|
|
||||||
|
// now let's swing the bat.
|
||||||
|
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||||
|
|
||||||
|
//player coords
|
||||||
|
double px = distance.fromX();
|
||||||
|
double py = distance.fromY();
|
||||||
|
double pz = distance.fromZ();
|
||||||
|
|
||||||
|
double x = Math.round(distance.getXDifference());
|
||||||
|
double y = Math.round(distance.getYDifference());
|
||||||
|
double z = Math.round(distance.getZDifference());
|
||||||
|
|
||||||
|
String direction = Utilities.getCardinalDirection(player);
|
||||||
|
|
||||||
|
if(direction != null)
|
||||||
|
{
|
||||||
|
if(direction.equals("N") || direction.equals("NE"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px-a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz-a);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction.equals("E") || direction.equals("SE"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz-a);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction.equals("S") || direction.equals("SW") || direction.equals("W"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px+a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(direction.equals("NW"))
|
||||||
|
{
|
||||||
|
if(x > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < x + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px-a,py,pz);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(z > 0)
|
||||||
|
{
|
||||||
|
for(int a = 0; a < z + 1; a++)
|
||||||
|
{
|
||||||
|
Location coords = new Location(player.getWorld(), px,py,pz+a);
|
||||||
|
if(coords.getBlock().getTypeId() != 0 && coords.getBlock().getTypeId() != block.getTypeId())
|
||||||
|
{
|
||||||
|
strikes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return strikes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean checkWaterWalk(Player player, double x, double z)
|
public boolean checkWaterWalk(Player player, double x, double z)
|
||||||
{
|
{
|
||||||
Block block = player.getLocation().getBlock();
|
Block block = player.getLocation().getBlock();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public enum CheckType
|
|||||||
WATER_WALK("anticheat.waterwalk"),
|
WATER_WALK("anticheat.waterwalk"),
|
||||||
NO_SWING("anticheat.noswing"),
|
NO_SWING("anticheat.noswing"),
|
||||||
FAST_BREAK("anticheat.fastbreak"),
|
FAST_BREAK("anticheat.fastbreak"),
|
||||||
|
CHEST_HACK("anticheat.chest"),
|
||||||
FAST_PLACE("anticheat.fastplace"),
|
FAST_PLACE("anticheat.fastplace"),
|
||||||
SPAM("anticheat.spam"),
|
SPAM("anticheat.spam"),
|
||||||
SPRINT("anticheat.sprint"),
|
SPRINT("anticheat.sprint"),
|
||||||
|
|||||||
@@ -30,11 +30,23 @@ public class Distance
|
|||||||
l2 = from;
|
l2 = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fromY() {
|
public double fromX()
|
||||||
|
{
|
||||||
|
return l2.getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double fromY()
|
||||||
|
{
|
||||||
return l2.getY();
|
return l2.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double toY() {
|
public double fromZ()
|
||||||
|
{
|
||||||
|
return l2.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public double toY()
|
||||||
|
{
|
||||||
return l1.getY();
|
return l1.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,4 +64,5 @@ public class Distance
|
|||||||
{
|
{
|
||||||
return Math.abs(l1.getY()-l2.getY());
|
return Math.abs(l1.getY()-l2.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.h31ix.anticheat.Anticheat;
|
import net.h31ix.anticheat.Anticheat;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@@ -92,6 +93,7 @@ public final class Utilities
|
|||||||
Material lily = Material.WATER_LILY;
|
Material lily = Material.WATER_LILY;
|
||||||
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
return block.getType() == lily || block.getRelative(BlockFace.NORTH).getType() == lily || block.getRelative(BlockFace.SOUTH).getType() == lily || block.getRelative(BlockFace.EAST).getType() == lily || block.getRelative(BlockFace.WEST).getType() == lily;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUsingMcMMOAbility(Player player)
|
public static boolean isUsingMcMMOAbility(Player player)
|
||||||
{
|
{
|
||||||
boolean b = false;
|
boolean b = false;
|
||||||
@@ -104,6 +106,58 @@ public final class Utilities
|
|||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Credits to sk89q for the calculation of cardinal direction.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the cardinal compass direction of a player.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getCardinalDirection(Player player) {
|
||||||
|
double rot = (player.getLocation().getYaw() - 90) % 360;
|
||||||
|
if (rot < 0) {
|
||||||
|
rot += 360.0;
|
||||||
|
}
|
||||||
|
return getDirection(rot);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a rotation to a cardinal direction name.
|
||||||
|
*
|
||||||
|
* @param rot
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static String getDirection(double rot) {
|
||||||
|
if (0 <= rot && rot < 22.5) {
|
||||||
|
return "N";
|
||||||
|
} else if (22.5 <= rot && rot < 67.5) {
|
||||||
|
return "NE";
|
||||||
|
} else if (67.5 <= rot && rot < 112.5) {
|
||||||
|
return "E";
|
||||||
|
} else if (112.5 <= rot && rot < 157.5) {
|
||||||
|
return "SE";
|
||||||
|
} else if (157.5 <= rot && rot < 202.5) {
|
||||||
|
return "S";
|
||||||
|
} else if (202.5 <= rot && rot < 247.5) {
|
||||||
|
return "SW";
|
||||||
|
} else if (247.5 <= rot && rot < 292.5) {
|
||||||
|
return "W";
|
||||||
|
} else if (292.5 <= rot && rot < 337.5) {
|
||||||
|
return "NW";
|
||||||
|
} else if (337.5 <= rot && rot < 360.0) {
|
||||||
|
return "N";
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSubmersed(Player player)
|
public static boolean isSubmersed(Player player)
|
||||||
{
|
{
|
||||||
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
return player.getLocation().getBlock().isLiquid() && player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid();
|
||||||
@@ -142,6 +196,7 @@ public final class Utilities
|
|||||||
INSTANT_BREAK.add(Material.TORCH);
|
INSTANT_BREAK.add(Material.TORCH);
|
||||||
INSTANT_BREAK.add(Material.CROPS);
|
INSTANT_BREAK.add(Material.CROPS);
|
||||||
INSTANT_BREAK.add(Material.SNOW);
|
INSTANT_BREAK.add(Material.SNOW);
|
||||||
|
INSTANT_BREAK.add(Material.TNT);
|
||||||
FOOD.add(Material.COOKED_BEEF);
|
FOOD.add(Material.COOKED_BEEF);
|
||||||
FOOD.add(Material.COOKED_CHICKEN);
|
FOOD.add(Material.COOKED_CHICKEN);
|
||||||
FOOD.add(Material.COOKED_FISH);
|
FOOD.add(Material.COOKED_FISH);
|
||||||
|
|||||||
Reference in new issue
Block a user