Search in sources :

Example 21 with SINGLE_SUCCESS

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

the class ResetCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("settings").then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module module = context.getArgument("module", Module.class);
        module.settings.forEach(group -> group.forEach(Setting::reset));
        module.info("Reset all settings.");
        return SINGLE_SUCCESS;
    })).then(literal("all").executes(context -> {
        Modules.get().getAll().forEach(module -> module.settings.forEach(group -> group.forEach(Setting::reset)));
        info("Reset all module settings.");
        return SINGLE_SUCCESS;
    }))).then(literal("gui").executes(context -> {
        GuiThemes.get().clearWindowConfigs();
        info("The Click GUI positioning has been reset.");
        return SINGLE_SUCCESS;
    }).then(literal("scale").executes(context -> {
        GuiThemes.get().resetScale();
        info("The GUI scale has been reset.");
        return SINGLE_SUCCESS;
    }))).then(literal("bind").then(argument("module", ModuleArgumentType.module()).executes(context -> {
        Module module = context.getArgument("module", Module.class);
        module.keybind.set(true, -1);
        module.info("Reset bind.");
        return SINGLE_SUCCESS;
    })).then(literal("all").executes(context -> {
        Modules.get().getAll().forEach(module -> module.keybind.set(true, -1));
        info("Reset all binds.");
        return SINGLE_SUCCESS;
    }))).then(literal("hud").executes(context -> {
        Systems.get(HUD.class).reset.run();
        ChatUtils.info("HUD", "Reset all elements.");
        return SINGLE_SUCCESS;
    }));
}
Also used : CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Setting(mathax.client.settings.Setting) Systems(mathax.client.systems.Systems) GuiThemes(mathax.client.gui.GuiThemes) ChatUtils(mathax.client.utils.misc.ChatUtils) 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) HUD(mathax.client.systems.hud.HUD) Module(mathax.client.systems.modules.Module)

Example 22 with SINGLE_SUCCESS

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

the class BindsCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.executes(context -> {
        // Modules
        List<Module> modules = Modules.get().getAll().stream().filter(module -> module.keybind.isSet()).collect(Collectors.toList());
        info("--- Bound Modules ((highlight)%d(default)) ---", modules.size());
        for (Module module : modules) {
            HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, getTooltip(module));
            MutableText text = new LiteralText(module.title).formatted(Formatting.WHITE);
            text.setStyle(text.getStyle().withHoverEvent(hoverEvent));
            MutableText sep = new LiteralText(" - ");
            sep.setStyle(sep.getStyle().withHoverEvent(hoverEvent));
            text.append(sep.formatted(Formatting.GRAY));
            MutableText key = new LiteralText(module.keybind.toString());
            key.setStyle(key.getStyle().withHoverEvent(hoverEvent));
            text.append(key.formatted(Formatting.GRAY));
            ChatUtils.sendMsg(text);
        }
        return SINGLE_SUCCESS;
    });
}
Also used : LiteralText(net.minecraft.text.LiteralText) ChatUtils(mathax.client.utils.misc.ChatUtils) HoverEvent(net.minecraft.text.HoverEvent) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) Modules(mathax.client.systems.modules.Modules) MutableText(net.minecraft.text.MutableText) Command(mathax.client.systems.commands.Command) Module(mathax.client.systems.modules.Module) MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) Module(mathax.client.systems.modules.Module) LiteralText(net.minecraft.text.LiteralText)

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