Plugin should now work on 1.7.10, started on Glide v2

This commit is contained in:
Rammelkast committed 2016-11-18 16:42:21 +01:00
1 parent c229252f7a
commit db821e4809
2 files changed
+46 -37

No files matched your search

@@ -14,6 +14,7 @@ import net.gravitydevelopment.anticheat.AntiCheat;
import net.gravitydevelopment.anticheat.check.CheckResult;
import net.gravitydevelopment.anticheat.util.Distance;
import net.gravitydevelopment.anticheat.util.Utilities;
import net.gravitydevelopment.anticheat.util.VersionUtil;
/**
* This is broken as f*ck
@@ -25,41 +26,49 @@ public class GlideCheck {
public static Map<UUID, Double> lastYDelta = new HashMap<UUID, Double>();
public static Map<UUID, Integer> glideBuffer = new HashMap<UUID, Integer>();
/*
* SOME OLD CODE
*
* UUID uuid = player.getUniqueId();
if(!lastYDelta.containsKey(uuid))
lastYDelta.put(uuid, 0.0);
if(!YAxisCheck.lastYcoord.containsKey(uuid))
YAxisCheck.lastYcoord.put(uuid, player.getLocation().getY());
double currentY = player.getLocation().getY();
double math = currentY - YAxisCheck.lastYcoord.get(uuid);
if((math < 0 && math > AntiCheat.getManager().getBackend().getMagic().GLIDE_MAX()) && !AntiCheat.getManager().getBackend().isMovingExempt(player))
{
if(math <= lastYDelta.get(uuid) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
&& Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.cantStandAtSingle(player.getLocation().getBlock()) && !!Utilities.cantStandAtSingle(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
{
if(!glideBuffer.containsKey(uuid))
glideBuffer.put(uuid, 0);
int currentBuffer = glideBuffer.get(uuid);
glideBuffer.put(uuid, currentBuffer + 1);
if(currentBuffer >= 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())
{
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
}
lastYDelta.put(uuid, math);
return new CheckResult(CheckResult.Result.FAILED, uuid + " attempted to fall too slowly!");
}
}
}else {
glideBuffer.remove(uuid);
}
lastYDelta.put(uuid, math);*/
public static CheckResult runCheck(Player player, Distance distance) {
/*UUID uuid = player.getUniqueId();
if(!lastYDelta.containsKey(uuid))
lastYDelta.put(uuid, 0.0);
if(!YAxisCheck.lastYcoord.containsKey(uuid))
YAxisCheck.lastYcoord.put(uuid, player.getLocation().getY());
double currentY = player.getLocation().getY();
double math = currentY - YAxisCheck.lastYcoord.get(uuid);
if((math < 0 && math > AntiCheat.getManager().getBackend().getMagic().GLIDE_MAX()) && !AntiCheat.getManager().getBackend().isMovingExempt(player))
{
if(math <= lastYDelta.get(uuid) && !(player.getEyeLocation().getBlock().getType() == Material.LADDER)
&& !Utilities.isInWater(player) && !Utilities.isInWeb(player)
&& Utilities.cantStandAt(player.getLocation().getBlock()) && !Utilities.cantStandAtSingle(player.getLocation().getBlock()) && !!Utilities.cantStandAtSingle(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
{
if(!glideBuffer.containsKey(uuid))
glideBuffer.put(uuid, 0);
int currentBuffer = glideBuffer.get(uuid);
glideBuffer.put(uuid, currentBuffer + 1);
if(currentBuffer >= 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())
{
player.sendMessage(ChatColor.RED + "[AntiCheat] Glide/Fly hacking detected.");
}
lastYDelta.put(uuid, math);
return new CheckResult(CheckResult.Result.FAILED, uuid + " attempted to fall too slowly!");
}
}
}else {
glideBuffer.remove(uuid);
}
lastYDelta.put(uuid, math);*/
UUID uuid = player.getUniqueId();
if (AntiCheat.getManager().getBackend().isMovingExempt(player) || VersionUtil.isFlying(player)) {
return PASS;
}
return PASS;
}
@@ -10,10 +10,10 @@ public class VersionUtil {
}
public static boolean isFlying(Player p) {
if (getVersion().equals("v1_8_R3")) {
return p.isFlying();
}else {
if (getVersion().equals("v1_9_R1") || getVersion().equals("v1_10_R1") || getVersion().equals("v1_11_R1")) {
return p.isFlying() || p.isGliding();
} else {
return p.isFlying();
}
}