Use worldborder API instead of an incorrect calculation

This commit is contained in:
MWHunter 2020-12-20 15:48:04 -06:00
parent 53fece8dac
commit 35a010c41e
2 changed files with 7 additions and 10 deletions

View File

@ -42,14 +42,5 @@ public interface WorldborderHook extends PluginHook {
* @param location The location to check * @param location The location to check
* @return True if it is inside (or there is no border), false if not * @return True if it is inside (or there is no border), false if not
*/ */
default boolean isInsideBorder(Location location) { 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;
}
} }

View File

@ -44,6 +44,12 @@ public class WorldBorderHook implements WorldborderHook {
return data == null ? -1 : Math.min(data.getRadiusX(), data.getRadiusZ()); 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 @Override
public Plugin getPlugin() { public Plugin getPlugin() {
return plugin; return plugin;