Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Merge korikisulda's butcher brush.
Additionally made it work with //butcher flags (added as an argument) as well as respecting the max butcher radius if the player has the permission.
Dieser Commit ist enthalten in:
Ursprung
d78bbc4f68
Commit
e5d34a9d2c
@ -27,16 +27,25 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.commands.UtilityCommands.FlagContainer;
|
||||||
import com.sk89q.worldedit.masks.BlockMask;
|
import com.sk89q.worldedit.masks.BlockMask;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||||
import com.sk89q.worldedit.tools.BrushTool;
|
import com.sk89q.worldedit.tools.BrushTool;
|
||||||
import com.sk89q.worldedit.tools.brushes.*;
|
import com.sk89q.worldedit.tools.brushes.ButcherBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.ClipboardBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.CylinderBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.GravityBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.HollowCylinderBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.HollowSphereBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.SmoothBrush;
|
||||||
|
import com.sk89q.worldedit.tools.brushes.SphereBrush;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Brush shape commands.
|
* Brush shape commands.
|
||||||
@ -272,4 +281,53 @@ public class BrushCommands {
|
|||||||
player.print(String.format("Gravity brush equipped (%.0f).",
|
player.print(String.format("Gravity brush equipped (%.0f).",
|
||||||
radius));
|
radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "butcher", "kill" },
|
||||||
|
usage = "[radius] [command flags]",
|
||||||
|
desc = "Butcher brush",
|
||||||
|
help = "Kills nearby mobs within the specified radius.\n" +
|
||||||
|
"Any number of 'flags' that the //butcher command uses\n" +
|
||||||
|
"may be specified as an argument",
|
||||||
|
min = 0,
|
||||||
|
max = 2
|
||||||
|
)
|
||||||
|
@CommandPermissions("worldedit.brush.butcher")
|
||||||
|
public void butcherBrush(CommandContext args, LocalSession session,
|
||||||
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
|
LocalConfiguration config = we.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
FlagContainer flags = new FlagContainer(player);
|
||||||
|
if (args.argsLength() == 2) {
|
||||||
|
String flagString = args.getString(1);
|
||||||
|
// straight from the command, using contains instead of hasflag
|
||||||
|
flags.or(KillFlags.FRIENDLY , flagString.contains("f"));
|
||||||
|
flags.or(KillFlags.PETS , flagString.contains("p"), "worldedit.butcher.pets");
|
||||||
|
flags.or(KillFlags.NPCS , flagString.contains("n"), "worldedit.butcher.npcs");
|
||||||
|
flags.or(KillFlags.GOLEMS , flagString.contains("g"), "worldedit.butcher.golems");
|
||||||
|
flags.or(KillFlags.ANIMALS , flagString.contains("a"), "worldedit.butcher.animals");
|
||||||
|
flags.or(KillFlags.AMBIENT , flagString.contains("b"), "worldedit.butcher.ambient");
|
||||||
|
flags.or(KillFlags.WITH_LIGHTNING, flagString.contains("l"), "worldedit.butcher.lightning");
|
||||||
|
}
|
||||||
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
|
tool.setSize(radius);
|
||||||
|
tool.setBrush(new ButcherBrush(flags.flags), "worldedit.brush.butcher");
|
||||||
|
|
||||||
|
player.print(String.format("Butcher brush equipped (%.0f).",
|
||||||
|
radius));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,6 +402,7 @@ public class UtilityCommands {
|
|||||||
flags.or(KillFlags.ANIMALS , args.hasFlag('a'), "worldedit.butcher.animals");
|
flags.or(KillFlags.ANIMALS , args.hasFlag('a'), "worldedit.butcher.animals");
|
||||||
flags.or(KillFlags.AMBIENT , args.hasFlag('b'), "worldedit.butcher.ambient");
|
flags.or(KillFlags.AMBIENT , args.hasFlag('b'), "worldedit.butcher.ambient");
|
||||||
flags.or(KillFlags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning");
|
flags.or(KillFlags.WITH_LIGHTNING, args.hasFlag('l'), "worldedit.butcher.lightning");
|
||||||
|
// If you add flags here, please add them to com.sk89q.worldedit.tools.brushes.ButcherBrush as well
|
||||||
|
|
||||||
int killed;
|
int killed;
|
||||||
if (player.isPlayer()) {
|
if (player.isPlayer()) {
|
||||||
@ -420,7 +421,7 @@ public class UtilityCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FlagContainer {
|
public static class FlagContainer {
|
||||||
private final LocalPlayer player;
|
private final LocalPlayer player;
|
||||||
public int flags = 0;
|
public int flags = 0;
|
||||||
public FlagContainer(LocalPlayer player) {
|
public FlagContainer(LocalPlayer player) {
|
||||||
|
40
src/main/java/com/sk89q/worldedit/tools/brushes/ButcherBrush.java
Normale Datei
40
src/main/java/com/sk89q/worldedit/tools/brushes/ButcherBrush.java
Normale Datei
@ -0,0 +1,40 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.tools.brushes;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
|
public class ButcherBrush implements Brush {
|
||||||
|
private int flags;
|
||||||
|
|
||||||
|
public ButcherBrush(int flags) {
|
||||||
|
this.flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
|
throws MaxChangedBlocksException {
|
||||||
|
editSession.getWorld().killMobs(pos, size, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren