Skip to content

Commit

Permalink
Fix cannot measure distance error in PositionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Archy-X committed Jul 28, 2024
1 parent 3d56d2d commit cc6af2c
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;

public record PositionHandler(double maxDistance, int minCount) {

public boolean failsCheck(CheckData data, Player player) {
Expand All @@ -15,6 +17,11 @@ public boolean failsCheck(CheckData data, Player player) {

if (prevLoc == null) return false;

if (!Objects.equals(currentLoc.getWorld(), currentLoc.getWorld())) {
data.resetCount();
return false;
}

if (currentLoc.distanceSquared(prevLoc) <= maxDistance * maxDistance) {
data.incrementCount();
} else {
Expand Down

0 comments on commit cc6af2c

Please sign in to comment.