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

The following examples show how to use org.spongepowered.api.event.Order#POST . 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: PlayerDisconnectListener.java    From EagleFactions with MIT License 6 votes vote down vote up
@Listener(order = Order.POST)
public void onDisconnect(ClientConnectionEvent.Disconnect event, @Root Player player)
{
    if (super.getPlugin().getPVPLogger().isActive() && EagleFactionsPlugin.getPlugin().getPVPLogger().isPlayerBlocked(player))
    {
        player.damage(1000, DamageSource.builder().type(DamageTypes.ATTACK).build());
        super.getPlugin().getPVPLogger().removePlayer(player);
    }

    EagleFactionsPlugin.REGEN_CONFIRMATION_MAP.remove(player.getUniqueId());

    final Optional<Faction> optionalFaction = getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId());
    optionalFaction.ifPresent(faction -> getPlugin().getFactionLogic().setLastOnline(faction, Instant.now()));

    //TODO: Unload player cache...
    FactionsCache.removePlayer(player.getUniqueId());
}
 
Example 2
Source File: UCListener.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
@Listener(order = Order.POST)
public void onCommand(SendCommandEvent e, @First CommandSource p) {
    // Deny command if muted
    if (p instanceof Player && UChat.get().mutes.contains(p.getName()) &&
            UChat.get().getConfig().root().general.muted_deny_cmds.contains(e.getCommand())) {
        UChat.get().getLang().sendMessage(p, "player.muted.denycmd");
        e.setCancelled(true);
        return;
    }

    if (UChat.get().getUCJDA() != null) {
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
        Task.builder().async().execute(() -> UChat.get().getUCJDA().sendCommandsToDiscord(UChat.get().getLang().get("discord.command")
                .replace("{player}", p.getName())
                .replace("{cmd}", "/" + e.getCommand() + " " + e.getArguments())
                .replace("{time-now}", sdf.format(cal.getTime()))));
    }
}
 
Example 3
Source File: EventForwarder.java    From BlueMap with MIT License 5 votes vote down vote up
@Listener(order = Order.POST)
@Exclude({ChangeBlockEvent.Post.class, ChangeBlockEvent.Pre.class, ChangeBlockEvent.Modify.class})
public void onBlockChange(ChangeBlockEvent evt) {
	for (Transaction<BlockSnapshot> tr : evt.getTransactions()) {
		if(!tr.isValid()) continue;
		
		Optional<Location<org.spongepowered.api.world.World>> ow = tr.getFinal().getLocation();
		if (ow.isPresent()) {
			listener.onBlockChange(ow.get().getExtent().getUniqueId(), ow.get().getPosition().toInt());
		}
	}
}
 
Example 4
Source File: SpongeWorldChangeListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Listener(order = Order.POST)
public void onWorldChange(MoveEntityEvent.Teleport event, @First Player player) {
    if (event.isCancelled()) {
        return;
    }

    try {
        actOnEvent(event, player);
    } catch (Exception e) {
        errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
    }
}
 
Example 5
Source File: PlayerOnlineListener.java    From Plan with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Listener(order = Order.POST)
public void onQuit(ClientConnectionEvent.Disconnect event) {
    try {
        actOnQuitEvent(event);
    } catch (Exception e) {
        errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build());
    }
}
 
Example 6
Source File: InventoryListener.java    From Prism with MIT License 5 votes vote down vote up
/**
 * Saves event records when a player drops an item on to the ground.
 *
 * @param event  DropItemEvent.Dispense
 * @param player Player
 */
@Listener(order = Order.POST)
public void onDropItemDispense(DropItemEvent.Dispense event, @Root Player player) {
    if (event.getEntities().isEmpty() || !Prism.getInstance().getConfig().getEventCategory().isItemDrop()) {
        return;
    }

    for (Entity entity : event.getEntities()) {
        if (!(entity instanceof Item)) {
            continue;
        }

        Item item = (Item) entity;
        if (!item.item().exists()) {
            continue;
        }

        ItemStackSnapshot itemStack = item.item().get();
        Prism.getInstance().getLogger().debug("Inventory dropped - {} x{}", itemStack.getType().getId(), itemStack.getQuantity());

        PrismRecord.create()
                .source(event.getCause())
                .event(PrismEvents.ITEM_DROP)
                .itemStack(itemStack)
                .location(player.getLocation())
                .buildAndSave();
    }
}
 
Example 7
Source File: EntityListener.java    From Prism with MIT License 5 votes vote down vote up
/**
 * Saves event records when an entity dies.
 *
 * @param event DestructEntityEvent.Death
 */
@Listener(order = Order.POST)
public void onDestructEntityDeath(DestructEntityEvent.Death event, @Getter("getTargetEntity") Entity entity) {
    if (!Prism.getInstance().getConfig().getEventCategory().isEntityDeath()) {
        return;
    }

    PrismRecord.create()
            .source(event.getCause())
            .event(PrismEvents.ENTITY_DEATH)
            .entity(event.getTargetEntity())
            .buildAndSave();
}
 
Example 8
Source File: PlayerDeathListener.java    From EagleFactions with MIT License 5 votes vote down vote up
@Listener(order = Order.POST)
public void onPlayerDeath(final DestructEntityEvent.Death event, final @Getter("getTargetEntity") Player player)
{
    CompletableFuture.runAsync(() -> super.getPlugin().getPowerManager().decreasePower(player.getUniqueId()))
            .thenRun(() -> player.sendMessage(Text.of(PluginInfo.PLUGIN_PREFIX, MessageLoader.parseMessage(Messages.YOUR_POWER_HAS_BEEN_DECREASED_BY, TextColors.RESET, ImmutableMap.of(Placeholders.NUMBER, Text.of(TextColors.GOLD, this.powerConfig.getPowerDecrement()))), "\n",
            TextColors.GRAY, Messages.CURRENT_POWER + " ", super.getPlugin().getPowerManager().getPlayerPower(player.getUniqueId()) + "/" + super.getPlugin().getPowerManager().getPlayerMaxPower(player.getUniqueId()))));

    final Optional<Faction> optionalChunkFaction = super.getPlugin().getFactionLogic().getFactionByChunk(player.getWorld().getUniqueId(), player.getLocation().getChunkPosition());
    if (this.protectionConfig.getWarZoneWorldNames().contains(player.getWorld().getName()) || (optionalChunkFaction.isPresent() && optionalChunkFaction.get().isWarZone()))
    {
        super.getPlugin().getPlayerManager().setDeathInWarZone(player.getUniqueId(), true);
    }

    if (this.factionsConfig.shouldBlockHomeAfterDeathInOwnFaction())
    {
        final Optional<Faction> optionalPlayerFaction = super.getPlugin().getFactionLogic().getFactionByPlayerUUID(player.getUniqueId());
        if (optionalChunkFaction.isPresent() && optionalPlayerFaction.isPresent() && optionalChunkFaction.get().getName().equals(optionalPlayerFaction.get().getName()))
        {
            super.getPlugin().getAttackLogic().blockHome(player.getUniqueId());
        }
    }

    if(super.getPlugin().getPVPLogger().isActive() && super.getPlugin().getPVPLogger().isPlayerBlocked(player))
    {
        super.getPlugin().getPVPLogger().removePlayer(player);
    }
}
 
Example 9
Source File: CacheService.java    From Web-API with MIT License 5 votes vote down vote up
@Listener(order = Order.POST)
public void onCommand(SendCommandEvent event) {
    CachedCommandCall cache = new CachedCommandCall(event, censoredCommands.contains(event.getCommand()));
    commandCalls.add(cache);

    while (commandCalls.size() > numCommandCalls) {
        commandCalls.poll();
    }
}
 
Example 10
Source File: InventoryListener.java    From Prism with MIT License 5 votes vote down vote up
/**
 * Saves event records when a player closes or opens an Inventory.
 *
 * @param event  InteractInventoryEvent
 * @param player Player
 */
@Listener(order = Order.POST)
public void onInteractInventory(InteractInventoryEvent event, @Root Player player) {
    if (!(event.getTargetInventory() instanceof CarriedInventory)
            || (!Prism.getInstance().getConfig().getEventCategory().isInventoryClose() && !Prism.getInstance().getConfig().getEventCategory().isInventoryOpen())) {
        return;
    }

    CarriedInventory<? extends Carrier> carriedInventory = (CarriedInventory<? extends Carrier>) event.getTargetInventory();
    if (carriedInventory.getCarrier().filter(Player.class::isInstance).isPresent()) {
        return;
    }

    // Get the location of the inventory otherwise fallback on the players location
    Location<World> location = carriedInventory.getCarrier()
            .filter(Locatable.class::isInstance)
            .map(Locatable.class::cast)
            .map(Locatable::getLocation)
            .orElse(player.getLocation());

    // Get the title of the inventory otherwise fallback on the class name
    String title = carriedInventory.getProperty(InventoryTitle.class, InventoryTitle.PROPERTY_NAME)
            .map(InventoryTitle::getValue)
            .map(Text::toPlain)
            .orElse(carriedInventory.getClass().getSimpleName());

    PrismRecord.EventBuilder eventBuilder = PrismRecord.create()
            .source(event.getCause())
            .container(title)
            .location(location);

    if (event instanceof InteractInventoryEvent.Close && Prism.getInstance().getConfig().getEventCategory().isInventoryClose()) {
        eventBuilder.event(PrismEvents.INVENTORY_CLOSE).buildAndSave();
    } else if (event instanceof InteractInventoryEvent.Open && Prism.getInstance().getConfig().getEventCategory().isInventoryOpen()) {
        eventBuilder.event(PrismEvents.INVENTORY_OPEN).buildAndSave();
    }
}
 
Example 11
Source File: SpongeAFKListener.java    From Plan with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Listener(order = Order.POST)
public void onLeave(ClientConnectionEvent.Disconnect event) {
    ignorePermissionInfo.remove(event.getTargetEntity().getUniqueId());
}
 
Example 12
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onEntitySpawn(SpawnEntityEvent event) {
    notifyHooks(WebHookService.WebHookType.ENTITY_SPAWN, event);
}
 
Example 13
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onPlayerChat(MessageChannelEvent.Chat event, @First Player player) {
    notifyHooks(WebHookService.WebHookType.CHAT, event);
}
 
Example 14
Source File: CacheService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onWorldLoad(LoadWorldEvent event) {
    updateWorld(event.getTargetWorld());
}
 
Example 15
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onWorldSave(SaveWorldEvent event) {
    notifyHooks(WebHookService.WebHookType.WORLD_SAVE, event);
}
 
Example 16
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onExplosion(ExplosionEvent event) {
    notifyHooks(WebHookService.WebHookType.EXPLOSION, event);
}
 
Example 17
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onInteractInventory(InteractInventoryEvent.Close event) {
    notifyHooks(WebHookService.WebHookType.INVENTORY_CLOSE, event);
}
 
Example 18
Source File: CacheService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onPlayerJoin(ClientConnectionEvent.Join event) {
    updatePlayer(event.getTargetEntity());
}
 
Example 19
Source File: WebHookService.java    From Web-API with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onInteractInventory(InteractInventoryEvent.Open event) {
    notifyHooks(WebHookService.WebHookType.INVENTORY_OPEN, event);
}
 
Example 20
Source File: ProtectionManager.java    From FlexibleLogin with MIT License 4 votes vote down vote up
@Listener(order = Order.POST)
public void onPlayerJoin(Join playerJoinEvent, @First Player player) {
    protect(player);
}