fix teleport command

This commit is contained in:
D3v1s0m 2024-06-03 13:40:08 +05:30
parent d75f260935
commit 01515c08b9
No known key found for this signature in database
GPG Key ID: FA1F770C7B1D40C1

@ -9,6 +9,7 @@ import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
import lol.pyr.znpcsplus.util.FoliaUtil; import lol.pyr.znpcsplus.util.FoliaUtil;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collections; import java.util.Collections;
@ -26,7 +27,9 @@ public class TeleportCommand implements CommandHandler {
context.setUsage(context.getLabel() + " teleport <id>"); context.setUsage(context.getLabel() + " teleport <id>");
Player player = context.ensureSenderIsPlayer(); Player player = context.ensureSenderIsPlayer();
NpcImpl npc = context.parse(NpcEntryImpl.class).getNpc(); 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)); context.send(Component.text("Teleported to NPC!", NamedTextColor.GREEN));
} }