mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-02 02:47:11 +00:00
Add a -f (friendly) flag to butcher
This commit is contained in:
parent
a23e9b857f
commit
499f3ccda7
@ -40,6 +40,7 @@ public abstract class LocalWorld {
|
||||
public static final int NPCS = 1 << 1;
|
||||
public static final int ANIMALS = 1 << 2;
|
||||
public static final int GOLEMS = 1 << 3;
|
||||
public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS;
|
||||
public static final int WITH_LIGHTNING = 1 << 20;
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ public class UtilityCommands {
|
||||
@Command(
|
||||
aliases = { "butcher" },
|
||||
usage = "[radius]",
|
||||
flags = "plang",
|
||||
flags = "plangf",
|
||||
desc = "Kill all or nearby mobs",
|
||||
help =
|
||||
"Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" +
|
||||
@ -355,6 +355,7 @@ public class UtilityCommands {
|
||||
" -n also kills NPCs.\n" +
|
||||
" -g also kills Golems.\n" +
|
||||
" -a also kills animals.\n" +
|
||||
" -f compounds all previous flags.\n" +
|
||||
" -l strikes lightning on each killed mob.",
|
||||
min = 0,
|
||||
max = 1
|
||||
@ -375,39 +376,48 @@ public class UtilityCommands {
|
||||
else{
|
||||
radius = config.butcherDefaultRadius;
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
if (player.hasPermission("worldedit.butcher.pets") && (args.hasFlag('p'))) {
|
||||
flags |= KillFlags.PETS;
|
||||
}
|
||||
|
||||
if (player.hasPermission("worldedit.butcher.npcs") && (args.hasFlag('n'))) {
|
||||
flags |= KillFlags.NPCS;
|
||||
}
|
||||
|
||||
if (player.hasPermission("worldedit.butcher.golems") && (args.hasFlag('g'))) {
|
||||
flags |= KillFlags.GOLEMS;
|
||||
}
|
||||
|
||||
if (player.hasPermission("worldedit.butcher.animals") && (args.hasFlag('a'))) {
|
||||
flags |= KillFlags.ANIMALS;
|
||||
}
|
||||
|
||||
if (args.hasFlag('l') && player.hasPermission("worldedit.butcher.lightning")) flags |= KillFlags.WITH_LIGHTNING;
|
||||
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.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning");
|
||||
|
||||
int killed;
|
||||
if (player.isPlayer()) {
|
||||
killed = player.getWorld().killMobs(session.getPlacementPosition(player), radius, flags);
|
||||
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);
|
||||
killed += world.killMobs(new Vector(), radius, flags.flags);
|
||||
}
|
||||
}
|
||||
|
||||
player.print("Killed " + killed + " mobs.");
|
||||
}
|
||||
|
||||
public class FlagContainer {
|
||||
private final LocalPlayer player;
|
||||
public int flags = 0;
|
||||
public FlagContainer(LocalPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void or(int flag, boolean on) {
|
||||
if (on) flags |= flag;
|
||||
}
|
||||
|
||||
public void or(int flag, boolean on, String permission) {
|
||||
or(flag, on);
|
||||
|
||||
if ((flags & flag) != 0 && !player.hasPermission(permission)) {
|
||||
flags &= ~flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "remove", "rem", "rement" },
|
||||
usage = "<type> <radius>",
|
||||
|
Loading…
Reference in New Issue
Block a user