package eu.mhsl.minecraft.pixelblocks.commands;

import eu.mhsl.minecraft.pixelblocks.Main;
import eu.mhsl.minecraft.pixelblocks.pixelblock.PixelBlock;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class DestroyAllSubCommand extends SubCommand {
    public DestroyAllSubCommand() {
        super("destroyall", "pixelblocks.command.destroyall", "pixelblocks.command.destroyall.description");
    }

    @Override
    public void execute(@NotNull Player player, @NotNull String[] args) {
        List<PixelBlock> blocksToDestroy = List.copyOf(Main.pixelBlocks);
        blocksToDestroy.forEach(pixelBlock -> pixelBlock.destroy(player, true));
        player.sendMessage(Component.translatable("pixelblocks.command.destroyall.success", Component.text(blocksToDestroy.size())).color(NamedTextColor.GREEN));
    }
}
