From 01515c08b95e9235219e7caa5a743d638fe45e42 Mon Sep 17 00:00:00 2001 From: D3v1s0m Date: Mon, 3 Jun 2024 13:40:08 +0530 Subject: [PATCH] fix teleport command --- .../java/lol/pyr/znpcsplus/commands/TeleportCommand.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/commands/TeleportCommand.java b/plugin/src/main/java/lol/pyr/znpcsplus/commands/TeleportCommand.java index 012ba85..b9705cd 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/commands/TeleportCommand.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/commands/TeleportCommand.java @@ -9,6 +9,7 @@ import lol.pyr.znpcsplus.npc.NpcRegistryImpl; import lol.pyr.znpcsplus.util.FoliaUtil; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import org.bukkit.Location; import org.bukkit.entity.Player; import java.util.Collections; @@ -26,7 +27,9 @@ public class TeleportCommand implements CommandHandler { context.setUsage(context.getLabel() + " teleport "); Player player = context.ensureSenderIsPlayer(); NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc(); - FoliaUtil.teleport(player, npc.getBukkitLocation()); + Location location = npc.getBukkitLocation(); + if (location == null) context.halt("Unable to teleport to NPC, the world is not loaded!"); + FoliaUtil.teleport(player, location); context.send(Component.text("Teleported to NPC!", NamedTextColor.GREEN)); }