package shcm.shsupercm.fabric.citresewn;
import com.mojang.brigadier.LiteralMessage;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.fabricmc.fabric.api.client.command.v1.ClientCommandManager;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.text.Text;
import shcm.shsupercm.fabric.citresewn.cit.*;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyKey;
import shcm.shsupercm.fabric.citresewn.pack.format.PropertyValue;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.argument;
import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal;
import static net.minecraft.text.Text.of;
/**
* Logic for the /citresewn client command. Only enabled when Fabric API is present.
* Structure:
*
* /citresewn - General info command * /citresewn config - Opens the config gui(only when Cloth Config is present) * /citresewn analyze pack <pack> - Displays data for the given loaded cit pack. **/ public class CITResewnCommand { /** * @see shcm.shsupercm.fabric.citresewn.mixin.ChatScreenMixin */ public static boolean openConfig = false; /** * Registers */ static void register() { ClientCommandManager.DISPATCHER.register(literal("citresewn") .executes(context -> { //citresewn context.getSource().sendFeedback(of("CIT Resewn v" + FabricLoader.getInstance().getModContainer("citresewn").orElseThrow().getMetadata().getVersion() + ":")); context.getSource().sendFeedback(of(" Registered: " + CITRegistry.TYPES.values().stream().distinct().count() + " types and " + CITRegistry.CONDITIONS.values().stream().distinct().count() + " conditions")); final boolean active = CITResewnConfig.INSTANCE.enabled && ActiveCITs.isActive(); context.getSource().sendFeedback(of(" Active: " + (active ? "yes" : ("no, " + (CITResewnConfig.INSTANCE.enabled ? "no cit packs loaded" : "disabled in config"))))); if (active) { context.getSource().sendFeedback(of(" Loaded: " + ActiveCITs.getActive().cits.values().stream().mapToLong(Collection::size).sum() + " CITs from " + ActiveCITs.getActive().cits.values().stream().flatMap(Collection::stream).map(cit -> cit.packName).distinct().count() + " resourcepacks")); } context.getSource().sendFeedback(of("")); return 1; }) .then(literal("config") .executes(context -> { //citresewn config openConfig = true; return 1; })) .then(literal("analyze") .then(literal("pack") .then(argument("pack", new LoadedCITPackArgument()) .executes(context -> { //citresewn analyze