From 35a010c41e40de3012579ac4480f085e2cb8cbb7 Mon Sep 17 00:00:00 2001 From: MWHunter Date: Sun, 20 Dec 2020 15:48:04 -0600 Subject: [PATCH] Use worldborder API instead of an incorrect calculation --- .../themoep/randomteleport/hook/WorldborderHook.java | 11 +---------- .../randomteleport/hook/plugin/WorldBorderHook.java | 6 ++++++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/randomteleport-hook/src/main/java/de/themoep/randomteleport/hook/WorldborderHook.java b/randomteleport-hook/src/main/java/de/themoep/randomteleport/hook/WorldborderHook.java index 78fae5a..3868be6 100644 --- a/randomteleport-hook/src/main/java/de/themoep/randomteleport/hook/WorldborderHook.java +++ b/randomteleport-hook/src/main/java/de/themoep/randomteleport/hook/WorldborderHook.java @@ -42,14 +42,5 @@ public interface WorldborderHook extends PluginHook { * @param location The location to check * @return True if it is inside (or there is no border), false if not */ - default boolean isInsideBorder(Location location) { - Location center = getCenter(location.getWorld()); - if (center != null) { - double radius = getBorderRadius(location.getWorld()); - if (radius > 0) { - return center.distanceSquared(location) <= radius * radius; - } - } - return true; - } + boolean isInsideBorder(Location location); } diff --git a/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java b/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java index 8c1111c..7a6587f 100644 --- a/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java +++ b/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java @@ -44,6 +44,12 @@ public class WorldBorderHook implements WorldborderHook { return data == null ? -1 : Math.min(data.getRadiusX(), data.getRadiusZ()); } + @Override + public boolean isInsideBorder(Location location) { + BorderData data = plugin.getWorldBorder(location.getWorld().getName()); + return data.insideBorder(location); + } + @Override public Plugin getPlugin() { return plugin;