aboutsummaryrefslogtreecommitdiffstats
path: root/bukkit/src/main/java/com
diff options
context:
space:
mode:
authorKrakenied <Krakenied1@gmail.com>2022-08-20 18:31:35 +0200
committerLeonardo Bishop <13875753+LMBishop@users.noreply.github.com>2022-08-21 18:56:52 +0100
commit0d439ce6a06a4c2237af42f431d1dac394eacf54 (patch)
treea40c5592859af8b50d3bbb64ee28686e57a9a84e /bukkit/src/main/java/com
parent84a4b07e46b206a58d60d7eb7ef2c831ca3c33cd (diff)
Fix IAE in DistancefromTaskType
Diffstat (limited to 'bukkit/src/main/java/com')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/DistancefromTaskType.java16
1 files changed, 8 insertions, 8 deletions
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);
}