Made afk check not consider y for distance to ensure acrobatic grinders don't bypass the check
This commit is contained in:
parent
647922cfc5
commit
baad49a608
|
|
@ -3,7 +3,7 @@ rootProject.name = "AFKDetector"
|
|||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://dev.alttd.com/snapshots") // Altitude - Galaxy
|
||||
maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy
|
||||
}
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
|
@ -58,7 +60,21 @@ public class AFKCheckTimer extends BukkitRunnable {
|
|||
}
|
||||
|
||||
private boolean playerMovedOutOfSphere(Player player, Location pastLocation) {
|
||||
return player.getLocation().distanceSquared(pastLocation) > Config.RADIUS * Config.RADIUS;
|
||||
return TwoDDistanceSquared(player.getLocation(), pastLocation) > Config.RADIUS * Config.RADIUS;
|
||||
// return player.getLocation().distanceSquared(pastLocation) > Config.RADIUS * Config.RADIUS;
|
||||
}
|
||||
|
||||
private double TwoDDistanceSquared(@NotNull Location o1, @NotNull Location o2) {
|
||||
if (o2.getWorld() != null && o1.getWorld() != null) {
|
||||
if (o2.getWorld() != o1.getWorld()) {
|
||||
String var10002 = o1.getWorld().getName();
|
||||
throw new IllegalArgumentException("Cannot measure distance between " + var10002 + " and " + o2.getWorld().getName());
|
||||
} else {
|
||||
return NumberConversions.square(o1.getX() - o2.getX()) + NumberConversions.square(o1.getZ() - o2.getZ());
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Cannot measure distance to a null world");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean playerHeadMoved(Location playerLocation, Location pastLocation) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user