Search in sources :

Example 6 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.

the class ToggleCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("all").then(literal("on").executes(context -> {
        new ArrayList<>(Modules.get().getAll()).forEach(module -> {
            if (!module.isActive() && !module.name.equals("panic"))
                module.toggle();
        });
        HUD.get().active = true;
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        new ArrayList<>(Modules.get().getActive()).forEach(Module::toggle);
        HUD.get().active = false;
        return SINGLE_SUCCESS;
    }))).then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        m.toggle();
        return SINGLE_SUCCESS;
    }).then(literal("on").executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        if (!m.isActive())
            m.toggle();
        return SINGLE_SUCCESS;
    })).then(literal("off").executes(context -> {
        Module m = ModuleArgumentType.getModule(context, "module");
        if (m.isActive())
            m.toggle();
        return SINGLE_SUCCESS;
    })));
}
Also used : CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Modules(mathax.client.systems.modules.Modules) Command(mathax.client.systems.commands.Command) Module(mathax.client.systems.modules.Module) HUD(mathax.client.systems.hud.HUD) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ModuleArgumentType(mathax.client.systems.commands.arguments.ModuleArgumentType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Module(mathax.client.systems.modules.Module)

Example 7 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.

the class EnchantCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("one").then(argument("enchantment", EnchantmentArgumentType.enchantment()).then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
        one(context, enchantment -> context.getArgument("level", Integer.class));
        return SINGLE_SUCCESS;
    }))).then(literal("max").executes(context -> {
        one(context, Enchantment::getMaxLevel);
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("all_possible").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
        all(true, enchantment -> context.getArgument("level", Integer.class));
        return SINGLE_SUCCESS;
    }))).then(literal("max").executes(context -> {
        all(true, Enchantment::getMaxLevel);
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("all").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
        all(false, enchantment -> context.getArgument("level", Integer.class));
        return SINGLE_SUCCESS;
    }))).then(literal("max").executes(context -> {
        all(false, Enchantment::getMaxLevel);
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("clear").executes(context -> {
        ItemStack itemStack = tryGetItemStack();
        Utils.clearEnchantments(itemStack);
        syncItem();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("remove").then(argument("enchantment", EnchantmentArgumentType.enchantment()).executes(context -> {
        ItemStack itemStack = tryGetItemStack();
        Utils.removeEnchantment(itemStack, context.getArgument("enchantment", Enchantment.class));
        syncItem();
        return SINGLE_SUCCESS;
    })));
}
Also used : Utils(mathax.client.utils.Utils) LiteralText(net.minecraft.text.LiteralText) InventoryScreen(net.minecraft.client.gui.screen.ingame.InventoryScreen) Enchantment(net.minecraft.enchantment.Enchantment) CommandContext(com.mojang.brigadier.context.CommandContext) Function(java.util.function.Function) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) Registry(net.minecraft.util.registry.Registry) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) ItemStack(net.minecraft.item.ItemStack) EnchantmentArgumentType(net.minecraft.command.argument.EnchantmentArgumentType) Command(mathax.client.systems.commands.Command) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) Enchantment(net.minecraft.enchantment.Enchantment) ItemStack(net.minecraft.item.ItemStack)

Example 8 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.

the class EnemiesCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("add").then(argument("enemy", EnemyArgumentType.enemy()).executes(context -> {
        Enemy enemy = EnemyArgumentType.getEnemy(context, "enemy");
        if (Enemies.get().add(enemy)) {
            if (enemy.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                info("Added (highlight)%s(default) to enemies.", enemy.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Added to enemies.", Config.get().toastDuration.get()));
        } else {
            if (enemy.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                error("(highlight)%s(default) is already your enemy.", enemy.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.RED + "Already your enemy.", Config.get().toastDuration.get()));
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("remove").then(argument("enemy", EnemyArgumentType.enemy()).executes(context -> {
        Enemy enemy = EnemyArgumentType.getEnemy(context, "enemy");
        if (Enemies.get().remove(enemy)) {
            if (enemy.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                info("Removed (highlight)%s(default) from enemies.", enemy.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Removed from enemies.", Config.get().toastDuration.get()));
        } else {
            if (enemy.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                error("(highlight)%s(default) is not your enemy.", enemy.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.REDSTONE_BLOCK, Enemies.get().color.getPacked(), "Enemies " + Formatting.GRAY + "[" + Formatting.WHITE + enemy.name + Formatting.GRAY + "]", null, Formatting.RED + "Not your enemy.", Config.get().toastDuration.get()));
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("list").executes(context -> {
        info("--- Enemies ((highlight)%s(default)) ---", Enemies.get().count());
        Enemies.get().forEach(enemy -> info("(highlight)" + enemy.name));
        return SINGLE_SUCCESS;
    }));
}
Also used : Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) Collection(java.util.Collection) CompletableFuture(java.util.concurrent.CompletableFuture) Items(net.minecraft.item.Items) Enemies(mathax.client.systems.enemies.Enemies) ArgumentType(com.mojang.brigadier.arguments.ArgumentType) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Config(mathax.client.systems.config.Config) Enemy(mathax.client.systems.enemies.Enemy) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) CommandSource.suggestMatching(net.minecraft.command.CommandSource.suggestMatching) Command(mathax.client.systems.commands.Command) StringReader(com.mojang.brigadier.StringReader) ToastSystem(mathax.client.utils.render.ToastSystem) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) Enemy(mathax.client.systems.enemies.Enemy) ToastSystem(mathax.client.utils.render.ToastSystem)

Example 9 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project Client by MatHax.

the class NotebotCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("status").executes(ctx -> {
        Notebot notebot = Modules.get().get(Notebot.class);
        notebot.printStatus();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("pause").executes(ctx -> {
        Notebot notebot = Modules.get().get(Notebot.class);
        notebot.pause();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("resume").executes(ctx -> {
        Notebot notebot = Modules.get().get(Notebot.class);
        notebot.pause();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("stop").executes(ctx -> {
        Notebot notebot = Modules.get().get(Notebot.class);
        notebot.stop();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("play").then(argument("name", StringArgumentType.greedyString()).executes(ctx -> {
        Notebot notebot = Modules.get().get(Notebot.class);
        String name = ctx.getArgument("name", String.class);
        if (name == null || name.equals("")) {
            throw INVALID_NAME.create();
        }
        Path path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.txt", name));
        if (!path.toFile().exists()) {
            path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.nbs", name));
        }
        notebot.loadSong(path.toFile());
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("preview").then(argument("name", StringArgumentType.greedyString()).executes(ctx -> {
        Notebot notebot = Modules.get().get(Notebot.class);
        String name = ctx.getArgument("name", String.class);
        if (name == null || name == "") {
            throw INVALID_NAME.create();
        }
        Path path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.txt", name));
        if (!path.toFile().exists()) {
            path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.nbs", name));
        }
        notebot.previewSong(path.toFile());
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("record").then(literal("start").executes(ctx -> {
        ticks = -1;
        song.clear();
        MatHax.EVENT_BUS.subscribe(this);
        info("Recording started");
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("record").then(literal("cancel").executes(ctx -> {
        MatHax.EVENT_BUS.unsubscribe(this);
        info("Recording cancelled");
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("record").then(literal("save").then(argument("name", StringArgumentType.greedyString()).executes(ctx -> {
        String name = ctx.getArgument("name", String.class);
        if (name == null || name == "") {
            throw INVALID_NAME.create();
        }
        Path path = MatHax.FOLDER.toPath().resolve(String.format("Notebot/%s.txt", name));
        saveRecording(path);
        return SINGLE_SUCCESS;
    }))));
}
Also used : LiteralText(net.minecraft.text.LiteralText) MatHax(mathax.client.MatHax) Arrays(java.util.Arrays) PacketEvent(mathax.client.events.packets.PacketEvent) FileWriter(java.io.FileWriter) IOException(java.io.IOException) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) EventHandler(mathax.client.eventbus.EventHandler) ArrayList(java.util.ArrayList) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) PlaySoundS2CPacket(net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket) List(java.util.List) TickEvent(mathax.client.events.world.TickEvent) SoundEvents(net.minecraft.sound.SoundEvents) Modules(mathax.client.systems.modules.Modules) Notebot(mathax.client.systems.modules.misc.Notebot) Command(mathax.client.systems.commands.Command) Path(java.nio.file.Path) Path(java.nio.file.Path) Notebot(mathax.client.systems.modules.misc.Notebot)

Example 10 with SINGLE_SUCCESS

use of com.mojang.brigadier.Command.SINGLE_SUCCESS in project KiwiClient by TangyKiwi.

the class Enchant method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("one").then(argument("enchantment", EnchantmentArgumentType.enchantment()).then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
        one(context, enchantment -> context.getArgument("level", Integer.class));
        return SINGLE_SUCCESS;
    }))).then(literal("max").executes(context -> {
        one(context, Enchantment::getMaxLevel);
        return SINGLE_SUCCESS;
    }))));
    builder.then(literal("all_possible").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
        all(true, enchantment -> context.getArgument("level", Integer.class));
        return SINGLE_SUCCESS;
    }))).then(literal("max").executes(context -> {
        all(true, Enchantment::getMaxLevel);
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("all").then(literal("level").then(argument("level", IntegerArgumentType.integer()).executes(context -> {
        all(false, enchantment -> context.getArgument("level", Integer.class));
        return SINGLE_SUCCESS;
    }))).then(literal("max").executes(context -> {
        all(false, Enchantment::getMaxLevel);
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("clear").executes(context -> {
        ItemStack itemStack = tryGetItemStack();
        Utils.clearEnchantments(itemStack);
        syncItem();
        return SINGLE_SUCCESS;
    }));
    builder.then(literal("remove").then(argument("enchantment", EnchantmentArgumentType.enchantment()).executes(context -> {
        ItemStack itemStack = tryGetItemStack();
        Utils.removeEnchantment(itemStack, context.getArgument("enchantment", Enchantment.class));
        syncItem();
        return SINGLE_SUCCESS;
    })));
}
Also used : LiteralText(net.minecraft.text.LiteralText) InventoryScreen(net.minecraft.client.gui.screen.ingame.InventoryScreen) Enchantment(net.minecraft.enchantment.Enchantment) Command(com.tangykiwi.kiwiclient.command.Command) CommandContext(com.mojang.brigadier.context.CommandContext) Utils(com.tangykiwi.kiwiclient.util.Utils) Function(java.util.function.Function) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) Registry(net.minecraft.util.registry.Registry) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) ItemStack(net.minecraft.item.ItemStack) EnchantmentArgumentType(net.minecraft.command.argument.EnchantmentArgumentType) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) Enchantment(net.minecraft.enchantment.Enchantment) ItemStack(net.minecraft.item.ItemStack)

Aggregations

SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)22 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)22 CommandSource (net.minecraft.command.CommandSource)22 LiteralText (net.minecraft.text.LiteralText)15 Command (meteordevelopment.meteorclient.systems.commands.Command)11 Command (mathax.client.systems.commands.Command)10 List (java.util.List)9 ItemStack (net.minecraft.item.ItemStack)8 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)7 SimpleCommandExceptionType (com.mojang.brigadier.exceptions.SimpleCommandExceptionType)7 CommandContext (com.mojang.brigadier.context.CommandContext)6 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)6 ChatUtils (meteordevelopment.meteorclient.utils.player.ChatUtils)6 BaseText (net.minecraft.text.BaseText)6 BaritoneAPI (baritone.api.BaritoneAPI)5 Modules (mathax.client.systems.modules.Modules)5 Items (net.minecraft.item.Items)5 Formatting (net.minecraft.util.Formatting)5 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)4 Collectors (java.util.stream.Collectors)4