/*
 * Original project: RedEnvelope by KaguyaStudio-MC
 * Original project link: https://github.com/KaguyaStudio-MC/RedEnvelope
 * Modified by: LeisureTimeDock
 * This file is part of RedEnvelope
 * Licensed under Camellia License Version 1.0
 */

package top.leisuretimedock.redenvelope.core.command;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;


public class RECommand {

    public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
        LiteralArgumentBuilder<CommandSourceStack> head =
                Commands.literal("hongbao")
                        .then(
                                Commands.literal("luck")
                                .then(
                                        Commands.argument("count", IntegerArgumentType.integer(1, 64))
                                                .then(
                                                        Commands.argument("itemcount", IntegerArgumentType.integer(1, 64))
                                                        .executes(CommandExecutes::sendLuckWithItemCount)
                                                )
                                                .executes(CommandExecutes::sendLuckWithoutItemCount)
                                )
                        )
                        .then(
                                Commands.literal("common")
                                .then(
                                        Commands.argument("count", IntegerArgumentType.integer(1, 64))
                                        .then(
                                                Commands.argument("single", IntegerArgumentType.integer(1, 64))
                                                .executes(CommandExecutes::sendCommon)
                                        )
                                )
                        )
                        .then(
                                Commands.literal("spell")
                                .then(
                                        Commands.argument("count", IntegerArgumentType.integer(1, 64))
                                        .then(
                                                Commands.argument("itemcount", IntegerArgumentType.integer(1, 64))
                                                .then(
                                                        Commands.argument("words", StringArgumentType.string())
                                                        .executes(CommandExecutes::sendSpellWithItemCount)
                                                )
                                        )
                                        .then(
                                                Commands.argument("words", StringArgumentType.string())
                                                .executes(CommandExecutes::sendSpellWithoutItemCount)
                                        )
                                )
                        )
                        .then(
                                Commands.literal("open")
                                .then(
                                        Commands.argument("uuid", StringArgumentType.string())
                                        .executes(CommandExecutes::open)
                                )
                        )
                        .then(
                                Commands.literal("withdraw")
                                .then(
                                        Commands.argument("uuid", StringArgumentType.string())
                                        .executes(CommandExecutes::withdraw)
                                )
                        )
                        .then(
                                Commands.literal("query")
                                .then(
                                        Commands.argument("uuid", StringArgumentType.string())
                                        .executes(CommandExecutes::queryWithUUID)
                                )
                                .then(
                                        Commands.literal("all")
                                        .executes(CommandExecutes::query)
                                )
                                .then(
                                        Commands.literal("remain")
                                                .executes(CommandExecutes::queryRemain)
                                ).then(
                                        Commands.literal("cooldown")
                                                .then(
                                                        Commands.literal("luck")
                                                                .executes(CommandExecutes::queryCooldownLuck)
                                                )
                                                .then(
                                                        Commands.literal("common")
                                                                .executes(CommandExecutes::queryCooldownCommon)
                                                )
                                                .then(
                                                        Commands.literal("spell")
                                                                .executes(CommandExecutes::queryCooldownSpell)
                                                )
                                                .executes(CommandExecutes::queryCooldown)
                                )
                                .executes(CommandExecutes::queryList));
        dispatcher.register(head);
    }
}
