package de.viper.survivalplus.commands;

import de.viper.survivalplus.SurvivalPlus;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Item;

public class ClearItemsCommand implements CommandExecutor {

    private final SurvivalPlus plugin;

    public ClearItemsCommand(SurvivalPlus plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        int totalRemoved = 0;
        for (World world : Bukkit.getWorlds()) {
            for (Item item : world.getEntitiesByClass(Item.class)) {
                item.remove();
                totalRemoved++;
            }
        }
        sender.sendMessage(ChatColor.RED + "Alle Items wurden entfernt (" + totalRemoved + " Stück).");
        return true;
    }
}
