Search in sources :

Example 6 with CmdSyntaxException

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

the class CmdSkull 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();
    }
    ItemStack item = new ItemStack(Items.PLAYER_HEAD, 64);
    Random random = new Random();
    String id = "[I;" + random.nextInt() + "," + random.nextInt() + "," + random.nextInt() + "," + random.nextInt() + "]";
    if (args.length < 2) {
        try {
            JsonObject json = new JsonParser().parse(Resources.toString(new URL("https://api.mojang.com/users/profiles/minecraft/" + args[0]), StandardCharsets.UTF_8)).getAsJsonObject();
            JsonObject json2 = new JsonParser().parse(Resources.toString(new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + json.get("id").getAsString()), StandardCharsets.UTF_8)).getAsJsonObject();
            item.setNbt(StringNbtReader.parse("{SkullOwner:{Id:" + id + ",Properties:{textures:[{Value:\"" + json2.get("properties").getAsJsonArray().get(0).getAsJsonObject().get("value").getAsString() + "\"}]}}}"));
        } catch (Exception e) {
            e.printStackTrace();
            BleachLogger.error("Error getting head! (" + e.getClass().getSimpleName() + ")");
        }
    } else if (args[0].equalsIgnoreCase("img")) {
        NbtCompound tag = StringNbtReader.parse("{SkullOwner:{Id:" + id + ",Properties:{textures:[{Value:\"" + encodeUrl(args[1]) + "\"}]}}}");
        item.setNbt(tag);
        BleachLogger.logger.info(tag);
    }
    mc.player.getInventory().addPickBlock(item);
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Random(java.util.Random) NbtCompound(net.minecraft.nbt.NbtCompound) JsonObject(com.google.gson.JsonObject) ItemStack(net.minecraft.item.ItemStack) URL(java.net.URL) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) JsonParser(com.google.gson.JsonParser)

Example 7 with CmdSyntaxException

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

the class CmdTerrain method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length != 6) {
        throw new CmdSyntaxException();
    }
    int[] poses = new int[6];
    for (int i = 0; i < 6; i++) {
        try {
            poses[i] = Integer.parseInt(args[i]);
            if (i >= 3 && poses[i - 3] > poses[i]) {
                int temp = poses[i - 3];
                poses[i - 3] = poses[i];
                poses[i] = temp;
            }
        } catch (Exception e) {
            throw new CmdSyntaxException("Could not parse number at pos " + i + " (\"" + args[i] + "\")");
        }
    }
    StringBuilder builder = new StringBuilder();
    for (int x = poses[0]; x <= poses[3]; x++) {
        for (int z = poses[2]; z <= poses[5]; z++) {
            for (int y = poses[4]; y >= poses[1]; y--) {
                if (mc.world.getBlockState(new BlockPos(x, y, z)).isFullCube(mc.world, new BlockPos(x, y, z))) {
                    builder.append(x - poses[0]).append(",").append(y - poses[1]).append(",").append(z - poses[2]).append("\n");
                    break;
                }
            }
        }
    }
    mc.keyboard.setClipboard(builder.toString().trim());
    BleachLogger.info("Copied terrain to clipboard!");
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) BlockPos(net.minecraft.util.math.BlockPos) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException)

Example 8 with CmdSyntaxException

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

the class CmdToggle method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length != 1) {
        throw new CmdSyntaxException();
    }
    for (Module m : ModuleManager.getModules()) {
        if (args[0].equalsIgnoreCase(m.getName())) {
            BleachQueue.add(m::toggle);
            BleachLogger.info(m.getName() + " Toggled");
            return;
        }
    }
    BleachLogger.error("Module \"" + args[0] + "\" Not Found!");
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) Module(org.bleachhack.module.Module)

Example 9 with CmdSyntaxException

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

the class CmdWatermark method onCommand.

@Override
public void onCommand(String alias, String[] args) throws Exception {
    if (args.length == 0) {
        throw new CmdSyntaxException();
    }
    if (args[0].equalsIgnoreCase("reset")) {
        if (args.length == 1) {
            BleachHack.watermark.reset(true, true);
            saveText();
            saveColor();
            BleachLogger.info("Reset the watermark text and colors!");
        } else if (args[1].equalsIgnoreCase("color")) {
            BleachHack.watermark.reset(false, true);
            saveColor();
            BleachLogger.info("Reset the watermark colors!");
        } else if (args[1].equalsIgnoreCase("text")) {
            BleachHack.watermark.reset(true, false);
            saveText();
            BleachLogger.info("Reset the watermark text!");
        } else {
            throw new CmdSyntaxException();
        }
    } else {
        if (args.length == 1) {
            throw new CmdSyntaxException();
        }
        if (args[0].equalsIgnoreCase("text")) {
            if (args.length > 3) {
                throw new CmdSyntaxException("The watermark can't contain more than 2 words.");
            }
            if ((args.length == 2 && args[1].length() < 2) || (args.length == 3 && (args[1].isEmpty() || args[2].isEmpty()))) {
                throw new CmdSyntaxException("The watermark can't be less than 2 characters long.");
            }
            BleachHack.watermark.setStrings(args[1], args.length == 3 ? args[2] : "");
            saveText();
            BleachLogger.info(new LiteralText("Set the watermark to ").append(BleachHack.watermark.getText()));
        } else if (args[0].equalsIgnoreCase("color")) {
            if (args.length > 3) {
                throw new CmdSyntaxException("The watermark can't contain more than 2 colors.");
            }
            BleachHack.watermark.setColor(Integer.parseInt(args[1].replace("x", "").replace("#", ""), 16), args.length == 3 ? Integer.parseInt(args[2].replace("x", "").replace("#", ""), 16) : BleachHack.watermark.getColor2());
            saveColor();
            BleachLogger.info(new LiteralText("Set the watermark to ").append(BleachHack.watermark.getText()));
        } else {
            throw new CmdSyntaxException();
        }
    }
}
Also used : CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) LiteralText(net.minecraft.text.LiteralText)

Example 10 with CmdSyntaxException

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

the class CmdNBT method getNbt.

private NbtCompound getNbt(String arg) {
    if (arg.equalsIgnoreCase("hand")) {
        return mc.player.getMainHandStack().getOrCreateNbt();
    } else if (arg.equalsIgnoreCase("block")) {
        HitResult target = mc.crosshairTarget;
        if (target.getType() == HitResult.Type.BLOCK) {
            BlockPos pos = ((BlockHitResult) target).getBlockPos();
            BlockEntity be = mc.world.getBlockEntity(pos);
            if (be != null) {
                return be.writeNbt(new NbtCompound());
            } else {
                return new NbtCompound();
            }
        }
        BleachLogger.error("Not looking at a block.");
        return null;
    } else if (arg.equalsIgnoreCase("entity")) {
        HitResult target = mc.crosshairTarget;
        if (target.getType() == HitResult.Type.ENTITY) {
            return ((EntityHitResult) target).getEntity().writeNbt(new NbtCompound());
        }
        BleachLogger.error("Not looking at an entity.");
        return null;
    }
    throw new CmdSyntaxException();
}
Also used : BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) NbtCompound(net.minecraft.nbt.NbtCompound) CmdSyntaxException(org.bleachhack.command.exception.CmdSyntaxException) BlockPos(net.minecraft.util.math.BlockPos) BlockEntity(net.minecraft.block.entity.BlockEntity)

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