package de.viper.survivalplus.commands;

import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;

public class ShowArmorStandsCommand implements CommandExecutor {

    private final JavaPlugin plugin;

    public ShowArmorStandsCommand(JavaPlugin plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!sender.hasPermission("survivalplus.showarmorstands")) {
            sender.sendMessage("§cDu hast keine Rechte für diesen Befehl.");
            return true;
        }

        int count = 0;
        for (World world : Bukkit.getWorlds()) {
            for (Entity entity : world.getEntities()) {
                if (entity instanceof ArmorStand) {
                    ArmorStand armorStand = (ArmorStand) entity;
                    if (!armorStand.isVisible()) {
                        armorStand.setVisible(true);
                        count++;
                    }
                }
            }
        }

        sender.sendMessage("§a" + count + " unsichtbare Armor Stands wurden sichtbar gemacht.");
        return true;
    }
}
