Changed instances of Pattern, Mask, etc. to newer versions.

Most affected is the brush code.
This commit is contained in:
sk89q 2014-06-27 19:55:38 -07:00
parent 9381beb417
commit d96d3cf8bc
35 changed files with 361 additions and 445 deletions

View File

@ -57,7 +57,6 @@ import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.RValue;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.math.interpolation.Interpolation;
import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
import com.sk89q.worldedit.math.interpolation.Node;
@ -275,7 +274,6 @@ public class EditSession implements Extent {
*
* @return mask, may be null
*/
@SuppressWarnings("deprecation")
public Mask getMask() {
return oldMask;
}
@ -285,13 +283,24 @@ public class EditSession implements Extent {
*
* @param mask mask or null
*/
@SuppressWarnings("deprecation")
public void setMask(Mask mask) {
this.oldMask = mask;
if (mask == null) {
maskingExtent.setMask(Masks.alwaysTrue());
} else {
maskingExtent.setMask(Masks.wrap(mask, this));
maskingExtent.setMask(mask);
}
}
/**
* @deprecated Use {@link #setMask(Mask)}
*/
@Deprecated
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
if (mask == null) {
setMask((Mask) null);
} else {
setMask(Masks.wrap(mask));
}
}
@ -786,7 +795,7 @@ public class EditSession implements Extent {
checkNotNull(position);
checkArgument(apothem >= 1, "apothem >= 1");
Mask mask = new com.sk89q.worldedit.masks.FuzzyBlockMask(new BaseBlock(blockType, -1));
Mask mask = new FuzzyBlockMask(this, new BaseBlock(blockType, -1));
Vector adjustment = new Vector(1, 1, 1).multiply(apothem - 1);
Region region = new CuboidRegion(
getWorld(), // Causes clamping of Y range
@ -855,7 +864,7 @@ public class EditSession implements Extent {
*/
@SuppressWarnings("deprecation")
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
Mask mask = filter == null ? new com.sk89q.worldedit.masks.ExistingBlockMask() : new com.sk89q.worldedit.masks.FuzzyBlockMask(filter);
Mask mask = filter == null ? new ExistingBlockMask(this) : new FuzzyBlockMask(this, filter);
return replaceBlocks(region, mask, pattern);
}
@ -876,7 +885,7 @@ public class EditSession implements Extent {
checkNotNull(pattern);
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
RegionMaskingFilter filter = new RegionMaskingFilter(Masks.wrap(mask, this), replace);
RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace);
RegionVisitor visitor = new RegionVisitor(region, filter);
Operations.completeLegacy(visitor);
return visitor.getAffected();

View File

@ -26,9 +26,9 @@ import com.sk89q.minecraft.util.commands.Logging;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.masks.BiomeTypeMask;
import com.sk89q.worldedit.masks.InvertedMask;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;

View File

@ -22,46 +22,42 @@ package com.sk89q.worldedit.command;
import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.CuboidClipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.LocalWorld.KillFlags;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.command.UtilityCommands.FlagContainer;
import com.sk89q.worldedit.masks.BlockMask;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.patterns.SingleBlockPattern;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.brush.ButcherBrush;
import com.sk89q.worldedit.command.tool.brush.ClipboardBrush;
import com.sk89q.worldedit.command.tool.brush.CylinderBrush;
import com.sk89q.worldedit.command.tool.brush.GravityBrush;
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
import com.sk89q.worldedit.command.tool.brush.*;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.parametric.Optional;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Brush shape commands.
*
* @author sk89q
* Commands to set brush shape.
*/
public class BrushCommands {
private final WorldEdit we;
public BrushCommands(WorldEdit we) {
this.we = we;
private final WorldEdit worldEdit;
/**
* Create a new instance.
*
* @param worldEdit reference to WorldEdit
*/
public BrushCommands(WorldEdit worldEdit) {
checkNotNull(worldEdit);
this.worldEdit = worldEdit;
}
@Command(
aliases = { "sphere", "s" },
usage = "<block> [radius]",
usage = "<pattern> [radius]",
flags = "h",
desc = "Choose the sphere brush",
help =
@ -71,25 +67,21 @@ public class BrushCommands {
max = 2
)
@CommandPermissions("worldedit.brush.sphere")
public void sphereBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
we.checkMaxBrushRadius(radius);
public void sphereBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
@Optional("2") double radius, @Switch('h') boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand());
Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill);
tool.setSize(radius);
if (args.hasFlag('h')) {
if (hollow) {
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
} else {
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
}
player.print(String.format("Sphere brush shape equipped (%.0f).",
radius));
player.print(String.format("Sphere brush shape equipped (%.0f).", radius));
}
@Command(
@ -104,28 +96,22 @@ public class BrushCommands {
max = 3
)
@CommandPermissions("worldedit.brush.cylinder")
public void cylinderBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
we.checkMaxBrushRadius(radius);
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
we.checkMaxBrushRadius(height);
public void cylinderBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
@Optional("2") double radius, @Optional("1") int height, @Switch('h') boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height);
BrushTool tool = session.getBrushTool(player.getItemInHand());
Pattern fill = we.getBlockPattern(player, args.getString(0));
tool.setFill(fill);
tool.setSize(radius);
if (args.hasFlag('h')) {
if (hollow) {
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
} else {
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
}
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
radius, height));
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).", radius, height));
}
@Command(
@ -140,8 +126,7 @@ public class BrushCommands {
max = 0
)
@CommandPermissions("worldedit.brush.clipboard")
public void clipboardBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
public void clipboardBrush(Player player, LocalSession session, EditSession editSession, @Switch('a') boolean ignoreAir) throws WorldEditException {
CuboidClipboard clipboard = session.getClipboard();
@ -152,12 +137,12 @@ public class BrushCommands {
Vector size = clipboard.getSize();
we.checkMaxBrushRadius(size.getBlockX());
we.checkMaxBrushRadius(size.getBlockY());
we.checkMaxBrushRadius(size.getBlockZ());
worldEdit.checkMaxBrushRadius(size.getBlockX());
worldEdit.checkMaxBrushRadius(size.getBlockY());
worldEdit.checkMaxBrushRadius(size.getBlockZ());
BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
tool.setBrush(new ClipboardBrush(clipboard, ignoreAir), "worldedit.brush.clipboard");
player.print("Clipboard brush shape equipped.");
}
@ -169,24 +154,20 @@ public class BrushCommands {
desc = "Choose the terrain softener brush",
help =
"Chooses the terrain softener brush.\n" +
"The -n flag makes it only consider naturally occuring blocks.",
"The -n flag makes it only consider naturally occurring blocks.",
min = 0,
max = 2
)
@CommandPermissions("worldedit.brush.smooth")
public void smoothBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
double radius = args.argsLength() > 0 ? args.getDouble(0) : 2;
we.checkMaxBrushRadius(radius);
int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4;
public void smoothBrush(Player player, LocalSession session, EditSession editSession,
@Optional("2") double radius, @Optional("4") int iterations, @Switch('n') boolean naturalBlocksOnly) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setSize(radius);
tool.setBrush(new SmoothBrush(iterations, args.hasFlag('n')), "worldedit.brush.smooth");
tool.setBrush(new SmoothBrush(iterations, naturalBlocksOnly), "worldedit.brush.smooth");
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (naturalBlocksOnly ? "natural blocks only" : "any block") + ").",
radius, iterations));
}
@ -198,21 +179,17 @@ public class BrushCommands {
max = 1
)
@CommandPermissions("worldedit.brush.ex")
public void extinguishBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
double radius = args.argsLength() > 1 ? args.getDouble(1) : 5;
we.checkMaxBrushRadius(radius);
public void extinguishBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand());
Pattern fill = new SingleBlockPattern(new BaseBlock(0));
Pattern fill = new BlockPattern(new BaseBlock(0));
tool.setFill(fill);
tool.setSize(radius);
tool.setMask(new BlockMask(new BaseBlock(BlockID.FIRE)));
tool.setMask(new BlockMask(editSession, new BaseBlock(BlockID.FIRE)));
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
player.print(String.format("Extinguisher equipped (%.0f).",
radius));
player.print(String.format("Extinguisher equipped (%.0f).", radius));
}
@Command(
@ -228,15 +205,12 @@ public class BrushCommands {
max = 1
)
@CommandPermissions("worldedit.brush.gravity")
public void gravityBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
we.checkMaxBrushRadius(radius);
public void gravityBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius, @Switch('h') boolean fromMaxY) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand());
tool.setSize(radius);
tool.setBrush(new GravityBrush(args.hasFlag('h')), "worldedit.brush.gravity");
tool.setBrush(new GravityBrush(fromMaxY), "worldedit.brush.gravity");
player.print(String.format("Gravity brush equipped (%.0f).",
radius));
@ -253,10 +227,9 @@ public class BrushCommands {
max = 2
)
@CommandPermissions("worldedit.brush.butcher")
public void butcherBrush(CommandContext args, LocalSession session,
LocalPlayer player, EditSession editSession) throws WorldEditException {
public void butcherBrush(CommandContext args, LocalSession session, Player player, EditSession editSession) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
LocalConfiguration config = worldEdit.getConfiguration();
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
double maxRadius = config.maxBrushRadius;

View File

@ -23,13 +23,13 @@ import com.sk89q.minecraft.util.commands.Command;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.command.parametric.Optional;
/**
* Tool commands.
*
* @author sk89q
*/
public class ToolUtilCommands {
private final WorldEdit we;
@ -77,13 +77,11 @@ public class ToolUtilCommands {
max = -1
)
@CommandPermissions("worldedit.brush.options.mask")
public void mask(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
if (args.argsLength() == 0) {
public void mask(Player player, LocalSession session, EditSession editSession, @Optional Mask mask) throws WorldEditException {
if (mask == null) {
session.getBrushTool(player.getItemInHand()).setMask(null);
player.print("Brush mask disabled.");
} else {
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
session.getBrushTool(player.getItemInHand()).setMask(mask);
player.print("Brush mask set.");
}
@ -97,9 +95,7 @@ public class ToolUtilCommands {
max = 1
)
@CommandPermissions("worldedit.brush.options.material")
public void material(CommandContext args, LocalSession session, LocalPlayer player,
EditSession editSession) throws WorldEditException {
Pattern pattern = we.getBlockPattern(player, args.getString(0));
public void material(Player player, LocalSession session, EditSession editSession, Pattern pattern) throws WorldEditException {
session.getBrushTool(player.getItemInHand()).setFill(pattern);
player.print("Brush material set.");
}

View File

@ -22,13 +22,15 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
/**
* A super pickaxe mode that will remove blocks in an area.
*
* @author sk89q
*/
public class AreaPickaxe implements BlockTool {
private static final BaseBlock air = new BaseBlock(0);
private int range;
@ -36,17 +38,17 @@ public class AreaPickaxe implements BlockTool {
this.range = range;
}
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.superpickaxe.area");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
int ox = clicked.getBlockX();
int oy = clicked.getBlockY();
int oz = clicked.getBlockZ();
int initialType = world.getBlockType(clicked);
int initialType = clicked.getWorld().getBlockType(clicked.toVector());
if (initialType == 0) {
return true;
@ -68,7 +70,7 @@ public class AreaPickaxe implements BlockTool {
continue;
}
world.queueBlockBreakEffect(server, pos, initialType, clicked.distanceSq(pos));
clicked.getWorld().queueBlockBreakEffect(server, pos, initialType, clicked.toVector().distanceSq(pos));
editSession.setBlock(pos, air);
}
@ -83,4 +85,5 @@ public class AreaPickaxe implements BlockTool {
return true;
}
}

View File

@ -19,29 +19,34 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
/**
* A mode that cycles the data values of supported blocks.
*
* @author sk89q
*/
public class BlockDataCyler implements DoubleActionBlockTool {
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.data-cycler");
}
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
private boolean handleCycle(Platform server, LocalConfiguration config,
Player player, LocalSession session, Location clicked, boolean forward) {
LocalWorld world = clicked.getWorld();
World world = clicked.getWorld();
int type = world.getBlockType(clicked);
int data = world.getBlockData(clicked);
int type = world.getBlockType(clicked.toVector());
int data = world.getBlockData(clicked.toVector());
if (config.allowedDataCycleBlocks.size() > 0
if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler")
&& !config.allowedDataCycleBlocks.contains(type)) {
player.printError("You are not permitted to cycle the data value of that block.");
@ -54,20 +59,19 @@ public class BlockDataCyler implements DoubleActionBlockTool {
if (data < 0) {
player.printError("That block's data cannot be cycled!");
} else {
world.setBlockData(clicked, data);
world.setBlockData(clicked.toVector(), data);
}
return true;
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
return handleCycle(server, config, player, session, clicked, true);
}
public boolean actSecondary(ServerInterface server,
LocalConfiguration config, LocalPlayer player,
LocalSession session, WorldVector clicked) {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
return handleCycle(server, config, player, session, clicked, false);
}

View File

@ -20,37 +20,40 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.world.World;
/**
* A mode that replaces one block.
*
* @author sk89q
*/
public class BlockReplacer implements DoubleActionBlockTool {
private BaseBlock targetBlock;
public BlockReplacer(BaseBlock targetBlock) {
this.targetBlock = targetBlock;
}
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.replacer");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
BlockBag bag = session.getBlockBag(player);
BlockBag bag = session.getBlockBag(player);
LocalWorld world = clicked.getWorld();
World world = clicked.getWorld();
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
try {
editSession.setBlock(clicked, targetBlock);
} catch (MaxChangedBlocksException e) {
editSession.setBlock(clicked.toVector(), targetBlock);
} catch (MaxChangedBlocksException ignored) {
} finally {
if (bag != null) {
bag.flushChanges();
@ -61,13 +64,12 @@ public class BlockReplacer implements DoubleActionBlockTool {
return true;
}
public boolean actSecondary(ServerInterface server,
LocalConfiguration config, LocalPlayer player,
LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = clicked.getWorld();
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player);
targetBlock = (editSession).getBlock(clicked);
targetBlock = (editSession).getBlock(clicked.toVector());
BlockType type = BlockType.fromID(targetBlock.getType());
if (type != null) {

View File

@ -19,25 +19,13 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
/**
* Represents a tool that uses a block..
*
* @author sk89q
*/
public interface BlockTool extends Tool {
/**
* Perform the action. Should return true to deny the default
* action.
*
* @param server
* @param config
* @param player
* @param session
* @param clicked
* @return true to deny
*/
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked);
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked);
}

View File

@ -20,28 +20,30 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.masks.CombinedMask;
import com.sk89q.worldedit.masks.Mask;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.patterns.SingleBlockPattern;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.session.request.Request;
/**
* Builds a shape at the place being looked at.
*
* @author sk89q
*/
public class BrushTool implements TraceTool {
protected static int MAX_RANGE = 500;
protected int range = -1;
private Mask mask = null;
private Brush brush = new SphereBrush();
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
private Pattern material = new BlockPattern(new BaseBlock(BlockID.COBBLESTONE));
private double size = 1;
private String permission;
@ -54,14 +56,8 @@ public class BrushTool implements TraceTool {
this.permission = permission;
}
/**
* Checks to see if the player can still be using this tool (considering
* permissions and such).
*
* @param player
* @return
*/
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission(permission);
}
@ -151,22 +147,14 @@ public class BrushTool implements TraceTool {
/**
* Set the set brush range.
*
* @param size
* @param range
*/
public void setRange(int range) {
this.range = range;
}
/**
* Perform the action. Should return true to deny the default
* action.
*
* @param player
* @param session
* @return true to deny
*/
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVector target = null;
target = player.getBlockTrace(getRange(), true);
@ -180,14 +168,14 @@ public class BrushTool implements TraceTool {
EditSession editSession = session.createEditSession(player);
Request.request().setEditSession(editSession);
if (mask != null) {
mask.prepare(session, player, target);
Mask existingMask = editSession.getMask();
if (existingMask == null) {
editSession.setMask(mask);
} else if (existingMask instanceof CombinedMask) {
((CombinedMask) existingMask).add(mask);
} else if (existingMask instanceof MaskIntersection) {
((MaskIntersection) existingMask).add(mask);
} else {
CombinedMask newMask = new CombinedMask(existingMask);
MaskIntersection newMask = new MaskIntersection(existingMask);
newMask.add(mask);
editSession.setMask(newMask);
}

View File

@ -20,12 +20,13 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.regions.RegionSelector;
/**
* A wand that can be used at a distance.
*
* @author wizjany
*/
public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
@ -34,12 +35,12 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
}
@Override
public boolean canUse(LocalPlayer player) {
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.wand");
}
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session) {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
WorldVector target = getTarget(player);
if (target == null) return true;
@ -56,8 +57,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
}
@Override
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session) {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
WorldVector target = getTarget(player);
if (target == null) return true;
@ -72,7 +72,7 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
return false;
}
public WorldVector getTarget(LocalPlayer player) {
public WorldVector getTarget(Player player) {
WorldVector target = null;
if (this.range > -1) {
target = player.getBlockTrace(getRange(), true);

View File

@ -20,28 +20,16 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
/**
* Represents a block tool that also has a secondary/primary function.
*
* @author sk89q
*/
public interface DoubleActionBlockTool extends BlockTool {
/**
* Perform the secondary action. Should return true to deny the default
* action.
*
* @param server
* @param config
* @param player
* @param session
* @param clicked
* @return true to deny
*/
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked);
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked);
}

View File

@ -20,24 +20,15 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Platform;
/**
* Represents a trace tool that also has a secondary/primary function.
*/
public interface DoubleActionTraceTool extends TraceTool {
/**
* Perform the secondary action. Should return true to deny the default
* action.
*
* @param server
* @param config
* @param player
* @param session
* @return true to deny
*/
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session);
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session);
}

View File

@ -19,18 +19,22 @@
package com.sk89q.worldedit.command.tool;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
/**
* A pickaxe mode that removes floating treetops (logs and leaves not connected
* to anything else)
*
* @author Moo0
*/
public class FloatingTreeRemover implements BlockTool {
private static final BaseBlock AIR = new BaseBlock(BlockID.AIR);
@ -40,16 +44,18 @@ public class FloatingTreeRemover implements BlockTool {
rangeSq = 100*100;
}
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.deltree");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config,
Player player, LocalSession session, Location clicked) {
final LocalWorld world = clicked.getWorld();
final World world = clicked.getWorld();
switch (world.getBlockType(clicked)) {
switch (world.getBlockType(clicked.toVector())) {
case BlockID.LOG:
case BlockID.LOG2:
case BlockID.LEAVES:
@ -67,7 +73,7 @@ public class FloatingTreeRemover implements BlockTool {
final EditSession editSession = session.createEditSession(player);
try {
final Set<Vector> blockSet = bfs(world, clicked);
final Set<Vector> blockSet = bfs(world, clicked.toVector());
if (blockSet == null) {
player.printError("That's not a floating tree.");
return true;
@ -111,7 +117,7 @@ public class FloatingTreeRemover implements BlockTool {
* @param origin any point contained in the floating tree
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
*/
private Set<Vector> bfs(LocalWorld world, Vector origin) throws MaxChangedBlocksException {
private Set<Vector> bfs(World world, Vector origin) throws MaxChangedBlocksException {
final Set<Vector> visited = new HashSet<Vector>();
final LinkedList<Vector> queue = new LinkedList<Vector>();

View File

@ -19,18 +19,23 @@
package com.sk89q.worldedit.command.tool;
import java.util.HashSet;
import java.util.Set;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import java.util.HashSet;
import java.util.Set;
/**
* A tool that flood fills blocks.
*
* @author sk89q
*/
public class FloodFillTool implements BlockTool {
private int range;
private Pattern pattern;
@ -39,15 +44,16 @@ public class FloodFillTool implements BlockTool {
this.pattern = pattern;
}
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.flood-fill");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
World world = clicked.getWorld();
int initialType = world.getBlockType(clicked);
int initialType = world.getBlockType(clicked.toVector());
if (initialType == BlockID.AIR) {
return true;
@ -60,8 +66,8 @@ public class FloodFillTool implements BlockTool {
EditSession editSession = session.createEditSession(player);
try {
recurse(server, editSession, world, clicked.toBlockVector(),
clicked, range, initialType, new HashSet<BlockVector>());
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
@ -71,23 +77,8 @@ public class FloodFillTool implements BlockTool {
return true;
}
/**
* Helper method.
*
* @param server
* @param superPickaxeManyDrop
* @param world
* @param pos
* @param origin
* @param size
* @param initialType
* @param visited
*/
private void recurse(ServerInterface server, EditSession editSession,
LocalWorld world, BlockVector pos,
Vector origin, int size, int initialType,
Set<BlockVector> visited)
throws MaxChangedBlocksException {
private void recurse(Platform server, EditSession editSession, World world, BlockVector pos, Vector origin, int size, int initialType,
Set<BlockVector> visited) throws MaxChangedBlocksException {
if (origin.distance(pos) > size || visited.contains(pos)) {
return;

View File

@ -22,11 +22,12 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
/**
* A tool that can place (or remove) blocks at a distance.
*
* @author wizjany
*/
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
@ -40,13 +41,12 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
}
@Override
public boolean canUse(LocalPlayer player) {
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.lrbuild");
}
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session) {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVectorFace pos = getTargetFace(player);
if (pos == null) return false;
EditSession eS = session.createEditSession(player);
@ -65,9 +65,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
}
@Override
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session) {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
WorldVectorFace pos = getTargetFace(player);
if (pos == null) return false;
EditSession eS = session.createEditSession(player);
@ -84,7 +82,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
return false;
}
public WorldVectorFace getTargetFace(LocalPlayer player) {
public WorldVectorFace getTargetFace(Player player) {
WorldVectorFace target = null;
target = player.getBlockTraceFace(getRange(), true);
@ -95,4 +93,5 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
return target;
}
}

View File

@ -19,33 +19,39 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.world.World;
/**
* Plants a tree.
*
* @author sk89q
* Looks up information about a block.
*/
public class QueryTool implements BlockTool {
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.info");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
LocalWorld world = clicked.getWorld();
World world = clicked.getWorld();
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
BaseBlock block = (editSession).rawGetBlock(clicked);
BaseBlock block = (editSession).rawGetBlock(clicked.toVector());
BlockType type = BlockType.fromID(block.getType());
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
+ "#" + block.getType() + "\u00A77" + " ("
+ (type == null ? "Unknown" : type.getName()) + ") "
+ "\u00A7f"
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked) + "/" + world.getBlockLightLevel(clicked.add(0, 1, 0)) + ")");
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");
if (block instanceof MobSpawnerBlock) {
player.printRaw("\u00A7e" + "Mob Type: "

View File

@ -22,6 +22,10 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.world.World;
import java.util.HashSet;
import java.util.Set;
@ -29,10 +33,9 @@ import java.util.Set;
/**
* A pickaxe mode that recursively finds adjacent blocks within range of
* an initial block and of the same type.
*
* @author sk89q
*/
public class RecursivePickaxe implements BlockTool {
private static final BaseBlock air = new BaseBlock(0);
private double range;
@ -40,15 +43,16 @@ public class RecursivePickaxe implements BlockTool {
this.range = range;
}
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.superpickaxe.recursive");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = clicked.getWorld();
int initialType = world.getBlockType(clicked);
int initialType = world.getBlockType(clicked.toVector());
if (initialType == BlockID.AIR) {
return true;
@ -62,8 +66,8 @@ public class RecursivePickaxe implements BlockTool {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
try {
recurse(server, editSession, world, clicked.toBlockVector(),
clicked, range, initialType, new HashSet<BlockVector>());
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<BlockVector>());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
@ -74,22 +78,8 @@ public class RecursivePickaxe implements BlockTool {
return true;
}
/**
* Helper method.
*
* @param server
* @param world
* @param pos
* @param origin
* @param size
* @param initialType
* @param visited
*/
private static void recurse(ServerInterface server, EditSession editSession,
LocalWorld world, BlockVector pos,
Vector origin, double size, int initialType,
Set<BlockVector> visited)
throws MaxChangedBlocksException {
private static void recurse(Platform server, EditSession editSession, World world, BlockVector pos,
Vector origin, double size, int initialType, Set<BlockVector> visited) throws MaxChangedBlocksException {
final double distanceSq = origin.distanceSq(pos);
if (distanceSq > size*size || visited.contains(pos)) {

View File

@ -19,26 +19,31 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.world.World;
/**
* A super pickaxe mode that removes one block.
*
* @author sk89q
*/
public class SinglePickaxe implements BlockTool {
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.superpickaxe");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
LocalWorld world = clicked.getWorld();
final int blockType = world.getBlockType(clicked);
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = clicked.getWorld();
final int blockType = world.getBlockType(clicked.toVector());
if (blockType == BlockID.BEDROCK
&& !player.canDestroyBedrock()) {
return true;
@ -48,14 +53,14 @@ public class SinglePickaxe implements BlockTool {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
try {
editSession.setBlock(clicked, new BaseBlock(BlockID.AIR));
editSession.setBlock(clicked.toVector(), new BaseBlock(BlockID.AIR));
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
editSession.flushQueue();
}
world.playEffect(clicked, 2001, blockType);
world.playEffect(clicked.toVector(), 2001, blockType);
return true;
}

View File

@ -19,23 +19,21 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.extension.platform.Actor;
/**
* Represents a tool. This interface alone defines nothing. A tool also
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
*
* @author sk89q
*/
public abstract interface Tool {
public interface Tool {
/**
* Checks to see if the player can still be using this tool (considering
* permissions and such).
*
* @param player
* @return
* @param actor the actor
* @return true if use is permitted
*/
public boolean canUse(LocalPlayer player);
public boolean canUse(Actor actor);
}

View File

@ -20,26 +20,11 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Platform;
/**
* Represents a tool that does not require a block.
*
* @author sk89q
*/
public interface TraceTool extends Tool {
/**
* Perform the action. Should return true to deny the default
* action.
*
* @param server
* @param config
* @param player
* @param session
* @return true to deny
*/
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session);
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session);
}

View File

@ -20,26 +20,30 @@
package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.*;
import com.sk89q.worldedit.util.Location;
/**
* Plants a tree.
*
* @author sk89q
*/
public class TreePlanter implements BlockTool {
private TreeGenerator gen;
public TreePlanter(TreeGenerator gen) {
this.gen = gen;
}
public boolean canUse(LocalPlayer player) {
@Override
public boolean canUse(Actor player) {
return player.hasPermission("worldedit.tool.tree");
}
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
LocalPlayer player, LocalSession session, WorldVector clicked) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
EditSession editSession = session.createEditSession(player);
@ -47,7 +51,7 @@ public class TreePlanter implements BlockTool {
boolean successful = false;
for (int i = 0; i < 10; i++) {
if (gen.generate(editSession, clicked.add(0, 1, 0))) {
if (gen.generate(editSession, clicked.toVector().add(0, 1, 0))) {
successful = true;
break;
}

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
/**
* Represents a brush.
@ -39,6 +39,5 @@ public interface Brush {
* @param size
* @throws MaxChangedBlocksException
*/
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException;
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException;
}

View File

@ -22,9 +22,10 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
public class ButcherBrush implements Brush {
private int flags;
public ButcherBrush(int flags) {
@ -32,8 +33,7 @@ public class ButcherBrush implements Brush {
}
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.getWorld().killMobs(pos, size, flags);
}

View File

@ -23,9 +23,10 @@ import com.sk89q.worldedit.CuboidClipboard;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
public class ClipboardBrush implements Brush {
private CuboidClipboard clipboard;
private boolean noAir;
@ -34,8 +35,8 @@ public class ClipboardBrush implements Brush {
this.noAir = noAir;
}
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
}
}

View File

@ -22,17 +22,19 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.Patterns;
public class CylinderBrush implements Brush {
private int height;
public CylinderBrush(int height) {
this.height = height;
}
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
editSession.makeCylinder(pos, mat, size, size, height, true);
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, true);
}
}

View File

@ -24,14 +24,12 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import java.util.*;
/**
* @author zml2008
*/
public class GravityBrush implements Brush {
private final boolean fullHeight;
public GravityBrush(boolean fullHeight) {
@ -65,4 +63,5 @@ public class GravityBrush implements Brush {
}
}
}
}

View File

@ -22,17 +22,20 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.Patterns;
public class HollowCylinderBrush implements Brush {
private int height;
public HollowCylinderBrush(int height) {
this.height = height;
}
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
editSession.makeCylinder(pos, mat, size, size, height, false);
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeCylinder(pos, Patterns.wrap(mat), size, size, height, false);
}
}

View File

@ -22,14 +22,13 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.Patterns;
public class HollowSphereBrush implements Brush {
public HollowSphereBrush() {
}
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, mat, size, size, size, false);
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, false);
}
}

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import com.sk89q.worldedit.math.convolution.HeightMap;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -27,11 +28,11 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.math.convolution.GaussianKernel;
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
public class SmoothBrush implements Brush {
private int iterations;
private boolean naturalOnly;
@ -53,4 +54,5 @@ public class SmoothBrush implements Brush {
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
heightMap.applyFilter(filter, iterations);
}
}

View File

@ -22,14 +22,13 @@ package com.sk89q.worldedit.command.tool.brush;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.patterns.Pattern;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.Patterns;
public class SphereBrush implements Brush {
public SphereBrush() {
}
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
throws MaxChangedBlocksException {
editSession.makeSphere(pos, mat, size, size, size, true);
@Override
public void build(EditSession editSession, Vector pos, Pattern mat, double size) throws MaxChangedBlocksException {
editSession.makeSphere(pos, Patterns.wrap(mat), size, size, size, true);
}
}

View File

@ -318,26 +318,21 @@ public class PlatformManager {
return;
}
if (player instanceof LocalPlayer) { // Temporary workaround
LocalPlayer localPlayer = (LocalPlayer) player;
WorldVector worldVector = new WorldVector(location);
if (player.isHoldingPickAxe() && session.hasSuperPickAxe()) {
final BlockTool superPickaxe = session.getSuperPickaxe();
if (superPickaxe != null && superPickaxe.canUse(localPlayer)) {
event.setCancelled(superPickaxe.actPrimary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector));
if (superPickaxe != null && superPickaxe.canUse(player)) {
event.setCancelled(superPickaxe.actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location));
return;
}
}
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionBlockTool) {
if (tool.canUse(localPlayer)) {
((DoubleActionBlockTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector);
if (tool.canUse(player)) {
((DoubleActionBlockTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
event.setCancelled(true);
}
}
}
} else if (event.getType() == Interaction.OPEN) {
if (player.getItemInHand() == getConfiguration().wandItem) {
@ -358,21 +353,16 @@ public class PlatformManager {
return;
}
if (player instanceof LocalPlayer) { // Temporary workaround
LocalPlayer localPlayer = (LocalPlayer) player;
WorldVector worldVector = new WorldVector(location);
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof BlockTool) {
if (tool.canUse(localPlayer)) {
((BlockTool) tool).actPrimary(getServerInterface(), getConfiguration(), localPlayer, session, worldVector);
if (tool.canUse(player)) {
((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location);
event.setCancelled(true);
}
}
}
}
}
}
@SuppressWarnings("deprecation")
@Subscribe
@ -380,6 +370,7 @@ public class PlatformManager {
// Create a proxy actor with a potentially different world for
// making changes to the world
Player player = createProxyActor(event.getPlayer());
World world = player.getWorld();
switch (event.getInputType()) {
case PRIMARY: {
@ -405,18 +396,14 @@ public class PlatformManager {
LocalSession session = worldEdit.getSessionManager().get(player);
if (player instanceof LocalPlayer) { // Temporary workaround
LocalPlayer localPlayer = (LocalPlayer) player;
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof DoubleActionTraceTool) {
if (tool.canUse(localPlayer)) {
((DoubleActionTraceTool) tool).actSecondary(getServerInterface(), getConfiguration(), localPlayer, session);
if (tool.canUse(player)) {
((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
event.setCancelled(true);
return;
}
}
}
break;
}
@ -441,18 +428,14 @@ public class PlatformManager {
LocalSession session = worldEdit.getSessionManager().get(player);
if (player instanceof LocalPlayer) { // Temporary workaround
LocalPlayer localPlayer = (LocalPlayer) player;
Tool tool = session.getTool(player.getItemInHand());
if (tool != null && tool instanceof TraceTool) {
if (tool.canUse(localPlayer)) {
((TraceTool) tool).actPrimary(getServerInterface(), getConfiguration(), localPlayer, session);
if (tool.canUse(player)) {
((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session);
event.setCancelled(true);
return;
}
}
}
break;
}

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.internal;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.regions.Region;
@ -250,7 +251,7 @@ public class LocalWorldAdapter extends LocalWorld {
}
@Override
public boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority) {
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
return world.queueBlockBreakEffect(server, position, blockId, priority);
}

View File

@ -25,6 +25,7 @@ import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
@ -219,7 +220,7 @@ public abstract class AbstractWorld implements World {
@SuppressWarnings("deprecation")
@Override
public boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority) {
public boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority) {
if (taskId == -1) {
taskId = server.schedule(0, 1, new Runnable() {
@Override

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.world;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.regions.Region;
@ -342,7 +343,7 @@ public interface World extends Extent {
* @param priority the priority
* @return true if the effect was played
*/
boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority);
boolean queueBlockBreakEffect(Platform server, Vector position, int blockId, double priority);
@Override
boolean equals(Object other);

View File

@ -123,7 +123,7 @@ public class SnapshotRestore {
}
private void checkAndAddBlock(Vector pos) {
if (editSession.getMask() != null && !editSession.getMask().matches(editSession, pos))
if (editSession.getMask() != null && !editSession.getMask().test(pos))
return;
BlockVector2D chunkPos = ChunkStore.toChunk(pos);