package de.teleportsuite.commands;
import de.teleportsuite.TeleportSuite;
import de.teleportsuite.models.TeleportLocation;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
public class TpWorldCommand implements CommandExecutor {
    private final TeleportSuite plugin;
    public TpWorldCommand(TeleportSuite p) { this.plugin = p; }
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (!(sender instanceof Player)) { sender.sendMessage("§cNur für Spieler!"); return true; }
        Player p = (Player) sender;
        if (!p.hasPermission("teleportsuite.tpworld")) { p.sendMessage(plugin.getConfigManager().getMessage("no-permission")); return true; }
        if (args.length < 1) { p.sendMessage("§cVerwendung: /tpworld <welt>"); return true; }
        World world = Bukkit.getWorld(args[0]);
        if (world == null) { p.sendMessage("§cWelt §6" + args[0] + " §cnicht gefunden."); return true; }
        var spawn = world.getSpawnLocation();
        plugin.getTeleportManager().teleport(p, new TeleportLocation(world.getName(), spawn.getX(), spawn.getY(), spawn.getZ(), 0, 0, plugin.getConfigManager().getServerName()));
        return true;
    }
}
