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);
}
}
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);
}
}
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);
}
}
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;
}
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;
}
Aggregations