Search in sources :

Example 1 with PartyPlayerImpl

use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.

the class PAPIHook method onRequest.

@Override
public String onRequest(OfflinePlayer offlinePlayer, String identifier) {
    if (offlinePlayer != null) {
        PartyPlayerImpl partyPlayer = plugin.getPlayerManager().getPlayer(offlinePlayer.getUniqueId());
        PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
        PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(identifier);
        return placeholder != null ? placeholder.formatPlaceholder(partyPlayer, party, identifier) : null;
    }
    return null;
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 2 with PartyPlayerImpl

use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.

the class EssentialsChatHandler method onChatPlayer.

@EventHandler
public void onChatPlayer(AsyncPlayerChatEvent event) {
    String old = event.getFormat();
    if (CommonUtils.toLowerCase(old).contains("{parties_")) {
        // Bypass useless checks if this isn't an Parties placeholder
        boolean somethingChanged = false;
        PartyPlayerImpl partyPlayer = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
        PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
        Matcher mat = PATTERN.matcher(old);
        while (mat.find()) {
            String base = mat.group(0);
            String identifier = mat.group(1);
            if (identifier != null) {
                identifier = CommonUtils.toLowerCase(identifier);
                PartiesPlaceholder placeholder = PartiesPlaceholder.getPlaceholder(identifier);
                if (placeholder != null) {
                    String parsed = placeholder.formatPlaceholder(partyPlayer, party, identifier);
                    if (parsed != null) {
                        old = old.replace(base, Color.translateAlternateColorCodes(parsed));
                        somethingChanged = true;
                    }
                }
            }
        }
        if (somethingChanged)
            event.setFormat(old);
    }
}
Also used : PartiesPlaceholder(com.alessiodp.parties.common.addons.internal.PartiesPlaceholder) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) Matcher(java.util.regex.Matcher) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl) EventHandler(org.bukkit.event.EventHandler)

Example 3 with PartyPlayerImpl

use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.

the class MythicMobsHandler method onMythicMobDeath.

@EventHandler
public void onMythicMobDeath(MythicMobLootDropEvent event) {
    if (active && event.getKiller() instanceof Player) {
        Entity killedEntity = event.getEntity();
        if (event.getKiller() != null) {
            PartyPlayerImpl killer = plugin.getPlayerManager().getPlayer(event.getKiller().getUniqueId());
            if (killer.isInParty()) {
                plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_EXP_MMHANDLING, event.getMobType().getInternalName(), killer.getName(), killer.getPlayerUUID().toString()), true);
                double vanillaExp = 0;
                double skillapiExp = 0;
                if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL)
                    vanillaExp = event.getExp();
                if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) {
                    for (Drop drop : event.getDrops().getDrops()) {
                        if (drop instanceof SkillAPIDrop) {
                            skillapiExp += drop.getAmount();
                        }
                    }
                }
                ExpDrop drop = new ExpDrop(killer, killedEntity, vanillaExp, skillapiExp);
                boolean result = ((BukkitExpManager) plugin.getExpManager()).distributeExp(drop);
                if (result && BukkitConfigMain.ADDITIONAL_EXP_DROP_CONVERT_REMOVEREALEXP) {
                    // Remove exp from the event if hooked
                    if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_NORMAL) {
                        // Be sure that we are removing exp from intangible drops
                        for (Drop d : event.getDrops().getLootTableIntangible().values()) {
                            if (d instanceof ExperienceDrop) {
                                d.setAmount(0);
                            }
                        }
                        // Add it to an array list that contains a list of entities
                        // that we need to manually remove drop experience
                        mobsExperienceToSuppress.add(event.getEntity().getUniqueId());
                    }
                    // Remove skillapi exp from the event if hooked
                    if (BukkitConfigMain.ADDITIONAL_EXP_DROP_GET_SKILLAPI) {
                        event.getDrops().getLootTableIntangible().remove(SkillAPIDrop.class);
                    }
                }
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) SkillAPIDrop(io.lumine.xikage.mythicmobs.drops.droppables.SkillAPIDrop) ExpDrop(com.alessiodp.parties.bukkit.players.objects.ExpDrop) BukkitExpManager(com.alessiodp.parties.bukkit.parties.BukkitExpManager) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) ExperienceDrop(io.lumine.xikage.mythicmobs.drops.droppables.ExperienceDrop) ExpDrop(com.alessiodp.parties.bukkit.players.objects.ExpDrop) Drop(io.lumine.xikage.mythicmobs.drops.Drop) SkillAPIDrop(io.lumine.xikage.mythicmobs.drops.droppables.SkillAPIDrop) ExperienceDrop(io.lumine.xikage.mythicmobs.drops.droppables.ExperienceDrop) EventHandler(org.bukkit.event.EventHandler)

Example 4 with PartyPlayerImpl

use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.

the class BukkitCommandTeleport method performTeleport.

@Override
public void performTeleport(PartyImpl party, PartyPlayerImpl player, int delay) {
    if (ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE)
        player.sendMessage(Messages.ADDCMD_TELEPORT_ACCEPT_REQUEST_SENT);
    else
        player.sendMessage(Messages.ADDCMD_TELEPORT_TELEPORTING.replace("%seconds%", Integer.toString(delay)));
    for (PartyPlayer onlinePlayer : party.getOnlineMembers(true)) {
        if (!onlinePlayer.getPlayerUUID().equals(player.getPlayerUUID())) {
            if (ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_ENABLE) {
                BukkitPartyTeleportRequest request = new BukkitPartyTeleportRequest((PartiesPlugin) plugin, (PartyPlayerImpl) onlinePlayer, player);
                ((PartyPlayerImpl) onlinePlayer).getPendingTeleportRequests().add(request);
                ((PartyPlayerImpl) onlinePlayer).sendMessage(Messages.ADDCMD_TELEPORT_ACCEPT_REQUEST_RECEIVED, player, party);
                plugin.getScheduler().scheduleAsyncLater(request::timeout, ConfigParties.ADDITIONAL_TELEPORT_ACCEPT_REQUEST_TIME, TimeUnit.SECONDS);
            } else {
                handleSinglePlayerTeleport((PartiesPlugin) plugin, (PartyPlayerImpl) onlinePlayer, player, delay);
            }
        }
    }
}
Also used : PartyPlayer(com.alessiodp.parties.api.interfaces.PartyPlayer) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) BukkitPartyTeleportRequest(com.alessiodp.parties.bukkit.parties.objects.BukkitPartyTeleportRequest)

Example 5 with PartyPlayerImpl

use of com.alessiodp.parties.common.players.objects.PartyPlayerImpl in project Parties by AlessioDP.

the class RankManagerTest method testCheckPlayerRankAlerter.

@Test
public void testCheckPlayerRankAlerter() {
    Messages.PARTIES_PERM_NORANK_UPRANK = "";
    Messages.PARTIES_PERM_NORANK_GENERAL = "";
    PartyPlayerImpl player = mock(PartyPlayerImpl.class);
    doNothing().when(player).sendMessage(anyString());
    User user = mock(User.class);
    when(user.hasPermission(anyString())).thenReturn(true);
    when(mockPlugin.getPlayer(any())).thenReturn(user);
    when(player.getRank()).thenReturn(1);
    assertTrue(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_COLOR));
    verify(player, times(0)).sendMessage(anyString());
    assertTrue(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_DESC));
    verify(player, times(0)).sendMessage(anyString());
    assertFalse(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_FOLLOW));
    verify(player, times(1)).sendMessage(anyString());
    assertFalse(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_HOME));
    verify(player, times(2)).sendMessage(anyString());
    assertFalse(rankManager.checkPlayerRankAlerter(player, PartiesPermission.PRIVATE_EDIT_MOTD));
    verify(player, times(3)).sendMessage(anyString());
}
Also used : User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) Test(org.junit.jupiter.api.Test)

Aggregations

PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)91 User (com.alessiodp.core.common.user.User)56 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)50 PartiesCommandData (com.alessiodp.parties.common.commands.utils.PartiesCommandData)43 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)28 UUID (java.util.UUID)10 EventHandler (org.bukkit.event.EventHandler)9 PartyPlayer (com.alessiodp.parties.api.interfaces.PartyPlayer)8 BukkitPartyPlayerImpl (com.alessiodp.parties.bukkit.players.objects.BukkitPartyPlayerImpl)8 Player (org.bukkit.entity.Player)8 ADPPlugin (com.alessiodp.core.common.ADPPlugin)7 ADPMainCommand (com.alessiodp.core.common.commands.utils.ADPMainCommand)6 CommandData (com.alessiodp.core.common.commands.utils.CommandData)6 OfflineUser (com.alessiodp.core.common.user.OfflineUser)6 CommonCommands (com.alessiodp.parties.common.commands.list.CommonCommands)5 PartiesSubCommand (com.alessiodp.parties.common.commands.utils.PartiesSubCommand)5 PartiesConstants (com.alessiodp.parties.common.configuration.PartiesConstants)5 ConfigMain (com.alessiodp.parties.common.configuration.data.ConfigMain)5 ConfigParties (com.alessiodp.parties.common.configuration.data.ConfigParties)5 Messages (com.alessiodp.parties.common.configuration.data.Messages)5