From 0d439ce6a06a4c2237af42f431d1dac394eacf54 Mon Sep 17 00:00:00 2001 From: Krakenied Date: Sat, 20 Aug 2022 18:31:35 +0200 Subject: Fix IAE in DistancefromTaskType --- .../bukkit/tasktype/type/DistancefromTaskType.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bukkit/src/main') diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/DistancefromTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/DistancefromTaskType.java index 11529c84..b786906a 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/DistancefromTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/DistancefromTaskType.java @@ -69,25 +69,25 @@ public final class DistancefromTaskType extends BukkitTaskType { super.debug("Player moved", quest.getId(), task.getId(), player.getUniqueId()); + String worldString = (String) task.getConfigValue("world"); + World world = Bukkit.getWorld(worldString); + if (!player.getWorld().equals(world)) { + super.debug("World " + worldString + " does not exist or isn't the player world, continuing...", quest.getId(), task.getId(), player.getUniqueId()); + continue; + } + int x = (int) task.getConfigValue("x"); int y = (int) task.getConfigValue("y"); int z = (int) task.getConfigValue("z"); - String worldString = (String) task.getConfigValue("world"); int distance = (int) task.getConfigValue("distance"); int distanceSquared = distance * distance; - World world = Bukkit.getWorld(worldString); - if (world == null) { - super.debug("World " + worldString + " does not exist, continuing...", quest.getId(), task.getId(), player.getUniqueId()); - continue; - } - Location location = new Location(world, x, y, z); double playerDistanceSquared = player.getLocation().distanceSquared(location); super.debug("Player is " + playerDistanceSquared + "m squared away", quest.getId(), task.getId(), player.getUniqueId()); - if (player.getWorld().equals(world) && playerDistanceSquared > distanceSquared) { + if (playerDistanceSquared > distanceSquared) { super.debug("Marking task as complete", quest.getId(), task.getId(), player.getUniqueId()); taskProgress.setCompleted(true); } -- cgit v1.2.3-70-g09d2