mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Hopefully fixed a few issues and improved things within the water walk check
This commit is contained in:
1 parent
70c486376b
commit
a7fe5782e0
4 files changed
+100
-41
No files matched your search
@@ -270,10 +270,10 @@ public class Anticheat extends JavaPlugin
|
||||
{
|
||||
logger.log(Level.INFO, "[AC] Checking for updates...");
|
||||
}
|
||||
URL url = null;
|
||||
URLConnection urlConn = null;
|
||||
URL url;
|
||||
URLConnection urlConn;
|
||||
InputStreamReader inStream = null;
|
||||
BufferedReader buff = null;
|
||||
BufferedReader buff;
|
||||
String v = "";
|
||||
try
|
||||
{
|
||||
|
||||
@@ -27,20 +27,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class PlayerListener extends EventListener
|
||||
@@ -209,6 +197,7 @@ public class PlayerListener extends EventListener
|
||||
double x = distance.getXDifference();
|
||||
double y = distance.getYDifference();
|
||||
double z = distance.getZDifference();
|
||||
backend.checkAscension(player,from.getY(),to.getY());
|
||||
if(checkManager.willCheck(player, CheckType.FLY) && checkManager.willCheck(player, CheckType.ZOMBE_FLY) && backend.checkFlight(player, distance))
|
||||
{
|
||||
from.setX(from.getX()-1);
|
||||
@@ -272,7 +261,7 @@ public class PlayerListener extends EventListener
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void checkDirSpeed(PlayerMoveEvent event)
|
||||
public void checkSpeed(PlayerMoveEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Location from = event.getFrom();
|
||||
|
||||
@@ -67,6 +67,9 @@ public class Backend
|
||||
private static final int Y_MAXVIOTIME = 5000;
|
||||
private static final int NOFALL_LIMIT = 5;
|
||||
|
||||
private static final int WATER_ASCENSION_VIOLATION_MAX = 13;
|
||||
private static final int WATER_SPEED_VIOLATION_MAX = 4;
|
||||
|
||||
private static final int SPRINT_FOOD_MIN = 6;
|
||||
private static final int EAT_MIN = 20;
|
||||
private static final int HEAL_MIN = 35;
|
||||
@@ -109,6 +112,7 @@ public class Backend
|
||||
private List<String> isInWater = new ArrayList<String>();
|
||||
private List<String> isInWaterCache = new ArrayList<String>();
|
||||
private List<String> instantBreakExempt = new ArrayList<String>();
|
||||
private List<String> isAscending = new ArrayList<String>();
|
||||
private Map<String,String> oldMessage = new HashMap<String,String>();
|
||||
private Map<String,String> lastMessage = new HashMap<String,String>();
|
||||
private Map<String,Integer> flightViolation = new HashMap<String,Integer>();
|
||||
@@ -127,6 +131,8 @@ public class Backend
|
||||
private Map<String,Long> lastBlockPlaced = new HashMap<String,Long>();
|
||||
private Map<String,Long> lastBlockPlaceTime = new HashMap<String,Long>();
|
||||
private Map<String,Integer> blockPunches = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterAscensionViolation = new HashMap<String,Integer>();
|
||||
private Map<String,Integer> waterSpeedViolation = new HashMap<String,Integer>();
|
||||
|
||||
public Backend(AnticheatManager instance)
|
||||
{
|
||||
@@ -251,47 +257,94 @@ public class Backend
|
||||
public boolean checkWaterWalk(Player player, double x, double z)
|
||||
{
|
||||
Block block = player.getLocation().getBlock();
|
||||
if(block.isLiquid() && player.getVehicle() == null)
|
||||
if(player.getVehicle() == null && !player.isFlying())
|
||||
{
|
||||
if(isInWater.contains(player.getName()))
|
||||
if(block.isLiquid() && block.getRelative(BlockFace.DOWN).isLiquid())
|
||||
{
|
||||
if(isInWaterCache.contains(player.getName()))
|
||||
{
|
||||
if(x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER && !Utilities.sprintFly(player) && player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if(isInWater.contains(player.getName()))
|
||||
{
|
||||
if(isInWaterCache.contains(player.getName()))
|
||||
{
|
||||
if(player.getNearbyEntities(1, 1, 1).isEmpty())
|
||||
{
|
||||
boolean b = false;
|
||||
if(!Utilities.sprintFly(player) && x > XZ_SPEED_MAX_WATER || z > XZ_SPEED_MAX_WATER)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
else if(x > XZ_SPEED_MAX_WATER_SPRINT || z > XZ_SPEED_MAX_WATER_SPRINT)
|
||||
{
|
||||
b = true;
|
||||
}
|
||||
if(b)
|
||||
{
|
||||
if(waterSpeedViolation.containsKey(player.getName()))
|
||||
{
|
||||
int v = waterSpeedViolation.get(player.getName());
|
||||
if(v >= WATER_SPEED_VIOLATION_MAX)
|
||||
{
|
||||
waterSpeedViolation.put(player.getName(), 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
waterSpeedViolation.put(player.getName(), v+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waterSpeedViolation.put(player.getName(), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isInWaterCache.add(player.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isInWaterCache.add(player.getName());
|
||||
isInWater.add(player.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (block.getRelative(BlockFace.DOWN).isLiquid() && isAscending(player) && Utilities.cantStandAt(block) && Utilities.cantStandAt(block.getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
if(waterAscensionViolation.containsKey(player.getName()))
|
||||
{
|
||||
int v = waterAscensionViolation.get(player.getName());
|
||||
if(v >= WATER_ASCENSION_VIOLATION_MAX)
|
||||
{
|
||||
waterAscensionViolation.put(player.getName(), 0);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
waterAscensionViolation.put(player.getName(), v+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
waterAscensionViolation.put(player.getName(), 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isInWater.add(player.getName());
|
||||
return false;
|
||||
isInWater.remove(player.getName());
|
||||
isInWaterCache.remove(player.getName());
|
||||
}
|
||||
|
||||
}
|
||||
isInWater.remove(player.getName());
|
||||
isInWaterCache.remove(player.getName());
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkYAxis(Player player, Distance distance)
|
||||
{
|
||||
//Arrow to the knee check
|
||||
if(distance.getYDifference() > 400) {
|
||||
//teleport. so just cancel.
|
||||
if(distance.getYDifference() > 400)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isMovingExempt(player))
|
||||
{
|
||||
double y1 = player.getLocation().getY();
|
||||
@@ -405,6 +458,18 @@ public class Backend
|
||||
return false;
|
||||
}
|
||||
|
||||
public void checkAscension(Player player, double y1, double y2)
|
||||
{
|
||||
if(y1 < y2)
|
||||
{
|
||||
isAscending.add(player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
isAscending.remove(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkSwing(Player player, Block block)
|
||||
{
|
||||
return !player.getInventory().getItemInHand().containsEnchantment(Enchantment.DIG_SPEED) && !Utilities.isInstantBreak(block.getType()) && !justAnimated(player);
|
||||
@@ -712,6 +777,11 @@ public class Backend
|
||||
return movingExempt.contains(player.getName()) || player.isFlying();
|
||||
}
|
||||
|
||||
public boolean isAscending(Player player)
|
||||
{
|
||||
return isAscending.contains(player.getName());
|
||||
}
|
||||
|
||||
public boolean isSpeedExempt(Player player) {
|
||||
return movingExempt.contains(player.getName());
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ public final class Utilities
|
||||
{
|
||||
return !canStand(block) && cantStandClose(block) && cantStandFar(block);
|
||||
}
|
||||
private static boolean cantStandClose(Block block)
|
||||
public static boolean cantStandClose(Block block)
|
||||
{
|
||||
return !canStand(block.getRelative(BlockFace.NORTH)) && !canStand(block.getRelative(BlockFace.EAST)) && !canStand(block.getRelative(BlockFace.SOUTH)) && !canStand(block.getRelative(BlockFace.WEST));
|
||||
}
|
||||
private static boolean cantStandFar(Block block)
|
||||
public static boolean cantStandFar(Block block)
|
||||
{
|
||||
return !canStand(block.getRelative(BlockFace.NORTH_WEST)) && !canStand(block.getRelative(BlockFace.NORTH_EAST)) && !canStand(block.getRelative(BlockFace.SOUTH_WEST)) && !canStand(block.getRelative(BlockFace.SOUTH_EAST));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user