use of com.alessiodp.parties.common.players.objects.PartyInviteImpl in project Parties by AlessioDP.
the class PartyImpl method invitePlayer.
@Override
public PartyInvite invitePlayer(@NotNull PartyPlayer invitedPlayer, @Nullable PartyPlayer inviter, boolean sendMessages) {
PartyInviteImpl ret = null;
IPlayerPreInviteEvent playerPreInviteEvent = plugin.getEventManager().preparePlayerPreInviteEvent(invitedPlayer, inviter, this);
plugin.getEventManager().callEvent(playerPreInviteEvent);
if (!playerPreInviteEvent.isCancelled()) {
if (!invitedPlayer.isInParty() && !isFull()) {
ret = new PartyInviteImpl(plugin, this, invitedPlayer, inviter);
inviteRequests.add(ret);
invitedPlayer.getPendingInvites().add(ret);
if (sendMessages) {
if (inviter != null)
((PartyPlayerImpl) inviter).sendMessage(Messages.MAINCMD_INVITE_SENT, (PartyPlayerImpl) invitedPlayer, this);
((PartyPlayerImpl) invitedPlayer).sendMessage(Messages.MAINCMD_INVITE_PLAYERINVITED, (PartyPlayerImpl) inviter, this);
}
// Call API event and sync with bukkit servers
sendPacketInvite(invitedPlayer, inviter);
IPlayerPostInviteEvent playerPostInviteEvent = plugin.getEventManager().preparePlayerPostInviteEvent(invitedPlayer, inviter, this);
plugin.getEventManager().callEvent(playerPostInviteEvent);
ret.setActiveTask(plugin.getScheduler().scheduleAsyncLater(ret::timeout, ConfigParties.GENERAL_INVITE_TIMEOUT, TimeUnit.SECONDS));
}
} else {
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_INVITEEVENT_DENY, invitedPlayer.getPlayerUUID(), getId(), inviter != null ? inviter.getPlayerUUID().toString() : "none"), true);
}
return ret;
}
use of com.alessiodp.parties.common.players.objects.PartyInviteImpl 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);
}
}
Aggregations