package de.teleportsuite.commands;
import de.teleportsuite.TeleportSuite;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
public class SetWarpCommand implements CommandExecutor {
    private final TeleportSuite plugin;
    public SetWarpCommand(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;
        boolean isAdmin = p.hasPermission("teleportsuite.setwarp");
        boolean playerWarps = plugin.getConfigManager().allowPlayerWarps() && p.hasPermission("teleportsuite.setwarp.player");
        if (!isAdmin && !playerWarps) { p.sendMessage(plugin.getConfigManager().getMessage("no-permission")); return true; }
        if (args.length < 1) { p.sendMessage("§cVerwendung: /setwarp <name> [permission]"); return true; }
        String perm = args.length > 1 ? args[1] : null;
        plugin.getWarpManager().setWarp(p, args[0], perm);
        return true;
    }
}
