/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.mojang.brigadier.CommandDispatcher
 *  com.mojang.brigadier.exceptions.CommandSyntaxException
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_2172
 *  net.minecraft.class_634
 *  net.minecraft.class_7157
 *  net.minecraft.class_7225$class_7874
 *  net.minecraft.class_7699
 */
package meteordevelopment.meteorclient.commands;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.commands.commands.BindCommand;
import meteordevelopment.meteorclient.commands.commands.BindsCommand;
import meteordevelopment.meteorclient.commands.commands.CommandsCommand;
import meteordevelopment.meteorclient.commands.commands.DamageCommand;
import meteordevelopment.meteorclient.commands.commands.DisconnectCommand;
import meteordevelopment.meteorclient.commands.commands.DismountCommand;
import meteordevelopment.meteorclient.commands.commands.DropCommand;
import meteordevelopment.meteorclient.commands.commands.EnchantCommand;
import meteordevelopment.meteorclient.commands.commands.EnderChestCommand;
import meteordevelopment.meteorclient.commands.commands.FakePlayerCommand;
import meteordevelopment.meteorclient.commands.commands.FovCommand;
import meteordevelopment.meteorclient.commands.commands.FriendsCommand;
import meteordevelopment.meteorclient.commands.commands.GamemodeCommand;
import meteordevelopment.meteorclient.commands.commands.GiveCommand;
import meteordevelopment.meteorclient.commands.commands.HClipCommand;
import meteordevelopment.meteorclient.commands.commands.HelpCommand;
import meteordevelopment.meteorclient.commands.commands.InputCommand;
import meteordevelopment.meteorclient.commands.commands.InventoryCommand;
import meteordevelopment.meteorclient.commands.commands.LocateCommand;
import meteordevelopment.meteorclient.commands.commands.MacroCommand;
import meteordevelopment.meteorclient.commands.commands.ModulesCommand;
import meteordevelopment.meteorclient.commands.commands.NameHistoryCommand;
import meteordevelopment.meteorclient.commands.commands.NbtCommand;
import meteordevelopment.meteorclient.commands.commands.NotebotCommand;
import meteordevelopment.meteorclient.commands.commands.PeekCommand;
import meteordevelopment.meteorclient.commands.commands.ProfilesCommand;
import meteordevelopment.meteorclient.commands.commands.ReloadCommand;
import meteordevelopment.meteorclient.commands.commands.ResetCommand;
import meteordevelopment.meteorclient.commands.commands.RotationCommand;
import meteordevelopment.meteorclient.commands.commands.SaveMapCommand;
import meteordevelopment.meteorclient.commands.commands.SayCommand;
import meteordevelopment.meteorclient.commands.commands.ServerCommand;
import meteordevelopment.meteorclient.commands.commands.SettingCommand;
import meteordevelopment.meteorclient.commands.commands.SpectateCommand;
import meteordevelopment.meteorclient.commands.commands.SwarmCommand;
import meteordevelopment.meteorclient.commands.commands.ToggleCommand;
import meteordevelopment.meteorclient.commands.commands.VClipCommand;
import meteordevelopment.meteorclient.commands.commands.WaspCommand;
import meteordevelopment.meteorclient.commands.commands.WaypointCommand;
import meteordevelopment.meteorclient.events.game.GameJoinedEvent;
import meteordevelopment.meteorclient.pathing.PathManagers;
import meteordevelopment.meteorclient.utils.PostInit;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_2172;
import net.minecraft.class_634;
import net.minecraft.class_7157;
import net.minecraft.class_7225;
import net.minecraft.class_7699;

public class Commands {
    public static final List<Command> COMMANDS = new ArrayList<Command>();
    public static CommandDispatcher<class_2172> DISPATCHER = new CommandDispatcher();

    @PostInit(dependencies={PathManagers.class})
    public static void init() {
        Commands.add(new VClipCommand());
        Commands.add(new HClipCommand());
        Commands.add(new DismountCommand());
        Commands.add(new DisconnectCommand());
        Commands.add(new DamageCommand());
        Commands.add(new DropCommand());
        Commands.add(new EnchantCommand());
        Commands.add(new FakePlayerCommand());
        Commands.add(new FriendsCommand());
        Commands.add(new CommandsCommand());
        Commands.add(new InventoryCommand());
        Commands.add(new NbtCommand());
        Commands.add(new NotebotCommand());
        Commands.add(new PeekCommand());
        Commands.add(new EnderChestCommand());
        Commands.add(new ProfilesCommand());
        Commands.add(new ReloadCommand());
        Commands.add(new ResetCommand());
        Commands.add(new SayCommand());
        Commands.add(new ServerCommand());
        Commands.add(new SwarmCommand());
        Commands.add(new ToggleCommand());
        Commands.add(new SettingCommand());
        Commands.add(new SpectateCommand());
        Commands.add(new GamemodeCommand());
        Commands.add(new SaveMapCommand());
        Commands.add(new MacroCommand());
        Commands.add(new ModulesCommand());
        Commands.add(new BindsCommand());
        Commands.add(new GiveCommand());
        Commands.add(new NameHistoryCommand());
        Commands.add(new BindCommand());
        Commands.add(new FovCommand());
        Commands.add(new RotationCommand());
        Commands.add(new WaypointCommand());
        Commands.add(new InputCommand());
        Commands.add(new WaspCommand());
        Commands.add(new LocateCommand());
        Commands.add(new HelpCommand());
        COMMANDS.sort(Comparator.comparing(Command::getName));
        MeteorClient.EVENT_BUS.subscribe(Commands.class);
    }

    public static void add(Command command) {
        COMMANDS.removeIf(existing -> existing.getName().equals(command.getName()));
        COMMANDS.add(command);
    }

    public static void dispatch(String message) throws CommandSyntaxException {
        DISPATCHER.execute(message, (Object)MeteorClient.mc.method_1562().method_2875());
    }

    public static Command get(String name) {
        for (Command command : COMMANDS) {
            if (!command.getName().equals(name)) continue;
            return command;
        }
        return null;
    }

    @EventHandler
    private static void onJoin(GameJoinedEvent event) {
        class_634 networkHandler = MeteorClient.mc.method_1562();
        Command.REGISTRY_ACCESS = class_7157.method_46722((class_7225.class_7874)networkHandler.method_29091(), (class_7699)networkHandler.method_45735());
        DISPATCHER = new CommandDispatcher();
        for (Command command : COMMANDS) {
            command.registerTo(DISPATCHER);
        }
    }
}

