com.sk89q.worldedit.util.eventbus.Subscribe Java Examples

The following examples show how to use com.sk89q.worldedit.util.eventbus.Subscribe. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldEditHook.java    From Slimefun4 with GNU General Public License v3.0 6 votes vote down vote up
@Subscribe
public void wrapForLogging(EditSessionEvent event) {
    event.setExtent(new AbstractDelegateExtent(event.getExtent()) {

        @Override
        public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
            if (block.getBlockType().getMaterial().isAir()) {
                World world = Bukkit.getWorld(event.getWorld().getName());

                if (world != null) {
                    Location l = new Location(world, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());

                    if (BlockStorage.hasBlockInfo(l)) {
                        BlockStorage.clearBlockInfo(l);
                    }
                }
            }
            
            return getExtent().setBlock(pos, block);
        }

    });
}
 
Example #2
Source File: WorldEditListener.java    From WorldGuardExtraFlagsPlugin with MIT License 5 votes vote down vote up
@Subscribe(priority = EventHandler.Priority.VERY_EARLY)
   public void onEditSessionEvent(EditSessionEvent event)
{
	Actor actor = event.getActor();
	if (actor != null && actor.isPlayer())
	{
		event.setExtent(this.plugin.getWorldGuardCommunicator().getWorldEditFlag(event.getWorld(), event.getExtent(), (Player)actor));
	}
}
 
Example #3
Source File: PlatformManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void handlePlatformReady(PlatformReadyEvent event) {
    choosePreferred();
    if (initialized.compareAndSet(false, true)) {
        worldEdit.getEventBus().post(new PlatformInitializeEvent());
    }
}
 
Example #4
Source File: CommandManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
    public void handleCommand(CommandEvent event) {
        Request.reset();
        Actor actor = event.getActor();
        if (actor instanceof Player) {
            actor = LocationMaskedPlayerWrapper.wrap((Player) actor);
        }
        String args = event.getArguments();
        CommandEvent finalEvent = new CommandEvent(actor, args);
        final FawePlayer<Object> fp = FawePlayer.wrap(actor);
        TaskManager.IMP.taskNow(new Runnable() {
            @Override
            public void run() {
//                int space0 = args.indexOf(' ');
//                String arg0 = space0 == -1 ? args : args.substring(0, space0);
//                CommandMapping cmd = dispatcher.get(arg0);
//                if (cmd != null && cmd.getCallable() instanceof AParametricCallable) {
//                    Command info = ((AParametricCallable) cmd.getCallable()).getDefinition();
//                    if (!info.queued()) {
//                        handleCommandOnCurrentThread(finalEvent);
//                        return;
//                    }
//                }
                if (!fp.runAction(new Runnable() {
                    @Override
                    public void run() {
                        handleCommandOnCurrentThread(finalEvent);
                    }
                }, false, true)) {
                    BBC.WORLDEDIT_COMMAND_LIMIT.send(fp);
                }
                finalEvent.setCancelled(true);
            }
        }, Fawe.isMainThread());
    }
 
Example #5
Source File: CommandManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void handleCommandSuggestion(CommandSuggestionEvent event) {
    try {
        CommandLocals locals = new CommandLocals();
        locals.put(Actor.class, event.getActor());
        event.setSuggestions(dispatcher.getSuggestions(event.getArguments(), locals));
    } catch (CommandException e) {
        event.getActor().printError(e.getMessage());
    }
}
 
Example #6
Source File: SessionManager.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe
public void onConfigurationLoad(ConfigurationLoadEvent event) {
    LocalConfiguration config = event.getConfiguration();
    File dir = new File(config.getWorkingDirectory(), "sessions");
    store = new JsonFileSessionStore(dir);
    this.path = dir;
}
 
Example #7
Source File: PlotWorldEditListener.java    From PlotMe-Core with GNU General Public License v3.0 5 votes vote down vote up
@Subscribe(priority = EventHandler.Priority.VERY_EARLY)
public void worldEditListener(EditSessionEvent event) {
    Actor actor = event.getActor();
    if (event.getWorld() == null) {
        return;
    }
    World world1 = PlotMe_CorePlugin.getInstance().getServer().getWorld(event.getWorld().getName());
    BukkitWorld adapt = BukkitUtil.adapt(world1);
    if (PlotMeCoreManager.getInstance().isPlotWorld(adapt)) {
        if (actor != null && actor.isPlayer()) {
            event.setExtent(new PlotMeWorldEdit(api, event.getExtent(), event.getActor()));
        }
    }
}