Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-09 21:10:05 +01:00
Add a -f (friendly) flag to butcher
Dieser Commit ist enthalten in:
Ursprung
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
|
||||
@ -376,38 +377,47 @@ public class UtilityCommands {
|
||||
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>",
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren