org.spongepowered.api.event.filter.Getter Java Examples

The following examples show how to use org.spongepowered.api.event.filter.Getter. 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: UCListener.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onJoin(ClientConnectionEvent.Join e, @Getter("getTargetEntity") Player p) {
    if (!UChat.get().getConfig().root().general.persist_channels) {
        UChat.get().getDefChannel(p.getWorld().getName()).addMember(p);
    }
    if (p.hasPermission("uchat.auto-msgtoggle")) {
        UChat.get().msgTogglePlayers.remove(p.getName());
    }

    if (UChat.get().getUCJDA() != null && !p.hasPermission(UChat.get().getConfig().root().discord.vanish_perm)) {
        Task.builder().async().execute(() ->
                UChat.get().getUCJDA().sendRawToDiscord(UChat.get().getLang().get("discord.join").replace("{player}", p.getName())));
    }
    if (UChat.get().getConfig().root().general.spy_enabled_onjoin && p.hasPermission("uchat.cmd.spy") && !UChat.get().isSpy.contains(p.getName())) {
        UChat.get().isSpy.add(p.getName());
        UChat.get().getLang().sendMessage(p, "cmd.spy.enabled");
    }
}
 
Example #2
Source File: UCListener.java    From UltimateChat with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onQuit(ClientConnectionEvent.Disconnect e, @Getter("getTargetEntity") Player p) {
    if (!UChat.get().getConfig().root().general.persist_channels) {
        UChat.get().getPlayerChannel(p).removeMember(p);
    }

    UChat.get().tellPlayers.remove(p.getName());
    UChat.get().tellPlayers.entrySet().removeIf(k -> k.getValue().equals(p.getName()));
    UChat.get().tempTellPlayers.remove(p.getName());
    UChat.get().tempTellPlayers.entrySet().removeIf(k -> k.getValue().equals(p.getName()));
    UChat.get().respondTell.remove(p.getName());
    UChat.get().respondTell.entrySet().removeIf(k -> k.getValue().equals(p.getName()));
    UChat.get().tempChannels.remove(p.getName());
    UChat.get().tempChannels.entrySet().removeIf(k -> k.getValue().equals(p.getName()));
    UChat.get().command.remove(p.getName());

    if (UChat.get().getUCJDA() != null && UChat.get().getUCJDA().JDAAvailable() && !p.hasPermission(UChat.get().getConfig().root().discord.vanish_perm)) {
        Task.builder().async().execute(() ->
                UChat.get().getUCJDA().sendRawToDiscord(UChat.get().getLang().get("discord.leave").replace("{player}", p.getName())));
    }
}
 
Example #3
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 #4
Source File: UCListener.java    From UltimateChat with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onDeath(DestructEntityEvent.Death e, @Getter("getTargetEntity") Player p) {
    if (UChat.get().getUCJDA() != null && !p.hasPermission(UChat.get().getConfig().root().discord.vanish_perm)) {
        Task.builder().async().execute(() ->
                UChat.get().getUCJDA().sendRawToDiscord(UChat.get().getLang().get("discord.death").replace("{player}", p.getName())));
    }
}
 
Example #5
Source File: UCListener.java    From UltimateChat with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onChangeWorld(MoveEntityEvent.Teleport e, @Getter("getTargetEntity") Player p) {
    if (!UChat.get().getConfig().root().general.check_channel_change_world) return;

    World tw = e.getToTransform().getExtent();
    UCChannel pch = UChat.get().getPlayerChannel(p);

    String toCh = "";
    if (!pch.availableInWorld(tw)) {
        if (UChat.get().getDefChannel(tw.getName()).availableInWorld(tw)) {
            UChat.get().getDefChannel(tw.getName()).addMember(p);
            toCh = UChat.get().getDefChannel(tw.getName()).getName();
        } else {
            for (UCChannel ch : UChat.get().getChannels().values()) {
                if (ch.availableInWorld(tw)) {
                    ch.addMember(p);
                    toCh = ch.getName();
                    break;
                }
            }
        }
    }
    if (!toCh.isEmpty()) {
        UChat.get().getLang().sendMessage(p, UChat.get().getLang().get("channel.entered").replace("{channel}", toCh));
    } else if (!pch.availableInWorld(tw)) {
        pch.removeMember(p);
        UChat.get().getLang().sendMessage(p, "channel.world.none");
    }
}
 
Example #6
Source File: EntityListener.java    From Prism with MIT License 5 votes vote down vote up
/**
 * Saves event records when a player disconnects.
 *
 * @param event ClientConnectionEvent.Disconnect
 */
@Listener(order = Order.POST)
public void onClientConnectionDisconnect(ClientConnectionEvent.Disconnect event, @Getter("getTargetEntity") Player player) {
    if (!Prism.getInstance().getConfig().getEventCategory().isPlayerDisconnect()) {
        return;
    }

    PrismRecord.create()
            .player(player)
            .event(PrismEvents.PLAYER_DISCONNECT)
            .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 a player joins.
 *
 * @param event ClientConnectionEvent.Join
 */
@Listener(order = Order.POST)
public void onClientConnectionJoin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
    if (!Prism.getInstance().getConfig().getEventCategory().isPlayerJoin()) {
        return;
    }

    PrismRecord.create()
            .player(player)
            .event(PrismEvents.PLAYER_JOIN)
            .location(player.getLocation())
            .buildAndSave();
}
 
Example #8
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 #9
Source File: PreventListener.java    From FlexibleLogin with MIT License 4 votes vote down vote up
@Listener(order = Order.FIRST, beforeModifications = true)
public void onDamagePlayer(DamageEntityEvent damageEntityEvent, @Getter("getTargetEntity") Player player) {
    //player is damage target
    checkLoginStatus(damageEntityEvent, player);
}