package de.teleportsuite.commands;
import de.teleportsuite.TeleportSuite;
import de.teleportsuite.models.TeleportLocation;
import org.bukkit.Bukkit;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
public class TpAllCommand implements CommandExecutor {
    private final TeleportSuite plugin;
    public TpAllCommand(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.tpall")) { p.sendMessage(plugin.getConfigManager().getMessage("no-permission")); return true; }
        TeleportLocation dest = new TeleportLocation(p.getLocation(), plugin.getConfigManager().getServerName());
        for (Player online : Bukkit.getOnlinePlayers()) {
            if (!online.equals(p)) plugin.getTeleportManager().teleport(online, dest);
        }
        p.sendMessage("§aAlle Spieler wurden zu dir teleportiert.");
        return true;
    }
}
