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 NPCS = 1 << 1;
|
||||||
public static final int ANIMALS = 1 << 2;
|
public static final int ANIMALS = 1 << 2;
|
||||||
public static final int GOLEMS = 1 << 3;
|
public static final int GOLEMS = 1 << 3;
|
||||||
|
public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS;
|
||||||
public static final int WITH_LIGHTNING = 1 << 20;
|
public static final int WITH_LIGHTNING = 1 << 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ public class UtilityCommands {
|
|||||||
@Command(
|
@Command(
|
||||||
aliases = { "butcher" },
|
aliases = { "butcher" },
|
||||||
usage = "[radius]",
|
usage = "[radius]",
|
||||||
flags = "plang",
|
flags = "plangf",
|
||||||
desc = "Kill all or nearby mobs",
|
desc = "Kill all or nearby mobs",
|
||||||
help =
|
help =
|
||||||
"Kills nearby mobs, based on radius, if none is given uses default in configuration.\n" +
|
"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" +
|
" -n also kills NPCs.\n" +
|
||||||
" -g also kills Golems.\n" +
|
" -g also kills Golems.\n" +
|
||||||
" -a also kills animals.\n" +
|
" -a also kills animals.\n" +
|
||||||
|
" -f compounds all previous flags.\n" +
|
||||||
" -l strikes lightning on each killed mob.",
|
" -l strikes lightning on each killed mob.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
@ -375,39 +376,48 @@ public class UtilityCommands {
|
|||||||
else{
|
else{
|
||||||
radius = config.butcherDefaultRadius;
|
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'))) {
|
FlagContainer flags = new FlagContainer(player);
|
||||||
flags |= KillFlags.GOLEMS;
|
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");
|
||||||
if (player.hasPermission("worldedit.butcher.animals") && (args.hasFlag('a'))) {
|
flags.or(KillFlags.GOLEMS , args.hasFlag('g'), "worldedit.butcher.golems");
|
||||||
flags |= KillFlags.ANIMALS;
|
flags.or(KillFlags.ANIMALS , args.hasFlag('a'), "worldedit.butcher.animals");
|
||||||
}
|
flags.or(KillFlags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning");
|
||||||
|
|
||||||
if (args.hasFlag('l') && player.hasPermission("worldedit.butcher.lightning")) flags |= KillFlags.WITH_LIGHTNING;
|
|
||||||
|
|
||||||
int killed;
|
int killed;
|
||||||
if (player.isPlayer()) {
|
if (player.isPlayer()) {
|
||||||
killed = player.getWorld().killMobs(session.getPlacementPosition(player), radius, flags);
|
killed = player.getWorld().killMobs(session.getPlacementPosition(player), radius, flags.flags);
|
||||||
} else {
|
} else {
|
||||||
killed = 0;
|
killed = 0;
|
||||||
for (LocalWorld world : we.getServer().getWorlds()) {
|
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.");
|
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(
|
@Command(
|
||||||
aliases = { "remove", "rem", "rement" },
|
aliases = { "remove", "rem", "rement" },
|
||||||
usage = "<type> <radius>",
|
usage = "<type> <radius>",
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren