Search in sources :

Example 11 with CmdSyntaxException

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

the class CmdRpc method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    DiscordRPC rpc = ModuleManager.getModule(DiscordRPC.class);
    String text = StringUtils.join(args, ' ', 1, args.length);
    if (args[0].equalsIgnoreCase("top")) {
        rpc.setTopText(text);
        BleachLogger.info("Set top RPC text to \"" + text + "\"");
        BleachFileHelper.saveMiscSetting("discordRPCTopText", new JsonPrimitive(text));
    } else if (args[0].equalsIgnoreCase("bottom")) {
        rpc.setBottomText(text);
        BleachLogger.info("Set bottom RPC text to \"" + text + "\"");
        BleachFileHelper.saveMiscSetting("discordRPCBottomText", new JsonPrimitive(text));
    } else if (args[0].equalsIgnoreCase("current")) {
        BleachLogger.info("Current RPC status:\n" + rpc.getTopText() + "\n" + rpc.getBottomText());
    } else {
        throw new CmdSyntaxException();
    }
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) JsonPrimitive(com.google.gson.JsonPrimitive) DiscordRPC(org.bleachhack.module.mods.DiscordRPC)

Example 12 with CmdSyntaxException

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

the class CmdCustomSign method onCommand.

@Override
public void onCommand(String alias, String[] args) {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    NoRender noRender = ModuleManager.getModule(NoRender.class);
    if (args[0].equalsIgnoreCase("list")) {
        String s = "Sign Text:";
        for (Text text : noRender.signText) {
            s += "\n\u00a77" + text.getString();
        }
        BleachLogger.info(s);
        return;
    }
    String arg = args[0].toLowerCase(Locale.ENGLISH);
    boolean all = arg.equals("all");
    Text text = new LiteralText(String.join(" ", Arrays.asList(args).subList(1, args.length)));
    boolean[] linesToChange = new boolean[] { arg.equals("line1") || all, arg.equals("line2") || all, arg.equals("line3") || all, arg.equals("line4") || all };
    JsonArray json = new JsonArray();
    for (int i = 0; i < 4; i++) {
        if (linesToChange[i]) {
            noRender.signText[i] = text;
            json.add(noRender.signText[i].getString());
        }
    }
    BleachFileHelper.saveMiscSetting("customSignText", json);
    BleachLogger.info("Changed sign text!");
}
Also used : JsonArray(com.google.gson.JsonArray) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) NoRender(org.bleachhack.module.mods.NoRender) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) LiteralText(net.minecraft.text.LiteralText)

Example 13 with CmdSyntaxException

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

the class CmdEnchant method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (!mc.interactionManager.getCurrentGameMode().isCreative()) {
        BleachLogger.error("Not In Creative Mode!");
        return;
    }
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("list")) {
        MutableText text = new LiteralText("");
        int i = 0;
        for (String[] s : enchantments.keySet()) {
            int color = i % 2 == 0 ? BleachLogger.INFO_COLOR : Formatting.AQUA.getColorValue();
            text.append(new LiteralText("\u00a77[\u00a7r" + String.join("\u00a77/\u00a7r", s) + "\u00a77] ").setStyle(Style.EMPTY.withColor(color)));
            i++;
        }
        BleachLogger.info(text);
        return;
    }
    int level = args.length == 1 ? 1 : Integer.parseInt(args[1]);
    ItemStack item = mc.player.getInventory().getMainHandStack();
    if (args[0].equalsIgnoreCase("all")) {
        for (Enchantment e : Registry.ENCHANTMENT) {
            enchant(item, e, level);
        }
        return;
    }
    int i = NumberUtils.toInt(args[0], -1);
    if (i != -1) {
        enchant(item, Enchantment.byRawId(i), level);
    } else {
        enchant(item, enchantments.entrySet().stream().filter(e -> ArrayUtils.contains(e.getKey(), args[0])).map(Entry::getValue).findFirst().orElse(null), level);
    }
}
Also used : MutableText(net.minecraft.text.MutableText) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) ItemStack(net.minecraft.item.ItemStack) Enchantment(net.minecraft.enchantment.Enchantment) LiteralText(net.minecraft.text.LiteralText)

Example 14 with CmdSyntaxException

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

the class CmdFriends method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0 || args.length > 2) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("add")) {
        if (args.length < 2) {
            throw new CmdSyntaxException("No username selected");
        }
        BleachHack.friendMang.add(args[1]);
        BleachLogger.info("Added \"" + args[1] + "\" to the friend list");
    } else if (args[0].equalsIgnoreCase("remove")) {
        if (args.length < 2) {
            throw new CmdSyntaxException("No username selected");
        }
        BleachHack.friendMang.remove(args[1].toLowerCase(Locale.ENGLISH));
        BleachLogger.info("Removed \"" + args[1] + "\" from the friend list");
    } else if (args[0].equalsIgnoreCase("list")) {
        if (BleachHack.friendMang.getFriends().isEmpty()) {
            BleachLogger.info("You don't have any friends :(");
        } else {
            int len = BleachHack.friendMang.getFriends().stream().min((f1, f2) -> f2.length() - f1.length()).get().length() + 3;
            MutableText text = new LiteralText("Friends:");
            for (String f : BleachHack.friendMang.getFriends()) {
                String spaces = StringUtils.repeat(' ', len - f.length());
                text.append(new LiteralText("\n> " + f + spaces).styled(style -> style.withColor(BleachLogger.INFO_COLOR))).append(new LiteralText("\u00a7c[Del]").styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Remove " + f + " from your friendlist"))).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, getPrefix() + "friends remove " + f)))).append("   ").append(new LiteralText("\u00a73[NameMC]").styled(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText("Open NameMC page of " + f))).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + f))));
            }
            BleachLogger.info(text);
        }
    } else if (args[0].equalsIgnoreCase("clear")) {
        BleachHack.friendMang.getFriends().clear();
        BleachLogger.info("Cleared Friend list");
    } else {
        throw new CmdSyntaxException();
    }
    BleachFileHelper.SCHEDULE_SAVE_FRIENDS.set(true);
}
Also used : LiteralText(net.minecraft.text.LiteralText) CommandCategory(org.bleachhack.command.CommandCategory) BleachHack(org.bleachhack.BleachHack) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Locale(java.util.Locale) ClickEvent(net.minecraft.text.ClickEvent) MutableText(net.minecraft.text.MutableText) Command(org.bleachhack.command.Command) BleachLogger(org.bleachhack.util.BleachLogger) BleachFileHelper(org.bleachhack.util.io.BleachFileHelper) HoverEvent(net.minecraft.text.HoverEvent) StringUtils(org.apache.commons.lang3.StringUtils) MutableText(net.minecraft.text.MutableText) HoverEvent(net.minecraft.text.HoverEvent) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) ClickEvent(net.minecraft.text.ClickEvent) LiteralText(net.minecraft.text.LiteralText)

Example 15 with CmdSyntaxException

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

the class CmdInvPeek method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    for (AbstractClientPlayerEntity e : mc.world.getPlayers()) {
        if (e.getDisplayName().getString().equalsIgnoreCase(args[0])) {
            BleachQueue.add(() -> {
                BleachLogger.info("Opened inventory for " + e.getDisplayName().getString());
                mc.setScreen(new InventoryScreen(e) {

                    public boolean mouseClicked(double mouseX, double mouseY, int button) {
                        return false;
                    }

                    protected void drawBackground(MatrixStack matrices, float delta, int mouseX, int mouseY) {
                        RenderSystem.setShader(GameRenderer::getPositionTexShader);
                        RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
                        RenderSystem.setShaderTexture(0, BACKGROUND_TEXTURE);
                        this.drawTexture(matrices, x, y, 0, 0, this.backgroundWidth, this.backgroundHeight);
                        drawEntity(x + 51, y + 75, 30, (float) (x + 51) - mouseX, (float) (y + 75 - 50) - mouseY, this.client.player);
                    }
                });
            });
            return;
        }
    }
    BleachLogger.error("Player " + args[0] + " not found!");
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) MatrixStack(net.minecraft.client.util.math.MatrixStack) AbstractClientPlayerEntity(net.minecraft.client.network.AbstractClientPlayerEntity) InventoryScreen(net.minecraft.client.gui.screen.ingame.InventoryScreen)

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