package eu.mhsl.minecraft.pixelblocks.commands;

import eu.mhsl.minecraft.pixelblocks.pixelblock.PixelBlock;
import eu.mhsl.minecraft.pixelblocks.pixelblock.PixelBlockWorld;
import eu.mhsl.minecraft.pixelblocks.utils.Direction;
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.UUID;

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

    @Override
    public void execute(@NotNull Player player, @NotNull String[] args) {
        if(PixelBlockWorld.isPixelWorld(player.getWorld())) {
            player.sendMessage(Component.translatable("pixelblocks.error.create-inside").color(NamedTextColor.RED));
            return;
        }

        PixelBlock.createPixelBlock(
            UUID.randomUUID(),
            player.getUniqueId(),
            player.getLocation().toBlockLocation(),
            Direction.south
        );
    }
}
