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);
}
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!");
}
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!");
}
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();
}
}
}
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();
}
Aggregations