mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-21 18:15:58 +01:00
Use worldborder API instead of an incorrect calculation
This commit is contained in:
parent
53fece8dac
commit
35a010c41e
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user