Search in sources :

Example 16 with CmdSyntaxException

use of org.bleachhack.command.exception.CmdSyntaxException in project BleachHack by BleachDrinker420.

the class CmdNBT method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("get")) {
        if (args.length != 2) {
            throw new CmdSyntaxException();
        }
        NbtCompound nbt = getNbt(args[1]);
        if (nbt != null) {
            String stringNbt = NbtHelper.toPrettyPrintedString(nbt);
            Text copy = new LiteralText("\u00a7e\u00a7l<COPY>").styled(s -> s.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, stringNbt)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Copy the nbt of this item to your clipboard"))));
            BleachLogger.info(new LiteralText("\u00a76\u00a7lNBT: ").append(copy).append("\u00a76\n" + stringNbt));
        }
    } else if (args[0].equalsIgnoreCase("copy")) {
        if (args.length != 2) {
            throw new CmdSyntaxException();
        }
        NbtCompound nbt = getNbt(args[1]);
        if (nbt != null) {
            mc.keyboard.setClipboard(nbt.toString());
            BleachLogger.info("\u00a76Copied\n\u00a7f" + NbtHelper.toPrettyPrintedString(nbt) + "\n\u00a76to clipboard.");
        }
    } else if (args[0].equalsIgnoreCase("set")) {
        if (!mc.interactionManager.getCurrentGameMode().isCreative()) {
            BleachLogger.error("You must be in creative mode to set NBT!");
            return;
        }
        if (args.length < 2) {
            throw new CmdSyntaxException();
        }
        ItemStack item = mc.player.getMainHandStack();
        item.setNbt(StringNbtReader.parse(StringUtils.join(ArrayUtils.subarray(args, 1, args.length), ' ')));
        BleachLogger.info("\u00a76Set NBT of " + item.getItem().getName().getString() + " to\n" + BleachJsonHelper.formatJson(item.getNbt().toString()));
    } else if (args[0].equalsIgnoreCase("wipe")) {
        if (!mc.interactionManager.getCurrentGameMode().isCreative()) {
            BleachLogger.error("You must be in creative mode to wipe NBT!");
            return;
        }
        mc.player.getMainHandStack().setNbt(new NbtCompound());
    } else {
        throw new CmdSyntaxException();
    }
}
Also used : HoverEvent(net.minecraft.text.HoverEvent) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) NbtCompound(net.minecraft.nbt.NbtCompound) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) ItemStack(net.minecraft.item.ItemStack) LiteralText(net.minecraft.text.LiteralText)

Example 17 with CmdSyntaxException

use of org.bleachhack.command.exception.CmdSyntaxException in project BleachHack by BleachDrinker420.

the class CmdBind method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("clear")) {
        int c = 0;
        for (Module m : ModuleManager.getModules()) {
            if (m.getKey() != Module.KEY_UNBOUND) {
                m.setKey(Module.KEY_UNBOUND);
                c++;
            }
        }
        BleachLogger.info("Cleared " + c + " Binds");
    } else if (args.length >= 2 && (args.length >= 3 || !args[1].equalsIgnoreCase("set"))) {
        for (Module m : ModuleManager.getModules()) {
            if (m.getName().equalsIgnoreCase(args[1])) {
                if (args[0].equalsIgnoreCase("set")) {
                    int key = Module.KEY_UNBOUND;
                    // Special cases for rshift/rcontrol and that shit
                    try {
                        key = InputUtil.fromTranslationKey("key.keyboard." + args[2].toLowerCase(Locale.ENGLISH)).getCode();
                    } catch (IllegalArgumentException e) {
                        if (args[2].toLowerCase(Locale.ENGLISH).startsWith("right")) {
                            try {
                                key = InputUtil.fromTranslationKey("key.keyboard." + args[2].toLowerCase(Locale.ENGLISH).replaceFirst("right", "right.")).getCode();
                            } catch (IllegalArgumentException e1) {
                                throw new CmdSyntaxException("Unknown key: " + args[2] + " / " + args[2].toLowerCase(Locale.ENGLISH).replaceFirst("right", "right."));
                            }
                        } else if (args[2].toLowerCase(Locale.ENGLISH).startsWith("r")) {
                            try {
                                key = InputUtil.fromTranslationKey("key.keyboard." + args[2].toLowerCase(Locale.ENGLISH).replaceFirst("r", "right.")).getCode();
                            } catch (IllegalArgumentException e1) {
                                throw new CmdSyntaxException("Unknown key: " + args[2] + " / " + args[2].toLowerCase(Locale.ENGLISH).replaceFirst("r", "right."));
                            }
                        } else {
                            throw new CmdSyntaxException("Unknown key: " + args[2]);
                        }
                    }
                    m.setKey(key);
                    BleachLogger.info("Bound " + m.getName() + " To " + args[2] + " (KEY" + key + ")");
                } else if (args[0].equalsIgnoreCase("del")) {
                    m.setKey(Module.KEY_UNBOUND);
                    BleachLogger.info("Removed Bind For " + m.getName());
                }
                return;
            }
        }
        throw new CmdSyntaxException("Could Not Find Module \"" + args[1] + "\"");
    } else {
        throw new CmdSyntaxException();
    }
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Module(org.bleachhack.module.Module)

Example 18 with CmdSyntaxException

use of org.bleachhack.command.exception.CmdSyntaxException in project BleachHack by BleachDrinker420.

the class CmdClickGui method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length != 1 && args.length != 2) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("reset")) {
        if (args.length == 1 || args[1].equalsIgnoreCase("closed")) {
            int y = 50;
            for (Window m : ModuleClickGuiScreen.INSTANCE.getWindows()) {
                if (m instanceof ClickGuiWindow) {
                    ((ClickGuiWindow) m).hiding = true;
                    m.x1 = 30;
                    m.y1 = y;
                    y += 16;
                }
            }
        } else if (args[1].equalsIgnoreCase("open")) {
            int x = 10;
            for (Window m : ModuleClickGuiScreen.INSTANCE.getWindows()) {
                if (m instanceof ClickGuiWindow) {
                    ((ClickGuiWindow) m).hiding = false;
                    m.x1 = x;
                    m.y1 = 35;
                    x += ModuleManager.getModule(ClickGui.class).getSetting(0).asSlider().getValueInt() + 5;
                }
            }
        } else {
            throw new CmdSyntaxException("Invalid reset mode!");
        }
        BleachFileHelper.SCHEDULE_SAVE_CLICKGUI.set(true);
        BleachLogger.info("Reset the clickgui!");
    } else if (args[0].equalsIgnoreCase("length")) {
        if (!NumberUtils.isCreatable(args[1])) {
            throw new CmdSyntaxException("Invalid clickgui length: " + args[1]);
        }
        ModuleManager.getModule(ClickGui.class).getSetting(0).asSlider().setValue(NumberUtils.createNumber(args[1]).doubleValue());
        BleachFileHelper.SCHEDULE_SAVE_MODULES.set(true);
        BleachLogger.info("Set the clickgui length to: " + args[1]);
    } else {
        throw new CmdSyntaxException();
    }
}
Also used : Window(org.bleachhack.gui.window.Window) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) ClickGuiWindow(org.bleachhack.gui.clickgui.window.ClickGuiWindow)

Example 19 with CmdSyntaxException

use of org.bleachhack.command.exception.CmdSyntaxException in project BleachHack by BleachDrinker420.

the class CmdClip method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("up") || args[0].equalsIgnoreCase("down")) {
        int moveStep = args[0].equalsIgnoreCase("up") ? 1 : -1;
        Box box = mc.player.getBoundingBox();
        if (mc.player.hasVehicle()) {
            box = box.union(mc.player.getVehicle().getBoundingBox());
        }
        for (int y = MathHelper.floor(box.minY) + moveStep; !mc.world.isOutOfHeightLimit(y - 1); y += moveStep) {
            if (WorldUtils.doesBoxCollide(new Box(box.minX, y - 1, box.minZ, box.maxX, y - 0.01, box.maxZ)) && !WorldUtils.doesBoxCollide(box.offset(0, -box.minY + y, 0))) {
                move(0, y - box.minY, 0);
                return;
            }
        }
        BleachLogger.error("No empty spaces to clip you to!");
    } else {
        if (args.length != 3) {
            throw new CmdSyntaxException();
        }
        if (!NumberUtils.isCreatable(args[0])) {
            throw new CmdSyntaxException("Invalid x distance \"" + args[0] + "\"");
        }
        if (!NumberUtils.isCreatable(args[1])) {
            throw new CmdSyntaxException("Invalid y distance \"" + args[1] + "\"");
        }
        if (!NumberUtils.isCreatable(args[2])) {
            throw new CmdSyntaxException("Invalid z distance \"" + args[2] + "\"");
        }
        move(NumberUtils.createNumber(args[0]).doubleValue(), NumberUtils.createNumber(args[1]).doubleValue(), NumberUtils.createNumber(args[2]).doubleValue());
    }
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Box(net.minecraft.util.math.Box)

Aggregations

CmdSyntaxException (org.bleachhack.command.exception.CmdSyntaxException)19 LiteralText (net.minecraft.text.LiteralText)6 NbtCompound (net.minecraft.nbt.NbtCompound)5 ItemStack (net.minecraft.item.ItemStack)4 ClickEvent (net.minecraft.text.ClickEvent)3 HoverEvent (net.minecraft.text.HoverEvent)3 MutableText (net.minecraft.text.MutableText)3 Module (org.bleachhack.module.Module)3 JsonArray (com.google.gson.JsonArray)2 JsonPrimitive (com.google.gson.JsonPrimitive)2 Random (java.util.Random)2 Text (net.minecraft.text.Text)2 BlockPos (net.minecraft.util.math.BlockPos)2 Command (org.bleachhack.command.Command)2 CommandCategory (org.bleachhack.command.CommandCategory)2 BleachLogger (org.bleachhack.util.BleachLogger)2 BleachFileHelper (org.bleachhack.util.io.BleachFileHelper)2 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1