/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.mojang.brigadier.builder.LiteralArgumentBuilder
 *  meteordevelopment.orbit.EventHandler
 *  net.minecraft.class_1297
 *  net.minecraft.class_2172
 *  net.minecraft.class_2561
 */
package meteordevelopment.meteorclient.commands.commands;

import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.commands.arguments.PlayerArgumentType;
import meteordevelopment.meteorclient.events.meteor.KeyEvent;
import meteordevelopment.meteorclient.events.meteor.MouseClickEvent;
import meteordevelopment.meteorclient.utils.misc.input.Input;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.class_1297;
import net.minecraft.class_2172;
import net.minecraft.class_2561;

public class SpectateCommand
extends Command {
    private final StaticListener shiftListener = new StaticListener();

    public SpectateCommand() {
        super("spectate", "Allows you to spectate nearby players", new String[0]);
    }

    @Override
    public void build(LiteralArgumentBuilder<class_2172> builder) {
        builder.then(SpectateCommand.literal("reset").executes(context -> {
            mc.method_1504((class_1297)SpectateCommand.mc.field_1724);
            return 1;
        }));
        builder.then(SpectateCommand.argument("player", PlayerArgumentType.create()).executes(context -> {
            mc.method_1504((class_1297)PlayerArgumentType.get(context));
            SpectateCommand.mc.field_1724.method_7353((class_2561)class_2561.method_43470((String)"Sneak to un-spectate."), true);
            MeteorClient.EVENT_BUS.subscribe((Object)this.shiftListener);
            return 1;
        }));
    }

    private static class StaticListener {
        private StaticListener() {
        }

        @EventHandler
        private void onKey(KeyEvent event) {
            if (Input.isPressed(mc.field_1690.field_1832)) {
                mc.method_1504((class_1297)mc.field_1724);
                event.cancel();
                MeteorClient.EVENT_BUS.unsubscribe((Object)this);
            }
        }

        @EventHandler
        private void onMouse(MouseClickEvent event) {
            if (Input.isPressed(mc.field_1690.field_1832)) {
                mc.method_1504((class_1297)mc.field_1724);
                event.cancel();
                MeteorClient.EVENT_BUS.unsubscribe((Object)this);
            }
        }
    }
}

