Search in sources :

Example 46 with PartyImpl

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

the class PartiesRedisBungeeListener method handlePostInvitePlayer.

public void handlePostInvitePlayer(UUID partyId, UUID invitedId, UUID inviterId, double timeout) {
    PartyImpl party = ((PartiesPlugin) plugin).getPartyManager().getParty(partyId);
    if (party != null) {
        PartyPlayerImpl invited = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(invitedId);
        PartyPlayerImpl inviter = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(inviterId);
        IPlayerPostInviteEvent event = ((PartiesPlugin) plugin).getEventManager().preparePlayerPostInviteEvent(invited, inviter, party);
        ((PartiesPlugin) plugin).getEventManager().callEvent(event);
        PartyInviteImpl invite = new PartyInviteImpl((PartiesPlugin) plugin, party, invited, inviter);
        party.getInviteRequests().add(invite);
        invited.getPendingInvites().add(invite);
        invite.setActiveTask(plugin.getScheduler().scheduleAsyncLater(() -> invite.timeout(false), (int) timeout, TimeUnit.SECONDS));
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_INVITE_PARTY, invitedId.toString(), partyId.toString(), inviterId != null ? inviterId.toString() : "none"), true);
    }
}
Also used : IPlayerPostInviteEvent(com.alessiodp.parties.api.events.common.player.IPlayerPostInviteEvent) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartyInviteImpl(com.alessiodp.parties.common.players.objects.PartyInviteImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 47 with PartyImpl

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

the class PartiesRedisBungeeListener method handlePostBroadcastMessage.

public void handlePostBroadcastMessage(UUID partyId, UUID playerId, String message) {
    PartyImpl party = ((PartiesPlugin) plugin).getPartyManager().getParty(partyId);
    if (party != null) {
        PartyPlayerImpl player = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(playerId);
        party.broadcastDirectMessage(message, player, false);
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_BROADCAST_MESSAGE, playerId != null ? playerId.toString() : "none", partyId.toString(), message), true);
    }
}
Also used : PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 48 with PartyImpl

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

the class PartiesRedisBungeeListener method handlePostExperience.

public void handlePostExperience(UUID partyId, UUID playerId, double experience) {
    PartyImpl party = ((PartiesPlugin) plugin).getPartyManager().getParty(partyId);
    if (party != null) {
        PartyPlayerImpl player = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(playerId);
        IPartyGetExperienceEvent event = ((PartiesPlugin) plugin).getEventManager().preparePartyGetExperienceEvent(party, experience, player);
        ((PartiesPlugin) plugin).getEventManager().callEvent(event);
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_EXPERIENCE, CommonUtils.formatDouble(experience), partyId.toString(), playerId != null ? playerId.toString() : "none"), true);
    }
}
Also used : PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) IPartyGetExperienceEvent(com.alessiodp.parties.api.events.common.party.IPartyGetExperienceEvent) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 49 with PartyImpl

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

the class CommandInfo method preRequisites.

@Override
public boolean preRequisites(CommandData commandData) {
    User sender = commandData.getSender();
    if (sender.isPlayer()) {
        PartyPlayerImpl partyPlayer = ((PartiesPlugin) plugin).getPlayerManager().getPlayer(sender.getUUID());
        // Checks for command prerequisites
        if (!sender.hasPermission(permission)) {
            sendNoPermissionMessage(partyPlayer, permission);
            return false;
        }
        PartyImpl party = null;
        if (commandData.getArgs().length == 1) {
            party = ((PartiesPlugin) plugin).getPartyManager().getPartyOfPlayer(partyPlayer);
            if (party == null) {
                sendMessage(sender, partyPlayer, Messages.PARTIES_COMMON_NOTINPARTY);
                return false;
            }
        }
        ((PartiesCommandData) commandData).setPartyPlayer(partyPlayer);
        ((PartiesCommandData) commandData).setParty(party);
    } else {
        if (commandData.getArgs().length == 1) {
            sendMessage(sender, null, Messages.PARTIES_COMMON_PARTYNOTFOUND);
            return false;
        }
    }
    commandData.addPermission(PartiesPermission.USER_INFO_OTHERS);
    return true;
}
Also used : User(com.alessiodp.core.common.user.User) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartiesCommandData(com.alessiodp.parties.common.commands.utils.PartiesCommandData) PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 50 with PartyImpl

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

the class BukkitExpManager method distributeExp.

/**
 * Distribute the experience to the player
 * @return Returns true if the distribution has been done
 */
public boolean distributeExp(ExpDrop drop) {
    boolean ret = false;
    // Flags used to messages
    double totalParty = 0;
    double totalNormal = 0;
    double totalLevelPoints = 0;
    double totalMmoCore = 0;
    double totalSkillapi = 0;
    PartyImpl party = plugin.getPartyManager().getParty(drop.getKiller().getPartyId());
    if (party != null) {
        plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_EXP_RECEIVED, drop.getNormal(), drop.getSkillApi()), true);
        Player player = Bukkit.getPlayer(drop.getKiller().getPlayerUUID());
        User user = plugin.getPlayer(drop.getKiller().getPlayerUUID());
        if (player != null && user != null) {
            // Calling API event
            BukkitPartiesPreExperienceDropEvent partiesPreExperienceDropEvent = ((BukkitEventManager) plugin.getEventManager()).preparePreExperienceDropEvent(party, drop.getKiller(), drop.getEntityKilled(), drop.getNormal(), drop.getSkillApi());
            plugin.getEventManager().callEvent(partiesPreExperienceDropEvent);
            if (!partiesPreExperienceDropEvent.isCancelled()) {
                drop.setNormal(partiesPreExperienceDropEvent.getNormalExperience());
                drop.setSkillApi(partiesPreExperienceDropEvent.getSkillApiExperience());
                if (drop.getNormal() > 0) {
                    switch(convertNormal) {
                        case PARTY:
                            totalParty += drop.getNormal();
                            break;
                        case NORMAL:
                            totalNormal += drop.getNormal();
                            break;
                        case LEVELPOINTS:
                            totalLevelPoints += drop.getNormal();
                            break;
                        case MMOCORE:
                            totalMmoCore += drop.getNormal();
                            break;
                        case SKILLAPI:
                            totalSkillapi += drop.getNormal();
                            break;
                        default:
                            // Convert option not set
                            return false;
                    }
                }
                if (drop.getSkillApi() > 0) {
                    switch(convertSkillapi) {
                        case PARTY:
                            totalParty += drop.getSkillApi();
                            break;
                        case NORMAL:
                            totalNormal += drop.getSkillApi();
                            break;
                        case LEVELPOINTS:
                            totalLevelPoints += drop.getSkillApi();
                            break;
                        case MMOCORE:
                            totalMmoCore += drop.getSkillApi();
                            break;
                        case SKILLAPI:
                            totalSkillapi += drop.getSkillApi();
                            break;
                        default:
                            // Convert option not set
                            return false;
                    }
                }
                // Send experience
                if (totalParty > 0) {
                    plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_EXP_SEND_PARTY, CommonUtils.formatDouble(totalParty), party.getId().toString()), true);
                    party.giveExperience(totalParty, drop.getKiller());
                    user.sendMessage(plugin.getMessageUtils().convertPlaceholders(BukkitMessages.ADDCMD_EXP_PARTY_GAINED.replace("%exp%", CommonUtils.formatDouble(totalParty)), drop.getKiller(), party), true);
                    ret = true;
                }
                if (totalNormal > 0)
                    ret = shareExperience(totalNormal, drop.getKiller(), party, drop.getEntityKilled(), ExpConvert.NORMAL) || ret;
                if (totalLevelPoints > 0)
                    ret = shareExperience(totalLevelPoints, drop.getKiller(), party, drop.getEntityKilled(), ExpConvert.LEVELPOINTS) || ret;
                if (totalMmoCore > 0)
                    ret = shareExperience(totalMmoCore, drop.getKiller(), party, drop.getEntityKilled(), ExpConvert.MMOCORE) || ret;
                if (totalSkillapi > 0)
                    ret = shareExperience(totalSkillapi, drop.getKiller(), party, drop.getEntityKilled(), ExpConvert.SKILLAPI) || ret;
            }
        }
    }
    return ret;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayer(com.alessiodp.parties.api.interfaces.PartyPlayer) User(com.alessiodp.core.common.user.User) BukkitPartiesPreExperienceDropEvent(com.alessiodp.parties.api.events.bukkit.unique.BukkitPartiesPreExperienceDropEvent) BukkitEventManager(com.alessiodp.parties.bukkit.events.BukkitEventManager) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)106 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)75 User (com.alessiodp.core.common.user.User)39 PartiesCommandData (com.alessiodp.parties.common.commands.utils.PartiesCommandData)31 ADPPlugin (com.alessiodp.core.common.ADPPlugin)11 UUID (java.util.UUID)11 ConfigMain (com.alessiodp.parties.common.configuration.data.ConfigMain)10 ConfigParties (com.alessiodp.parties.common.configuration.data.ConfigParties)10 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)9 PartiesConstants (com.alessiodp.parties.common.configuration.PartiesConstants)9 PartyHomeImpl (com.alessiodp.parties.common.parties.objects.PartyHomeImpl)8 LinkedList (java.util.LinkedList)8 LinkedHashSet (java.util.LinkedHashSet)7 List (java.util.List)7 HashMap (java.util.HashMap)6 ADPMainCommand (com.alessiodp.core.common.commands.utils.ADPMainCommand)5 CommandData (com.alessiodp.core.common.commands.utils.CommandData)5 OfflineUser (com.alessiodp.core.common.user.OfflineUser)5 CommonCommands (com.alessiodp.parties.common.commands.list.CommonCommands)5 PartiesSubCommand (com.alessiodp.parties.common.commands.utils.PartiesSubCommand)5