@Command( aliases = {"butcher", "kill"}, usage = "[radius]", flags = "plangbtfr", desc = "Butcher brush", help = "Kills nearby mobs within the specified radius.\n" + "Flags:\n" + " -p also kills pets.\n" + " -n also kills NPCs.\n" + " -g also kills Golems.\n" + " -a also kills animals.\n" + " -b also kills ambient mobs.\n" + " -t also kills mobs with name tags.\n" + " -f compounds all previous flags.\n" + " -r also destroys armor stands.\n" + " -l currently does nothing.", min = 0, max = 1) @CommandPermissions("worldedit.brush.butcher") public void butcherBrush( Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException { LocalConfiguration config = worldEdit.getConfiguration(); double radius = args.argsLength() > 0 ? args.getDouble(0) : 5; double maxRadius = config.maxBrushRadius; // hmmmm not horribly worried about this because -1 is still rather efficient, // the problem arises when butcherMaxRadius is some really high number but not infinite // - original idea taken from https://github.com/sk89q/worldedit/pull/198#issuecomment-6463108 if (player.hasPermission("worldedit.butcher")) { maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius); } if (radius > maxRadius) { player.printError("Maximum allowed brush radius: " + maxRadius); return; } CreatureButcher flags = new CreatureButcher(player); flags.fromCommand(args); BrushTool tool = session.getBrushTool(player.getItemInHand()); tool.setSize(radius); tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher"); player.print(String.format("Butcher brush equipped (%.0f).", radius)); }
@Command( aliases = {"/ex", "/ext", "/extinguish", "ex", "ext", "extinguish"}, usage = "[radius]", desc = "Extinguish nearby fire", min = 0, max = 1) @CommandPermissions("worldedit.extinguish") @Logging(PLACEMENT) public void extinguish( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); int defaultRadius = config.maxRadius != -1 ? Math.min(40, config.maxRadius) : 40; int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : defaultRadius; we.checkMaxRadius(size); int affected = editSession.removeNear(session.getPlacementPosition(player), 51, size); player.print(affected + " block(s) have been removed."); }
@Command( aliases = {"butcher"}, usage = "[radius]", flags = "plangbf", desc = "Kill all or nearby mobs", help = "Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" + "Flags:" + " -p also kills pets.\n" + " -n also kills NPCs.\n" + " -g also kills Golems.\n" + " -a also kills animals.\n" + " -b also kills ambient mobs.\n" + " -f compounds all previous flags.\n" + " -l strikes lightning on each killed mob.", min = 0, max = 1) @CommandPermissions("worldedit.butcher") @Logging(PLACEMENT) @Console public void butcher( CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { LocalConfiguration config = we.getConfiguration(); // technically the default can be larger than the max, but that's not my problem int radius = config.butcherDefaultRadius; // there might be a better way to do this but my brain is fried right now if (args.argsLength() > 0) { // user inputted radius, override the default radius = args.getInteger(0); if (config.butcherMaxRadius != -1) { // clamp if there is a max if (radius == -1) { radius = config.butcherMaxRadius; } else { // Math.min does not work if radius is -1 (actually highest possible value) radius = Math.min(radius, config.butcherMaxRadius); } } } FlagContainer flags = new FlagContainer(player); flags.or(KillFlags.FRIENDLY, args.hasFlag('f')); flags.or(KillFlags.PETS, args.hasFlag('p'), "worldedit.butcher.pets"); flags.or(KillFlags.NPCS, args.hasFlag('n'), "worldedit.butcher.npcs"); flags.or(KillFlags.GOLEMS, args.hasFlag('g'), "worldedit.butcher.golems"); flags.or(KillFlags.ANIMALS, args.hasFlag('a'), "worldedit.butcher.animals"); flags.or(KillFlags.AMBIENT, args.hasFlag('b'), "worldedit.butcher.ambient"); flags.or(KillFlags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning"); int killed; if (player.isPlayer()) { killed = player.getWorld().killMobs(session.getPlacementPosition(player), radius, flags.flags); } else { killed = 0; for (LocalWorld world : we.getServer().getWorlds()) { killed += world.killMobs(new Vector(), radius, flags.flags); } } if (radius < 0) { player.print("Killed " + killed + " mobs."); } else { player.print("Killed " + killed + " mobs in a radius of " + radius + "."); } }