Search in sources :

Example 1 with CreatureButcher

use of com.sk89q.worldedit.command.util.CreatureButcher in project FastAsyncWorldEdit by IntellectualSites.

the class BrushCommands method butcherBrush.

@Command(name = "butcher", aliases = { "kill" }, desc = "Butcher brush, kills mobs within a radius")
@CommandPermissions("worldedit.brush.butcher")
public void butcherBrush(Player player, LocalSession session, @Arg(desc = "Radius to kill mobs in", def = "5") Expression radius, @Switch(name = 'p', desc = "Also kill pets") boolean killPets, @Switch(name = 'n', desc = "Also kill NPCs") boolean killNpcs, @Switch(name = 'g', desc = "Also kill golems") boolean killGolems, @Switch(name = 'a', desc = "Also kill animals") boolean killAnimals, @Switch(name = 'b', desc = "Also kill ambient mobs") boolean killAmbient, @Switch(name = 't', desc = "Also kill mobs with name tags") boolean killWithName, @Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)") boolean killFriendly, @Switch(name = 'r', desc = "Also destroy armor stands") boolean killArmorStands, @Switch(name = 'w', desc = "Also kill water mobs") boolean killWater, InjectedValueAccess context) throws WorldEditException {
    worldEdit.checkMaxBrushRadius(radius);
    CreatureButcher flags = new CreatureButcher(player);
    flags.or(CreatureButcher.Flags.FRIENDLY, killFriendly);
    // No permission check here. Flags will instead be filtered by the subsequent calls.
    flags.or(CreatureButcher.Flags.PETS, killPets, "worldedit.butcher.pets");
    flags.or(CreatureButcher.Flags.NPCS, killNpcs, "worldedit.butcher.npcs");
    flags.or(CreatureButcher.Flags.GOLEMS, killGolems, "worldedit.butcher.golems");
    flags.or(CreatureButcher.Flags.ANIMALS, killAnimals, "worldedit.butcher.animals");
    flags.or(CreatureButcher.Flags.AMBIENT, killAmbient, "worldedit.butcher.ambient");
    flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged");
    flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
    flags.or(CreatureButcher.Flags.WATER, killWater, "worldedit.butcher.water");
    set(context, new ButcherBrush(flags), "worldedit.brush.butcher").setSize(radius);
}
Also used : CreatureButcher(com.sk89q.worldedit.command.util.CreatureButcher) ButcherBrush(com.sk89q.worldedit.command.tool.brush.ButcherBrush) ScatterCommand(com.fastasyncworldedit.core.command.tool.brush.ScatterCommand) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Example 2 with CreatureButcher

use of com.sk89q.worldedit.command.util.CreatureButcher in project FastAsyncWorldEdit by IntellectualSites.

the class UtilityCommands method butcher.

@Command(name = "butcher", aliases = { "/butcher" }, desc = "Kill all or nearby mobs")
@CommandPermissions("worldedit.butcher")
@Logging(PLACEMENT)
public int butcher(Actor actor, @Arg(desc = "Radius to kill mobs in", def = "") Integer radius, @Switch(name = 'p', desc = "Also kill pets") boolean killPets, @Switch(name = 'n', desc = "Also kill NPCs") boolean killNpcs, @Switch(name = 'g', desc = "Also kill golems") boolean killGolems, @Switch(name = 'a', desc = "Also kill animals") boolean killAnimals, @Switch(name = 'b', desc = "Also kill ambient mobs") boolean killAmbient, @Switch(name = 't', desc = "Also kill mobs with name tags") boolean killWithName, @Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)") boolean killFriendly, @Switch(name = 'r', desc = "Also destroy armor stands") boolean killArmorStands, @Switch(name = 'w', desc = "Also kill water mobs") boolean killWater) throws WorldEditException {
    LocalConfiguration config = we.getConfiguration();
    if (radius == null) {
        radius = config.butcherDefaultRadius;
    } else if (radius < -1) {
        actor.print(Caption.of("worldedit.butcher.explain-all"));
        return 0;
    } else if (radius == -1) {
        if (config.butcherMaxRadius != -1) {
            radius = config.butcherMaxRadius;
        }
    }
    if (config.butcherMaxRadius != -1) {
        radius = Math.min(radius, config.butcherMaxRadius);
    }
    CreatureButcher flags = new CreatureButcher(actor);
    flags.or(CreatureButcher.Flags.FRIENDLY, killFriendly);
    // No permission check here. Flags will instead be filtered by the subsequent calls.
    flags.or(CreatureButcher.Flags.PETS, killPets, "worldedit.butcher.pets");
    flags.or(CreatureButcher.Flags.NPCS, killNpcs, "worldedit.butcher.npcs");
    flags.or(CreatureButcher.Flags.GOLEMS, killGolems, "worldedit.butcher.golems");
    flags.or(CreatureButcher.Flags.ANIMALS, killAnimals, "worldedit.butcher.animals");
    flags.or(CreatureButcher.Flags.AMBIENT, killAmbient, "worldedit.butcher.ambient");
    flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged");
    flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
    flags.or(CreatureButcher.Flags.WATER, killWater, "worldedit.butcher.water");
    // FAWE start - run this sync
    int finalRadius = radius;
    int killed = TaskManager.taskManager().sync(() -> killMatchingEntities(finalRadius, actor, flags::createFunction));
    // FAWE end
    actor.print(Caption.of("worldedit.butcher.killed", TextComponent.of(killed), TextComponent.of(radius)));
    return killed;
}
Also used : CreatureButcher(com.sk89q.worldedit.command.util.CreatureButcher) LocalConfiguration(com.sk89q.worldedit.LocalConfiguration) Logging(com.sk89q.worldedit.command.util.Logging) Command(org.enginehub.piston.annotation.Command) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)2 CreatureButcher (com.sk89q.worldedit.command.util.CreatureButcher)2 Command (org.enginehub.piston.annotation.Command)2 ScatterCommand (com.fastasyncworldedit.core.command.tool.brush.ScatterCommand)1 LocalConfiguration (com.sk89q.worldedit.LocalConfiguration)1 ButcherBrush (com.sk89q.worldedit.command.tool.brush.ButcherBrush)1 Logging (com.sk89q.worldedit.command.util.Logging)1