Merge pull request #42 from MWHunter/master

Fix WorldBorder checking for non-circle borders
This commit is contained in:
Max Lee 2020-12-20 23:04:17 +01:00 committed by GitHub
commit 6b632d7023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;