Fix possible NPEs when no ChunkyBorder border is set in a world (Fixes #56)

This commit is contained in:
Phoenix616 2023-04-09 13:45:53 +01:00
parent 34fc5c3439
commit 8bebacc7ba
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 3 additions and 3 deletions

View File

@ -25,19 +25,19 @@ public class ChunkyBorderHook implements WorldborderHook {
@Override
public Location getCenter(World world) {
BorderData borderData = chunkyBorder.getBorders().get(world.getName());
return new Location(world, borderData.getCenterX(),0D,borderData.getCenterZ());
return borderData != null ? new Location(world, borderData.getCenterX(),0D,borderData.getCenterZ()) : null;
}
@Override
public double getBorderRadius(World world) {
BorderData borderData = chunkyBorder.getBorders().get(world.getName());
return borderData.getRadiusX();
return borderData != null ? borderData.getRadiusX() : -1;
}
@Override
public boolean isInsideBorder(Location location) {
BorderData borderData = chunkyBorder.getBorders().get(location.getWorld().getName());
return borderData.getBorder().isBounding(location.getBlockX(),location.getBlockZ());
return borderData == null || borderData.getBorder().isBounding(location.getBlockX(),location.getBlockZ());
}
@Override