Java Code Examples for org.spongepowered.api.event.Order#PRE

The following examples show how to use org.spongepowered.api.event.Order#PRE . 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: HuskyUI.java    From HuskyUI-Plugin with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Handle inventory clicks
 * @param event clickinvevent
 */
@Listener(order = Order.PRE)
public void onItemClick(ClickInventoryEvent event){
    try {
        if (event instanceof ClickInventoryEvent.Primary ||
                event instanceof ClickInventoryEvent.Secondary ||
                event instanceof ClickInventoryEvent.Shift ||
                event instanceof ClickInventoryEvent.Creative) {

            ItemStack affected;
            affected = event.getTransactions().get(0).getOriginal().createStack();
            if (event instanceof ClickInventoryEvent.Shift && (affected.getType() == ItemTypes.AIR || affected.getType() == ItemTypes.NONE)) {
                affected = event.getTransactions().get(0).getDefault().createStack();
            }
            Optional<Integer> potentialID = registry.getElementIDFromItemStack(affected);
            if (potentialID.isPresent()) {
                if (registry.elementExists(potentialID.get())) {
                    if (registry.isElementAuto(potentialID.get())) {
                        if (event.getTransactions().get(0).getSlot().parent().getArchetype().equals(InventoryArchetypes.PLAYER)) {
                            if (registry.isElementFixedAuto(potentialID.get())) {
                                event.setCancelled(true);
                            }
                        } else {
                            event.setCancelled(true);
                        }
                    }
                }
            }
        }
    }catch(Exception ignored){}
}
 
Example 2
Source File: SpongeServerShutdownSave.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Listener(order = Order.PRE)
public void onServerShutdown(GameStoppingServerEvent event) {
    GameState state = event.getState();
    shuttingDown = state == GameState.SERVER_STOPPING
            || state == GameState.GAME_STOPPING
            || state == GameState.SERVER_STOPPED
            || state == GameState.GAME_STOPPED;
}
 
Example 3
Source File: ChatUILib.java    From ChatUI with MIT License 5 votes vote down vote up
@Listener(order = Order.PRE, beforeModifications = true)
@IsCancelled(Tristate.UNDEFINED)
public void onIncomingMessage(MessageChannelEvent.Chat event, @Root Player player) {
    if (getView(player).handleIncoming(event.getRawMessage())) {
        // No plugins should interpret this as chat
        event.setCancelled(true);
        event.setChannel(MessageChannel.TO_NONE);
    }
}
 
Example 4
Source File: WebHookService.java    From Web-API with MIT License 5 votes vote down vote up
@Listener(order = Order.PRE)
public void onEntityDespawn(DestructEntityEvent event) {
    Entity ent = event.getTargetEntity();
    if (ent instanceof Player) {
        notifyHooks(WebHookService.WebHookType.PLAYER_DEATH, event);
    } else {
        notifyHooks(WebHookService.WebHookType.ENTITY_DESPAWN, event);
    }
}
 
Example 5
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onServerStop(GameStoppingEvent event) {
    notifyHooks(WebHookService.WebHookType.SERVER_STOP, event);
}
 
Example 6
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onPlayerLeave(ClientConnectionEvent.Disconnect event) {
    notifyHooks(WebHookService.WebHookType.PLAYER_LEAVE, event);
}
 
Example 7
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onUserKick(KickPlayerEvent event) {
    notifyHooks(WebHookService.WebHookType.PLAYER_KICK, event);
}
 
Example 8
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onUserBan(BanUserEvent event) {
    notifyHooks(WebHookService.WebHookType.PLAYER_BAN, event);
}
 
Example 9
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onEntityExpire(ExpireEntityEvent event) {
    notifyHooks(WebHookService.WebHookType.ENTITY_EXPIRE, event);
}
 
Example 10
Source File: SpongeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onGamePreInit(GamePreInitializationEvent event) {
    this.server = this.game.getServer();
    new FaweSponge(this);
    Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}
 
Example 11
Source File: SpongeMain.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
@Listener(order = Order.PRE)
public void onGamePreInit(GamePreInitializationEvent event) {
    this.server = this.game.getServer();
    new FaweSponge(this);
    Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}