mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-02 14:38:45 +00:00
Added/Fixed Glide check
This commit is contained in:
1 parent
831b82ff30
commit
9b87ce92eb
7 files changed
+42
-19
No files matched your search
@@ -57,8 +57,7 @@ public enum CheckType {
|
|||||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
AUTOTOOL(Permission.CHECK_AUTOTOOL);
|
||||||
GLIDE(Permission.CHECK_GLIDE);
|
|
||||||
|
|
||||||
private final Permission permission;
|
private final Permission permission;
|
||||||
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
private final Map<String, Integer> level = new HashMap<String, Integer>();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -25,26 +26,27 @@ public class GlideCheck {
|
|||||||
|
|
||||||
public static CheckResult runCheck(Player player, Distance distance) {
|
public static CheckResult runCheck(Player player, Distance distance) {
|
||||||
String name = player.getName();
|
String name = player.getName();
|
||||||
if(!glideBuffer.containsKey(name))
|
|
||||||
{
|
|
||||||
glideBuffer.put(name, 0);
|
|
||||||
}
|
|
||||||
if(!lastYDelta.containsKey(name))
|
if(!lastYDelta.containsKey(name))
|
||||||
{
|
|
||||||
lastYDelta.put(name, 0.0);
|
lastYDelta.put(name, 0.0);
|
||||||
}
|
if(!YAxisCheck.lastYcoord.containsKey(name))
|
||||||
|
YAxisCheck.lastYcoord.put(name, player.getLocation().getY());
|
||||||
double currentY = player.getLocation().getY();
|
double currentY = player.getLocation().getY();
|
||||||
double math = currentY - YAxisCheck.lastYcoord.get(name);
|
double math = currentY - YAxisCheck.lastYcoord.get(name);
|
||||||
if(math < 0 && !AntiCheat.getManager().getBackend().isMovingExempt(player))
|
if(math < 0 && !AntiCheat.getManager().getBackend().isMovingExempt(player))
|
||||||
{
|
{
|
||||||
if(math <= lastYDelta.get(name) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
|
if(math <= lastYDelta.get(name) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
|
||||||
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
|
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
|
||||||
&& Utilities.cantStandAt(player.getLocation().getBlock()))
|
&& Utilities.cantStandAtSingle(player.getLocation().getBlock()))
|
||||||
{
|
{
|
||||||
|
if(!glideBuffer.containsKey(name))
|
||||||
|
glideBuffer.put(name, 0);
|
||||||
int currentBuffer = glideBuffer.get(name);
|
int currentBuffer = glideBuffer.get(name);
|
||||||
glideBuffer.put(name, currentBuffer + 1);
|
glideBuffer.put(name, currentBuffer + 1);
|
||||||
if((currentBuffer + 1) >= AntiCheat.getManager().getBackend().getMagic().FLIGHT_LIMIT())
|
if((currentBuffer + 1) >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT())
|
||||||
{
|
{
|
||||||
|
double fallDist = distanceToFall(player.getLocation());
|
||||||
|
player.teleport(player.getLocation().add(0, -fallDist, 0));
|
||||||
|
player.setFallDistance((float) fallDist);
|
||||||
if(!AntiCheat.getManager().getBackend().silentMode())
|
if(!AntiCheat.getManager().getBackend().silentMode())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
|
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
|
||||||
@@ -55,7 +57,14 @@ public class GlideCheck {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastYDelta.put(name, math);
|
lastYDelta.put(name, math);
|
||||||
return PASS;
|
return PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double distanceToFall(Location location) {
|
||||||
|
double firstY = location.getY();
|
||||||
|
while (location.clone().add(0, -0.1, 0).getBlock().getType() == Material.AIR)
|
||||||
|
location.add(0, -0.1, 0);
|
||||||
|
return firstY - location.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -157,6 +157,10 @@ public interface Magic {
|
|||||||
* Number of times a player can be caught in-flight before action is taken; Type=INTEGER, Leniency=INCREASE.
|
* Number of times a player can be caught in-flight before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
public int FLIGHT_LIMIT();
|
public int FLIGHT_LIMIT();
|
||||||
|
/**
|
||||||
|
* Number of times a player can be caught in-glide before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||||
|
*/
|
||||||
|
public int GLIDE_LIMIT();
|
||||||
/**
|
/**
|
||||||
* How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE.
|
* How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ public class PlayerListener extends EventListener {
|
|||||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
||||||
@@ -328,7 +328,7 @@ public class PlayerListener extends EventListener {
|
|||||||
log(result.getMessage(), player, CheckType.SPRINT);
|
log(result.getMessage(), player, CheckType.SPRINT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !player.isFlying() && (Bukkit.getVersion().contains("1.9") && !player.isGliding()) /*TODO: ElytraFly check, this is a quick workaround */) {
|
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !player.isFlying()) /*TODO: ElytraFly fix */ {
|
||||||
CheckResult result = FlightCheck.runCheck(player, distance);
|
CheckResult result = FlightCheck.runCheck(player, distance);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
if (!silentMode()) {
|
||||||
@@ -337,13 +337,11 @@ public class PlayerListener extends EventListener {
|
|||||||
log(result.getMessage(), player, CheckType.FLY);
|
log(result.getMessage(), player, CheckType.FLY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.GLIDE) && !player.isFlying() && (Bukkit.getVersion().contains("1.9") && !player.isGliding()) /*TODO: ElytraFly check, this is a quick workaround */) {
|
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !player.isFlying())/*TODO: ElytraFly fix */ {
|
||||||
CheckResult result = GlideCheck.runCheck(player, distance);
|
CheckResult result = GlideCheck.runCheck(player, distance);
|
||||||
if (result.failed()) {
|
if (result.failed()) {
|
||||||
if (!silentMode()) {
|
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF
|
||||||
event.setTo(user.getGoodLocation(from.clone()));
|
log(result.getMessage(), player, CheckType.FLY);
|
||||||
}
|
|
||||||
log(result.getMessage(), player, CheckType.GLIDE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
|
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ public enum Permission {
|
|||||||
CHECK_VISUAL,
|
CHECK_VISUAL,
|
||||||
CHECK_FASTINVENTORY,
|
CHECK_FASTINVENTORY,
|
||||||
CHECK_AUTOTOOL,
|
CHECK_AUTOTOOL,
|
||||||
CHECK_GLIDE,
|
|
||||||
|
|
||||||
/* System Nodes */
|
/* System Nodes */
|
||||||
SYSTEM_LOG,
|
SYSTEM_LOG,
|
||||||
|
|||||||
@@ -61,6 +61,19 @@ public final class Utilities {
|
|||||||
AntiCheat.getManager().log(msg);
|
AntiCheat.getManager().log(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if only the block beneath them is standable (includes water + lava)
|
||||||
|
* @param block the block to check (under)
|
||||||
|
* @return true if they cannot stand there
|
||||||
|
*/
|
||||||
|
public static boolean cantStandAtSingle(Block block)
|
||||||
|
{
|
||||||
|
// TODO: Implement Better to reduce false positives (done? lets test...)
|
||||||
|
Block otherBlock = block.getLocation().add(0, -0.5, 0).getBlock();
|
||||||
|
boolean center = otherBlock.getType() == Material.AIR;
|
||||||
|
return center;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether a player cannot stand on or around the given block
|
* Determine whether a player cannot stand on or around the given block
|
||||||
|
|||||||
@@ -83,3 +83,4 @@ Y_MAXVIOLATIONS: 1
|
|||||||
Y_MAXVIOTIME: 5000
|
Y_MAXVIOTIME: 5000
|
||||||
Y_SPEED_MAX: 0.5
|
Y_SPEED_MAX: 0.5
|
||||||
Y_TIME: 1000
|
Y_TIME: 1000
|
||||||
|
GLIDE_LIMIT: 10
|
||||||
Reference in new issue
Block a user