Clean up the brush class

This commit is contained in:
Jesse Boyd 2017-01-08 23:53:46 +11:00
parent 1f83319c8f
commit c0cbe8b4cd
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 13 additions and 12 deletions

View File

@ -20,12 +20,10 @@ import com.sk89q.worldedit.util.Location;
public class CommandBrush implements Brush {
private final String command;
private final Player player;
private final int radius;
private final BrushTool tool;
public CommandBrush(Player player, BrushTool tool, String command, double radius) {
this.player = player;
public CommandBrush(BrushTool tool, String command, double radius) {
this.command = command;
this.radius = (int) radius;
this.tool = tool;
@ -40,13 +38,14 @@ public class CommandBrush implements Brush {
.replace("{world}", editSession.getQueue().getWorldName())
.replace("{size}", radius + "");
FawePlayer fp = editSession.getPlayer();
Player player = fp.getPlayer();
WorldVectorFace face = player.getBlockTraceFace(256, true);
if (face == null) {
position = position.add(0, 1, 1);
} else {
position = face.getFaceVector();
}
FawePlayer<Object> fp = FawePlayer.wrap(player);
fp.setSelection(selector);
PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
String[] cmds = replaced.split(";");

View File

@ -1,6 +1,7 @@
package com.boydti.fawe.object.brush;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.clipboard.ResizableClipboardBuilder;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.function.NullRegionFunction;
@ -11,7 +12,6 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Masks;
@ -25,17 +25,15 @@ import com.sk89q.worldedit.session.ClipboardHolder;
public class CopyPastaBrush implements DoubleActionBrush {
private final DoubleActionBrushTool tool;
private final LocalSession session;
private final Player player;
public CopyPastaBrush(Player player, LocalSession session, DoubleActionBrushTool tool) {
public CopyPastaBrush(DoubleActionBrushTool tool) {
this.tool = tool;
this.session = session;
this.player = player;
}
@Override
public void build(DoubleActionBrushTool.BrushAction action, final EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
FawePlayer fp = editSession.getPlayer();
LocalSession session = fp.getSession();
switch (action) {
case SECONDARY: {
Mask mask = tool.getMask();
@ -74,7 +72,7 @@ public class CopyPastaBrush implements DoubleActionBrush {
ClipboardHolder holder = new ClipboardHolder(clipboard, editSession.getWorld().getWorldData());
session.setClipboard(holder);
int blocks = builder.size();
player.print(BBC.getPrefix() + BBC.COMMAND_COPY.format(blocks));
BBC.COMMAND_COPY.send(fp, blocks);
return;
}
case PRIMARY: {
@ -90,7 +88,7 @@ public class CopyPastaBrush implements DoubleActionBrush {
.build();
Operations.completeLegacy(operation);
} catch (EmptyClipboardException e) {
player.print(BBC.getPrefix() + BBC.BRUSH_PASTE_NONE.s());
BBC.BRUSH_PASTE_NONE.send(fp);
}
}
}

View File

@ -22,6 +22,10 @@ public final class Masks {
private Masks() {
}
public static boolean isNull(Mask mask) {
return mask == null || mask == ALWAYS_TRUE;
}
/**
* Return a 3D mask that always returns true;
*