mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
Scattercommand should use the same editsession for all commands, make it "silent" by default and allow players to see output if wanted.
This commit is contained in:
@ -11,20 +11,29 @@ import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ScatterCommand extends ScatterBrush {
|
||||
|
||||
private final String command;
|
||||
private final boolean print;
|
||||
|
||||
public ScatterCommand(int count, int distance, String command) {
|
||||
public ScatterCommand(int count, int distance, String command, boolean print) {
|
||||
super(count, distance);
|
||||
this.command = command;
|
||||
this.print = print;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(EditSession editSession, LocalBlockVectorSet placed, BlockVector3 position, Pattern p, double size) throws
|
||||
public void apply(
|
||||
EditSession editSession,
|
||||
LocalBlockVectorSet placed,
|
||||
BlockVector3 position,
|
||||
Pattern pattern,
|
||||
double size
|
||||
) throws
|
||||
MaxChangedBlocksException {
|
||||
int radius = getDistance();
|
||||
CuboidRegionSelector selector = new CuboidRegionSelector(
|
||||
@ -42,12 +51,40 @@ public class ScatterCommand extends ScatterBrush {
|
||||
player.setSelection(selector);
|
||||
List<String> cmds = StringMan.split(replaced, ';');
|
||||
for (String cmd : cmds) {
|
||||
CommandEvent event = new CommandEvent(
|
||||
new LocationMaskedPlayerWrapper(player, player.getLocation().setPosition(position.toVector3()), false),
|
||||
cmd
|
||||
);
|
||||
Player p = print ?
|
||||
new LocationMaskedPlayerWrapper(player, player.getLocation().setPosition(position.toVector3()), false) :
|
||||
new ScatterCommandPlayerWrapper(player, position);
|
||||
CommandEvent event = new CommandEvent(p, cmd, editSession);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class ScatterCommandPlayerWrapper extends LocationMaskedPlayerWrapper {
|
||||
|
||||
ScatterCommandPlayerWrapper(Player player, BlockVector3 position) {
|
||||
super(player, player.getLocation().setPosition(position.toVector3()), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ public class SilentPlayerWrapper extends AsyncPlayer {
|
||||
|
||||
@Override
|
||||
public void print(Component component) {
|
||||
super.print(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user