From 8bebacc7badc07ce057eda476c506099b064a2cf Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Sun, 9 Apr 2023 13:45:53 +0100 Subject: [PATCH] Fix possible NPEs when no ChunkyBorder border is set in a world (Fixes #56) --- .../randomteleport/hook/plugin/ChunkyBorderHook.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/randomteleport-plugin-hooks/chunkyborder/src/main/java/de/themoep/randomteleport/hook/plugin/ChunkyBorderHook.java b/randomteleport-plugin-hooks/chunkyborder/src/main/java/de/themoep/randomteleport/hook/plugin/ChunkyBorderHook.java index 7f08933..5059a3a 100644 --- a/randomteleport-plugin-hooks/chunkyborder/src/main/java/de/themoep/randomteleport/hook/plugin/ChunkyBorderHook.java +++ b/randomteleport-plugin-hooks/chunkyborder/src/main/java/de/themoep/randomteleport/hook/plugin/ChunkyBorderHook.java @@ -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