use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class PlatformManager method handleBlockInteract.
@Subscribe
public void handleBlockInteract(BlockInteractEvent event) {
// Create a proxy actor with a potentially different world for
// making changes to the world
Actor actor = createProxyActor(event.getCause());
Location location = event.getLocation();
// At this time, only handle interaction from players
if (!(actor instanceof Player)) {
return;
}
Player player = (Player) actor;
LocalSession session = worldEdit.getSessionManager().get(actor);
Request.reset();
Request.request().setSession(session);
Request.request().setWorld(player.getWorld());
try {
if (event.getType() == Interaction.HIT) {
// in addition, it is implicitly bound to all pickaxe items, not just a single tool item
if (session.hasSuperPickAxe() && player.isHoldingPickAxe()) {
final BlockTool superPickaxe = session.getSuperPickaxe();
if (superPickaxe != null && superPickaxe.canUse(player)) {
// FAWE start - run async
player.runAction(() -> reset(superPickaxe).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location, event.getFace()), false, true);
// FAWE end
event.setCancelled(true);
return;
}
}
Tool tool = session.getTool(player);
if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) {
// FAWE start - run async
player.runAction(() -> reset((DoubleActionBlockTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location, event.getFace()), false, true);
// FAWE end
event.setCancelled(true);
}
} else if (event.getType() == Interaction.OPEN) {
// FAWE start - get general tool over item in main hand & run async
Tool tool = session.getTool(player);
if (tool instanceof BlockTool && tool.canUse(player)) {
if (player.checkAction()) {
// FAWE run async
player.runAction(() -> {
BlockTool blockTool = (BlockTool) tool;
if (!(tool instanceof BrushTool)) {
blockTool = reset(blockTool);
}
blockTool.actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location, event.getFace());
}, false, true);
// FAWE end
event.setCancelled(true);
}
}
}
} catch (Throwable e) {
handleThrowable(e, actor);
} finally {
Request.reset();
}
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method setOperationBasedBrush.
// FAWE end
static void setOperationBasedBrush(Player player, LocalSession session, double radius, Contextual<? extends Operation> factory, RegionFactory shape, String permission) throws WorldEditException {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setSize(radius);
tool.setFill(null);
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
player.print(Caption.of("worldedit.brush.operation.equip", TextComponent.of(factory.toString())));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method setOperationBasedBrush.
// FAWE end
static void setOperationBasedBrush(Player player, LocalSession session, // FAWE start - Expression > double
Expression radius, // FAWE end
Contextual<? extends Operation> factory, RegionFactory shape, String permission) throws WorldEditException {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setSize(radius);
tool.setFill(null);
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
player.print(Caption.of("worldedit.brush.operation.equip", TextComponent.of(factory.toString())));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class ScrollTargetOffset method increment.
@Override
public boolean increment(Player player, int amount) {
BrushTool tool = getTool();
tool.setTargetOffset(tool.getTargetOffset() + amount);
return true;
}
use of com.sk89q.worldedit.command.tool.BrushTool in project FastAsyncWorldEdit by IntellectualSites.
the class BrushCommands method process.
// FAWE start
public BrushSettings process(Player player, Arguments arguments, BrushSettings settings) throws WorldEditException {
LocalSession session = worldEdit.getSessionManager().get(player);
session.setTool(player, null);
BrushTool tool = session.getBrushTool(player);
if (tool != null) {
tool.setPrimary(settings);
tool.setSecondary(settings);
player.print(Caption.of("fawe.worldedit.brush.brush.equipped", arguments.get().split(" ")[1]));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}
return settings;
}
Aggregations