package com.tiedup.remake.commands;

import com.mojang.brigadier.CommandDispatcher;
import com.tiedup.remake.commands.subcommands.BondageSubCommand;
import com.tiedup.remake.commands.subcommands.DebtSubCommand;
import com.tiedup.remake.commands.subcommands.InventorySubCommand;
import com.tiedup.remake.commands.subcommands.MasterTestSubCommand;
import com.tiedup.remake.commands.subcommands.TestAnimSubCommand;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;

/**
 * Main TiedUp! command suite — registration hub.
 *
 * All command implementations are delegated to domain-specific sub-command classes
 * in the {@code subcommands/} package. This class only builds the root node and
 * wires together the sub-trees.
 *
 * Commands are grouped by domain:
 * - Bondage: tie, untie, gag, ungag, blindfold, unblind, collar, takecollar,
 *   takeearplugs, putearplugs, takeclothes, putclothes, fullyrestrain, enslave, free, adjust
 * - Debt: debt show/set/add/remove
 * - Master test: mastertest, masterchair, mastertask
 * - Test animation: testanim <animId>/stop
 * - Inventory: returnstuff
 * - Plus existing delegated commands: bounty, npc, key, collar, clothes,
 *   kidnapset, kidnapreload, cell, social, debug
 */
@SuppressWarnings("null")
public class TiedUpCommand {

    /**
     * Register all TiedUp commands with the command dispatcher.
     *
     * @param dispatcher The command dispatcher
     */
    public static void register(
        CommandDispatcher<CommandSourceStack> dispatcher
    ) {
        var root = Commands.literal("tiedup");

        // === Domain sub-commands (implemented in subcommands/ package) ===
        BondageSubCommand.register(root);
        DebtSubCommand.register(root);
        MasterTestSubCommand.register(root);
        TestAnimSubCommand.register(root);
        InventorySubCommand.register(root);

        // === Existing delegated commands (each has its own class) ===
        // /tiedup bounty <player> - Bounty system
        root.then(BountyCommand.createBountyCommand());
        // /tiedup npc ... - NPC management
        root.then(NPCCommand.createNPCCommand());
        // /tiedup key ... - Key management
        root.then(KeyCommand.createKeyCommand());
        // /tiedup collar ... - Collar management
        root.then(CollarCommand.createCollarCommand());
        // /tiedup clothes ... - Clothes configuration
        root.then(ClothesCommand.createClothesCommand());
        // /tiedup kidnapset - Configuration reload
        root.then(KidnapSetCommand.createKidnapSetCommand());
        // /tiedup kidnapreload - Configuration reload (alias)
        root.then(KidnapSetCommand.createKidnapReloadCommand());
        // /tiedup cell ... - Cell management
        root.then(CellCommand.createCellCommand());
        // === Social Commands ===
        root.then(SocialCommand.createBlockPlayerCommand());
        root.then(SocialCommand.createUnblockPlayerCommand());
        root.then(SocialCommand.createCheckBlockedCommand());
        root.then(SocialCommand.createNoRPCommand());
        root.then(SocialCommand.createMeCommand());
        root.then(SocialCommand.createPMCommand());
        root.then(SocialCommand.createTalkAreaCommand());
        root.then(SocialCommand.createTalkInfoCommand());
        // /tiedup debug ... - Captivity system debugging
        root.then(CaptivityDebugCommand.createDebugCommand());

        dispatcher.register(root);
    }
}
