use of com.sk89q.worldedit.command.tool.DoubleActionTraceTool in project FastAsyncWorldEdit by IntellectualSites.
the class PlatformManager method handlePlayerInput.
// FAWE end
@Subscribe
public void handlePlayerInput(PlayerInputEvent event) {
// Create a proxy actor with a potentially different world for
// making changes to the world
Player player = createProxyActor(event.getPlayer());
LocalSession session = worldEdit.getSessionManager().get(player);
try {
switch(event.getInputType()) {
case PRIMARY:
{
Tool tool = session.getTool(player);
if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) {
// FAWE start - run async
player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session));
// FAWE end
event.setCancelled(true);
return;
}
break;
}
case SECONDARY:
{
Tool tool = session.getTool(player);
if (tool instanceof TraceTool && tool.canUse(player)) {
// FAWE start - run async
// todo this needs to be fixed so the event is canceled after actPrimary is used and returns true
player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session), false, true);
// FAWE end
event.setCancelled(true);
return;
}
break;
}
}
// FAWE start - add own message
} catch (Throwable e) {
FaweException faweException = FaweException.get(e);
if (faweException != null) {
player.print(Caption.of("fawe.cancel.reason", faweException.getComponent()));
} else {
player.print(Caption.of("worldedit.command.error.report"));
player.print(TextComponent.of(e.getClass().getName() + ": " + e.getMessage()));
e.printStackTrace();
}
// FAWE end
} finally {
Request.reset();
}
}
Aggregations