Allow binding by data

This commit is contained in:
Jesse Boyd 2017-03-05 15:46:48 +11:00
parent c10520c010
commit 0775b55fbb
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
7 changed files with 88 additions and 67 deletions

View File

@ -84,8 +84,7 @@ public class BrushListener implements Listener {
FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer);
com.sk89q.worldedit.entity.Player player = fp.getPlayer(); com.sk89q.worldedit.entity.Player player = fp.getPlayer();
LocalSession session = fp.getSession(); LocalSession session = fp.getSession();
int item = player.getItemInHand(); Tool tool = session.getTool(player);
Tool tool = session.getTool(item);
if (tool instanceof ResettableTool) { if (tool instanceof ResettableTool) {
if (((ResettableTool) tool).reset()) { if (((ResettableTool) tool).reset()) {
event.setCancelled(true); event.setCancelled(true);

View File

@ -32,7 +32,7 @@ public class VisualQueue {
iter.remove(); iter.remove();
LocalSession session = fp.getSession(); LocalSession session = fp.getSession();
Player player = fp.getPlayer(); Player player = fp.getPlayer();
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
Brush brush; Brush brush;
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
BrushTool brushTool = (BrushTool) tool; BrushTool brushTool = (BrushTool) tool;

View File

@ -37,6 +37,7 @@ import com.sk89q.jchronic.Chronic;
import com.sk89q.jchronic.Options; import com.sk89q.jchronic.Options;
import com.sk89q.jchronic.utils.Span; import com.sk89q.jchronic.utils.Span;
import com.sk89q.jchronic.utils.Time; import com.sk89q.jchronic.utils.Time;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.command.tool.BlockTool; import com.sk89q.worldedit.command.tool.BlockTool;
import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.InvalidToolBindException; import com.sk89q.worldedit.command.tool.InvalidToolBindException;
@ -959,7 +960,7 @@ public class LocalSession {
@Deprecated @Deprecated
@Nullable @Nullable
public Tool getTool(int item) { public Tool getTool(int item) {
return tools.get(FaweCache.getCombined(item, 0)); return getTool(item, 0);
} }
@Nullable @Nullable
@ -972,7 +973,13 @@ public class LocalSession {
if (tools.isEmpty()) { if (tools.isEmpty()) {
return null; return null;
} }
return getTool(player.getItemInHand()); try {
BaseBlock block = player.getBlockInHand();
return getTool(block.getId(), block.getType());
} catch (WorldEditException e) {
e.printStackTrace();
return null;
}
} }
/** /**
@ -985,20 +992,32 @@ public class LocalSession {
* @throws InvalidToolBindException if the item can't be bound to that item * @throws InvalidToolBindException if the item can't be bound to that item
*/ */
public BrushTool getBrushTool(int item) throws InvalidToolBindException { public BrushTool getBrushTool(int item) throws InvalidToolBindException {
return getBrushTool(item, null); return getBrushTool(item, 0, null, true);
} }
public BrushTool getBrushTool(int item, Player player) throws InvalidToolBindException { public BrushTool getBrushTool(Player player) throws InvalidToolBindException {
return getBrushTool(item, player, true); return getBrushTool(player, true);
} }
public BrushTool getBrushTool(int item, Player player, boolean create) throws InvalidToolBindException { public BrushTool getBrushTool(Player player, boolean create) throws InvalidToolBindException {
Tool tool = getTool(item); BaseBlock block;
try {
block = player.getBlockInHand();
} catch (WorldEditException e) {
e.printStackTrace();
block = EditSession.nullBlock;
}
return getBrushTool(block.getId(), block.getData(), player, create);
}
public BrushTool getBrushTool(int id, int data, Player player, boolean create) throws InvalidToolBindException {
Tool tool = getTool(id, data);
if ((tool == null || !(tool instanceof BrushTool))) { if ((tool == null || !(tool instanceof BrushTool))) {
if (create) { if (create) {
tool = new BrushTool("worldedit.brush.sphere"); tool = new BrushTool("worldedit.brush.sphere");
setTool(item, tool, player); setTool(id, data, tool, player);
} else { } else {
return null; return null;
} }
@ -1016,12 +1035,18 @@ public class LocalSession {
*/ */
@Deprecated @Deprecated
public void setTool(int item, @Nullable Tool tool) throws InvalidToolBindException { public void setTool(int item, @Nullable Tool tool) throws InvalidToolBindException {
setTool(item, tool, null); setTool(item, 0, tool, null);
} }
@Deprecated public void setTool(@Nullable Tool tool, Player player) throws InvalidToolBindException {
public void setTool(int item, @Nullable Tool tool, Player player) throws InvalidToolBindException { BaseBlock item;
setTool(item, 0, tool, player); try {
item = player.getBlockInHand();
} catch (WorldEditException e) {
item = EditSession.nullBlock;
e.printStackTrace();
}
setTool(item.getId(), item.getData(), tool, player);
} }
public void setTool(int id, int data, @Nullable Tool tool, Player player) throws InvalidToolBindException { public void setTool(int id, int data, @Nullable Tool tool, Player player) throws InvalidToolBindException {

View File

@ -128,13 +128,13 @@ public class BrushCommands {
min = 1 min = 1
) )
public void primary(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void primary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
int item = player.getItemInHand(); BaseBlock item = player.getBlockInHand();
BrushTool tool = session.getBrushTool(item, player, false); BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null); session.setTool(item.getId(), item.getData(), null, player);
String cmd = "brush " + args.getJoinedStrings(0); String cmd = "brush " + args.getJoinedStrings(0);
CommandEvent event = new CommandEvent(player, cmd); CommandEvent event = new CommandEvent(player, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event); CommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false); BrushTool newTool = session.getBrushTool(item.getId(), item.getData(), player, false);
if (newTool != null && tool != null) { if (newTool != null && tool != null) {
newTool.setSecondary(tool.getSecondary()); newTool.setSecondary(tool.getSecondary());
} }
@ -148,13 +148,13 @@ public class BrushCommands {
min = 1 min = 1
) )
public void secondary(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void secondary(Player player, LocalSession session, CommandContext args) throws WorldEditException {
int item = player.getItemInHand(); BaseBlock item = player.getBlockInHand();
BrushTool tool = session.getBrushTool(item, player, false); BrushTool tool = session.getBrushTool(player, false);
session.setTool(item, null); session.setTool(item.getId(), item.getData(), null, player);
String cmd = "brush " + args.getJoinedStrings(0); String cmd = "brush " + args.getJoinedStrings(0);
CommandEvent event = new CommandEvent(player, cmd); CommandEvent event = new CommandEvent(player, cmd);
CommandManager.getInstance().handleCommandOnCurrentThread(event); CommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item, player, false); BrushTool newTool = session.getBrushTool(item.getId(), item.getData(), player, false);
if (newTool != null && tool != null) { if (newTool != null && tool != null) {
newTool.setPrimary(tool.getPrimary()); newTool.setPrimary(tool.getPrimary());
} }
@ -168,8 +168,7 @@ public class BrushCommands {
max = 1 max = 1
) )
public void visual(Player player, LocalSession session, @Optional("0") int mode) throws WorldEditException { public void visual(Player player, LocalSession session, @Optional("0") int mode) throws WorldEditException {
int item = player.getItemInHand(); BrushTool tool = session.getBrushTool(player, false);
BrushTool tool = session.getBrushTool(item, player, false);
if (tool == null) { if (tool == null) {
BBC.BRUSH_NONE.send(player); BBC.BRUSH_NONE.send(player);
return; return;
@ -188,8 +187,7 @@ public class BrushCommands {
max = 1 max = 1
) )
public void target(Player player, LocalSession session, @Optional("0") int mode) throws WorldEditException { public void target(Player player, LocalSession session, @Optional("0") int mode) throws WorldEditException {
int item = player.getItemInHand(); BrushTool tool = session.getBrushTool(player, false);
BrushTool tool = session.getBrushTool(item, player, false);
if (tool == null) { if (tool == null) {
BBC.BRUSH_NONE.send(player); BBC.BRUSH_NONE.send(player);
return; return;
@ -209,8 +207,7 @@ public class BrushCommands {
max = -1 max = -1
) )
public void scroll(Player player, EditSession editSession, LocalSession session, CommandContext args) throws WorldEditException { public void scroll(Player player, EditSession editSession, LocalSession session, CommandContext args) throws WorldEditException {
int item = player.getItemInHand(); BrushTool tool = session.getBrushTool(player, false);
BrushTool tool = session.getBrushTool(item, player, false);
if (tool == null) { if (tool == null) {
BBC.BRUSH_NONE.send(player); BBC.BRUSH_NONE.send(player);
return; return;
@ -352,7 +349,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.blendball") @CommandPermissions("worldedit.brush.blendball")
public void blendBallBrush(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException { public void blendBallBrush(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new BlendBall(), "worldedit.brush.blendball", player); tool.setBrush(new BlendBall(), "worldedit.brush.blendball", player);
player.print(BBC.getPrefix() + BBC.BRUSH_BLEND_BALL.f(radius)); player.print(BBC.getPrefix() + BBC.BRUSH_BLEND_BALL.f(radius));
@ -369,7 +366,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.erode") @CommandPermissions("worldedit.brush.erode")
public void erodeBrush(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException { public void erodeBrush(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new ErodeBrush(), "worldedit.brush.erode", player); tool.setBrush(new ErodeBrush(), "worldedit.brush.erode", player);
player.print(BBC.getPrefix() + BBC.BRUSH_ERODE.f(radius)); player.print(BBC.getPrefix() + BBC.BRUSH_ERODE.f(radius));
@ -386,7 +383,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.pull") @CommandPermissions("worldedit.brush.pull")
public void pullBrush(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException { public void pullBrush(Player player, LocalSession session, @Optional("5") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new RaiseBrush(), "worldedit.brush.pull", player); tool.setBrush(new RaiseBrush(), "worldedit.brush.pull", player);
player.print(BBC.getPrefix() + BBC.BRUSH_ERODE.f(radius)); player.print(BBC.getPrefix() + BBC.BRUSH_ERODE.f(radius));
@ -403,7 +400,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.sphere") @CommandPermissions("worldedit.brush.sphere")
public void circleBrush(Player player, LocalSession session, Pattern fill, @Optional("5") double radius) throws WorldEditException { public void circleBrush(Player player, LocalSession session, Pattern fill, @Optional("5") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setFill(fill); tool.setFill(fill);
tool.setBrush(new CircleBrush(tool, player), "worldedit.brush.circle", player); tool.setBrush(new CircleBrush(tool, player), "worldedit.brush.circle", player);
@ -422,7 +419,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.recursive") @CommandPermissions("worldedit.brush.recursive")
public void recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, @Optional("2") double radius, @Switch('d') boolean depthFirst) throws WorldEditException { public void recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill, @Optional("2") double radius, @Switch('d') boolean depthFirst) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new RecurseBrush(tool, depthFirst), "worldedit.brush.recursive", player); tool.setBrush(new RecurseBrush(tool, depthFirst), "worldedit.brush.recursive", player);
tool.setMask(new IdMask(editSession)); tool.setMask(new IdMask(editSession));
@ -446,7 +443,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.line") @CommandPermissions("worldedit.brush.line")
public void lineBrush(Player player, LocalSession session, Pattern fill, @Optional("0") double radius, @Switch('h') boolean shell, @Switch('s') boolean select, @Switch('f') boolean flat) throws WorldEditException { public void lineBrush(Player player, LocalSession session, Pattern fill, @Optional("0") double radius, @Switch('h') boolean shell, @Switch('s') boolean select, @Switch('f') boolean flat) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new LineBrush(shell, select, flat), "worldedit.brush.line", player); tool.setBrush(new LineBrush(shell, select, flat), "worldedit.brush.line", player);
@ -464,7 +461,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.spline") @CommandPermissions("worldedit.brush.spline")
public void splineBrush(Player player, LocalSession session, Pattern fill, @Optional("25") double radius) throws WorldEditException { public void splineBrush(Player player, LocalSession session, Pattern fill, @Optional("25") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new SplineBrush(player, session, tool), "worldedit.brush.spline", player); tool.setBrush(new SplineBrush(player, session, tool), "worldedit.brush.spline", player);
@ -486,7 +483,7 @@ public class BrushCommands {
public void sphereBrush(Player player, LocalSession session, Pattern fill, @Optional("2") double radius, @Switch('h') boolean hollow) throws WorldEditException { public void sphereBrush(Player player, LocalSession session, Pattern fill, @Optional("2") double radius, @Switch('h') boolean hollow) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
@ -524,7 +521,7 @@ public class BrushCommands {
// public void testBrush(Player player, LocalSession session, Pattern fill, @Optional("10") double radius, @Optional("10") int count, @Optional("10") int distance) throws WorldEditException { // public void testBrush(Player player, LocalSession session, Pattern fill, @Optional("10") double radius, @Optional("10") int count, @Optional("10") int distance) throws WorldEditException {
// worldEdit.checkMaxBrushRadius(radius); // worldEdit.checkMaxBrushRadius(radius);
// //
// BrushTool tool = session.getBrushTool(player.getItemInHand(), player); // BrushTool tool = session.getBrushTool(player);
// tool.setFill(fill); // tool.setFill(fill);
// tool.setSize(radius); // tool.setSize(radius);
// tool.setBrush(new Test(count), "worldedit.brush.test"); // tool.setBrush(new Test(count), "worldedit.brush.test");
@ -548,7 +545,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
worldEdit.checkMaxBrushRadius(height); worldEdit.checkMaxBrushRadius(height);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
@ -582,7 +579,7 @@ public class BrushCommands {
worldEdit.checkMaxBrushRadius(size.getBlockY()); worldEdit.checkMaxBrushRadius(size.getBlockY());
worldEdit.checkMaxBrushRadius(size.getBlockZ()); worldEdit.checkMaxBrushRadius(size.getBlockZ());
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin), "worldedit.brush.clipboard", player); tool.setBrush(new ClipboardBrush(holder, ignoreAir, usingOrigin), "worldedit.brush.clipboard", player);
player.print(BBC.getPrefix() + BBC.BRUSH_CLIPBOARD.s()); player.print(BBC.getPrefix() + BBC.BRUSH_CLIPBOARD.s());
} }
@ -608,7 +605,7 @@ public class BrushCommands {
FawePlayer fp = FawePlayer.wrap(player); FawePlayer fp = FawePlayer.wrap(player);
FaweLimit limit = Settings.IMP.getLimit(fp); FaweLimit limit = Settings.IMP.getLimit(fp);
iterations = Math.min(limit.MAX_ITERATIONS, iterations); iterations = Math.min(limit.MAX_ITERATIONS, iterations);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new SmoothBrush(iterations, naturalBlocksOnly), "worldedit.brush.smooth", player); tool.setBrush(new SmoothBrush(iterations, naturalBlocksOnly), "worldedit.brush.smooth", player);
@ -626,7 +623,7 @@ public class BrushCommands {
public void extinguishBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius) throws WorldEditException { public void extinguishBrush(Player player, LocalSession session, EditSession editSession, @Optional("5") double radius) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
Pattern fill = new BlockPattern(new BaseBlock(0)); Pattern fill = new BlockPattern(new BaseBlock(0));
tool.setFill(fill); tool.setFill(fill);
tool.setSize(radius); tool.setSize(radius);
@ -652,7 +649,7 @@ public class BrushCommands {
public void gravityBrush(Player player, LocalSession session, @Optional("5") double radius, @Switch('h') boolean fromMaxY) throws WorldEditException { public void gravityBrush(Player player, LocalSession session, @Optional("5") double radius, @Switch('h') boolean fromMaxY) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new GravityBrush(fromMaxY, tool), "worldedit.brush.gravity", player); tool.setBrush(new GravityBrush(fromMaxY, tool), "worldedit.brush.gravity", player);
player.print(BBC.getPrefix() + BBC.BRUSH_GRAVITY.f(radius)); player.print(BBC.getPrefix() + BBC.BRUSH_GRAVITY.f(radius));
@ -734,7 +731,7 @@ public class BrushCommands {
} }
} }
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
if (flat) { if (flat) {
try { try {
@ -768,7 +765,7 @@ public class BrushCommands {
@CommandPermissions("worldedit.brush.copy") @CommandPermissions("worldedit.brush.copy")
public void copy(Player player, LocalSession session, @Optional("5") double radius, @Switch('r') boolean rotate) throws WorldEditException { public void copy(Player player, LocalSession session, @Optional("5") double radius, @Switch('r') boolean rotate) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius); worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new CopyPastaBrush(tool, session, rotate), "worldedit.brush.copy", player); tool.setBrush(new CopyPastaBrush(tool, session, rotate), "worldedit.brush.copy", player);
player.print(BBC.getPrefix() + BBC.BRUSH_COPY.f(radius)); player.print(BBC.getPrefix() + BBC.BRUSH_COPY.f(radius));
@ -785,7 +782,7 @@ public class BrushCommands {
) )
@CommandPermissions("worldedit.brush.command") @CommandPermissions("worldedit.brush.command")
public void command(Player player, LocalSession session, @Optional("5") double radius, CommandContext args) throws WorldEditException { public void command(Player player, LocalSession session, @Optional("5") double radius, CommandContext args) throws WorldEditException {
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
String cmd = args.getJoinedStrings(1); String cmd = args.getJoinedStrings(1);
tool.setBrush(new CommandBrush(tool, cmd, radius), "worldedit.brush.copy", player); tool.setBrush(new CommandBrush(tool, cmd, radius), "worldedit.brush.copy", player);
player.print(BBC.getPrefix() + BBC.BRUSH_COMMAND.f(cmd)); player.print(BBC.getPrefix() + BBC.BRUSH_COMMAND.f(cmd));
@ -830,7 +827,7 @@ public class BrushCommands {
CreatureButcher flags = new CreatureButcher(player); CreatureButcher flags = new CreatureButcher(player);
flags.fromCommand(args); flags.fromCommand(args);
BrushTool tool = session.getBrushTool(player.getItemInHand(), player); BrushTool tool = session.getBrushTool(player);
tool.setSize(radius); tool.setSize(radius);
tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher", player); tool.setBrush(new ButcherBrush(flags), "worldedit.brush.butcher", player);
player.print(BBC.getPrefix() + BBC.BRUSH_BUTCHER.f(radius)); player.print(BBC.getPrefix() + BBC.BRUSH_BUTCHER.f(radius));

View File

@ -61,7 +61,7 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.tool.inspect") @CommandPermissions("worldedit.tool.inspect")
public void inspectBrush(Player player, LocalSession session, @Optional("1") double radius) throws WorldEditException { public void inspectBrush(Player player, LocalSession session, @Optional("1") double radius) throws WorldEditException {
session.setTool(player.getItemInHand(), new InspectBrush(), player); session.setTool(new InspectBrush(), player);
BBC.TOOL_INSPECT.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_INSPECT.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -73,7 +73,7 @@ public class ToolCommands {
max = 0 max = 0
) )
public void none(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void none(Player player, LocalSession session, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), null, player); session.setTool(null, player);
BBC.TOOL_NONE.send(player); BBC.TOOL_NONE.send(player);
} }
@ -86,7 +86,7 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.tool.info") @CommandPermissions("worldedit.tool.info")
public void info(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void info(Player player, LocalSession session, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new QueryTool(), player); session.setTool(new QueryTool(), player);
BBC.TOOL_INFO.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_INFO.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -110,7 +110,7 @@ public class ToolCommands {
return; return;
} }
session.setTool(player.getItemInHand(), new TreePlanter(new TreeGenerator(type)), player); session.setTool(new TreePlanter(new TreeGenerator(type)), player);
BBC.TOOL_TREE.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_TREE.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -124,7 +124,7 @@ public class ToolCommands {
@CommandPermissions("worldedit.tool.replacer") @CommandPermissions("worldedit.tool.replacer")
public void repl(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void repl(Player player, LocalSession session, CommandContext args) throws WorldEditException {
BaseBlock targetBlock = we.getBlock(player, args.getString(0)); BaseBlock targetBlock = we.getBlock(player, args.getString(0));
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock), player); session.setTool(new BlockReplacer(targetBlock), player);
BBC.TOOL_REPL.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_REPL.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -138,7 +138,7 @@ public class ToolCommands {
@CommandPermissions("worldedit.tool.data-cycler") @CommandPermissions("worldedit.tool.data-cycler")
public void cycler(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void cycler(Player player, LocalSession session, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new BlockDataCyler(), player); session.setTool(new BlockDataCyler(), player);
BBC.TOOL_CYCLER.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_CYCLER.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -160,7 +160,7 @@ public class ToolCommands {
} }
Pattern pattern = we.getBlockPattern(player, args.getString(0)); Pattern pattern = we.getBlockPattern(player, args.getString(0));
session.setTool(player.getItemInHand(), new FloodFillTool(range, pattern), player); session.setTool(new FloodFillTool(range, pattern), player);
BBC.TOOL_FLOOD_FILL.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_FLOOD_FILL.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -173,7 +173,7 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.tool.deltree") @CommandPermissions("worldedit.tool.deltree")
public void deltree(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void deltree(Player player, LocalSession session, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new FloatingTreeRemover(), player); session.setTool(new FloatingTreeRemover(), player);
BBC.TOOL_DELTREE.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_DELTREE.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -186,7 +186,7 @@ public class ToolCommands {
) )
@CommandPermissions("worldedit.tool.farwand") @CommandPermissions("worldedit.tool.farwand")
public void farwand(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void farwand(Player player, LocalSession session, CommandContext args) throws WorldEditException {
session.setTool(player.getItemInHand(), new DistanceWand(), player); session.setTool(new DistanceWand(), player);
BBC.TOOL_FARWAND.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_FARWAND.send(player, ItemType.toHeldName(player.getItemInHand()));
} }
@ -202,7 +202,7 @@ public class ToolCommands {
BaseBlock secondary = we.getBlock(player, args.getString(0)); BaseBlock secondary = we.getBlock(player, args.getString(0));
BaseBlock primary = we.getBlock(player, args.getString(1)); BaseBlock primary = we.getBlock(player, args.getString(1));
session.setTool(player.getItemInHand(), new LongRangeBuildTool(primary, secondary), player); session.setTool(new LongRangeBuildTool(primary, secondary), player);
BBC.TOOL_LRBUILD_BOUND.send(player, ItemType.toHeldName(player.getItemInHand())); BBC.TOOL_LRBUILD_BOUND.send(player, ItemType.toHeldName(player.getItemInHand()));
BBC.TOOL_LRBUILD_INFO.send(player, ItemType.toName(secondary.getType()), ItemType.toName(primary.getType())); BBC.TOOL_LRBUILD_INFO.send(player, ItemType.toName(secondary.getType()), ItemType.toName(primary.getType()));
} }

View File

@ -69,7 +69,7 @@ public class ToolUtilCommands {
) )
@CommandPermissions("worldedit.brush.options.mask") @CommandPermissions("worldedit.brush.options.mask")
public void mask(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context, @Switch('h') boolean offHand) throws WorldEditException { public void mask(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context, @Switch('h') boolean offHand) throws WorldEditException {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f());
return; return;
@ -109,7 +109,7 @@ public class ToolUtilCommands {
) )
@CommandPermissions("worldedit.brush.options.mask") @CommandPermissions("worldedit.brush.options.mask")
public void smask(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context, @Switch('h') boolean offHand) throws WorldEditException { public void smask(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context, @Switch('h') boolean offHand) throws WorldEditException {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
if (tool == null) { if (tool == null) {
player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f()); player.print(BBC.getPrefix() + BBC.BRUSH_NONE.f());
return; return;
@ -149,7 +149,7 @@ public class ToolUtilCommands {
) )
@CommandPermissions("worldedit.brush.options.transform") @CommandPermissions("worldedit.brush.options.transform")
public void transform(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context, @Switch('h') boolean offHand) throws WorldEditException { public void transform(Player player, LocalSession session, EditSession editSession, @Optional CommandContext context, @Switch('h') boolean offHand) throws WorldEditException {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
if (tool == null) { if (tool == null) {
return; return;
} }
@ -188,7 +188,7 @@ public class ToolUtilCommands {
) )
@CommandPermissions("worldedit.brush.options.material") @CommandPermissions("worldedit.brush.options.material")
public void material(Player player, LocalSession session, Pattern pattern, @Switch('h') boolean offHand) throws WorldEditException { public void material(Player player, LocalSession session, Pattern pattern, @Switch('h') boolean offHand) throws WorldEditException {
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
BrushTool bt = (BrushTool) tool; BrushTool bt = (BrushTool) tool;
if (offHand) { if (offHand) {
@ -210,7 +210,7 @@ public class ToolUtilCommands {
@CommandPermissions("worldedit.brush.options.range") @CommandPermissions("worldedit.brush.options.range")
public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException { public void range(Player player, LocalSession session, CommandContext args) throws WorldEditException {
int range = Math.max(0, Math.min(256, args.getInteger(0))); int range = Math.max(0, Math.min(256, args.getInteger(0)));
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
BrushTool bt = (BrushTool) tool; BrushTool bt = (BrushTool) tool;
((BrushTool) tool).setRange(range); ((BrushTool) tool).setRange(range);
@ -231,7 +231,7 @@ public class ToolUtilCommands {
int radius = args.getInteger(0); int radius = args.getInteger(0);
we.checkMaxBrushRadius(radius); we.checkMaxBrushRadius(radius);
Tool tool = session.getTool(player.getItemInHand()); Tool tool = session.getTool(player);
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {
BrushTool bt = (BrushTool) tool; BrushTool bt = (BrushTool) tool;
if (offHand) { if (offHand) {

View File

@ -394,7 +394,7 @@ public class PlatformManager {
return; return;
} }
} }
final Tool tool = session.getTool(player.getItemInHand()); final Tool tool = session.getTool(player);
if (tool != null && tool instanceof DoubleActionBlockTool) { if (tool != null && tool instanceof DoubleActionBlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);
@ -431,7 +431,7 @@ public class PlatformManager {
return; return;
} }
final Tool tool = session.getTool(player.getItemInHand()); final Tool tool = session.getTool(player);
if (tool != null && tool instanceof BlockTool) { if (tool != null && tool instanceof BlockTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);
@ -495,7 +495,7 @@ public class PlatformManager {
final LocalSession session = worldEdit.getSessionManager().get(player); final LocalSession session = worldEdit.getSessionManager().get(player);
final Tool tool = session.getTool(player.getItemInHand()); final Tool tool = session.getTool(player);
if (tool != null && tool instanceof DoubleActionTraceTool) { if (tool != null && tool instanceof DoubleActionTraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);
@ -533,7 +533,7 @@ public class PlatformManager {
final LocalSession session = worldEdit.getSessionManager().get(player); final LocalSession session = worldEdit.getSessionManager().get(player);
final Tool tool = session.getTool(player.getItemInHand()); final Tool tool = session.getTool(player);
if (tool != null && tool instanceof TraceTool) { if (tool != null && tool instanceof TraceTool) {
if (tool.canUse(player)) { if (tool.canUse(player)) {
FawePlayer<?> fp = FawePlayer.wrap(player); FawePlayer<?> fp = FawePlayer.wrap(player);