use of com.sk89q.worldedit.util.eventbus.Subscribe 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.util.eventbus.Subscribe in project BuildSystem by einTosti.
the class EditSessionListener method onEditSession.
@Subscribe
public void onEditSession(EditSessionEvent event) {
Actor actor = event.getActor();
if (actor == null || !actor.isPlayer()) {
return;
}
Player player = Bukkit.getPlayer(actor.getName());
if (player == null) {
return;
}
BuildWorld buildWorld = worldManager.getBuildWorld(player.getWorld().getName());
if (buildWorld == null) {
return;
}
if (event.getStage() == EditSession.Stage.BEFORE_CHANGE) {
disableArchivedWorlds(buildWorld, player, event);
checkBuilders(buildWorld, player, event);
}
}
use of com.sk89q.worldedit.util.eventbus.Subscribe in project ChuoCity by jaoafa.
the class Event_WGNonProtection method onWEEdit.
@Subscribe
public void onWEEdit(EditSessionEvent event) {
if (Main.getWorldGuard() == null) {
return;
}
if (event.getStage() == EditSession.Stage.BEFORE_REORDER) {
return;
}
Actor actor = event.getActor();
if (actor == null || !actor.isPlayer()) {
return;
}
Player player = Bukkit.getPlayer(actor.getUniqueId());
if (player == null) {
return;
}
if (player.hasPermission("worldguard.region.bypass")) {
return;
}
event.setExtent(new AbstractDelegateExtent(event.getExtent()) {
private boolean canBuild(int x, int y, int z) {
LocalPlayer localPlayer = Main.getWorldGuard().wrapPlayer(player);
if (Main.isChuoCity(new Location(player.getWorld(), x, y, z))) {
return true;
}
if (!player.getWorld().getName().equalsIgnoreCase("Jao_Afa")) {
// Jao_Afa以外では適用しない
return true;
}
ProtectedRegion region = Main.getTopRegion(new Location(player.getWorld(), x, y, z));
if (region == null) {
// 誰も保護していない
return false;
}
if (region.isOwner(localPlayer)) {
// オーナー
return true;
}
// メンバー
return region.isMember(localPlayer);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block) throws WorldEditException {
return canBuild(location.getBlockX(), location.getBlockY(), location.getBlockZ()) && super.setBlock(location, block);
}
});
}
use of com.sk89q.worldedit.util.eventbus.Subscribe in project QuickShop-Hikari by Ghost-chu.
the class WorldEditAdapter method proxyEditSession.
@Subscribe(priority = EventHandler.Priority.NORMAL)
public void proxyEditSession(EditSessionEvent event) {
Actor actor = event.getActor();
World world = event.getWorld();
if (actor != null && event.getStage() == EditSession.Stage.BEFORE_CHANGE) {
event.setExtent(new WorldEditBlockListener(actor, world, event.getExtent(), QuickShop.getInstance()));
}
}
use of com.sk89q.worldedit.util.eventbus.Subscribe in project FastAsyncWorldEdit by IntellectualSites.
the class SessionManager method onConfigurationLoad.
@Subscribe
public void onConfigurationLoad(ConfigurationLoadEvent event) {
LocalConfiguration config = event.getConfiguration();
File dir = new File(config.getWorkingDirectoryPath().toFile(), "sessions");
store = new JsonFileSessionStore(dir);
}
Aggregations