Package dev.itsharshxd.zentrix.api.party
Interface PartyService
public interface PartyService
Provides party operations in Zentrix.
Addons can use it to query party state and membership, and to manage parties.
Example
PartyService partyService = ZentrixAPI.get().getPartyService();
// Check whether the player is in a party
if (partyService.isInParty(player)) {
ZentrixParty party = partyService.getParty(player).orElse(null);
if (party != null) {
player.sendMessage("Party size: " + party.getSize());
}
}
// Check whether the player leads a party
if (partyService.isPartyLeader(player)) {
player.sendMessage("You are the party leader!");
}
- Since:
- 1.2.0
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanacceptInvite(@NotNull org.bukkit.entity.Player invitee, @NotNull UUID inviterId) Accepts a pending invitation for a player, exactly as/party acceptdoes: the same checks, the same messages, andPartyInviteAcceptEventbefore joining.default booleancancelInvite(@NotNull UUID inviterId, @NotNull UUID inviteeId) Withdraws a pending invitation without messaging anyone; the caller explains it if it needs to.@NotNull Optional<ZentrixParty> createParty(@NotNull org.bukkit.entity.Player leader) Creates a new party with the given player as the leader.default booleandenyInvite(@NotNull org.bukkit.entity.Player invitee, @NotNull UUID inviterId) Turns down a pending invitation for a player, exactly as/party denydoes, messages included.booleandisbandParty(@NotNull org.bukkit.entity.Player leader) Disbands the party the given player leads.intGets the maximum party size allowed.default intgetMaxPartySize(@NotNull org.bukkit.entity.Player leader) Gets the maximum size of the party a player leads, which their perk tier inperks.ymlcan change.default @NotNull List<PartyInvitation> getOutgoingInvites(@NotNull UUID inviterId) Gets the invitations a party leader has sent that are still pending.@NotNull Optional<ZentrixParty> Gets the party a player belongs to by UUID.@NotNull Optional<ZentrixParty> getParty(@NotNull org.bukkit.entity.Player player) Gets the party a player belongs to.default @NotNull List<PartyInvitation> getPendingInvites(@NotNull UUID inviteeId) Gets the invitations a player has not answered yet.booleaninvitePlayer(@NotNull org.bukkit.entity.Player leader, @NotNull org.bukkit.entity.Player target) Sends a party invite from the leader to a target player.booleanChecks if a player is currently in a party by UUID.booleanisInParty(@NotNull org.bukkit.entity.Player player) Checks if a player is currently in a party.booleanisPartyLeader(@NotNull org.bukkit.entity.Player player) Checks if a player is the leader of their party.booleankickMember(@NotNull org.bukkit.entity.Player leader, @NotNull UUID targetId) Kicks a member from the party.voidleaveParty(@NotNull org.bukkit.entity.Player player) Removes the given player from their party.booleanpromoteLeader(@NotNull org.bukkit.entity.Player leader, @NotNull UUID targetId) Promotes a party member to leader.
-
Method Details
-
getParty
@NotNull @NotNull Optional<ZentrixParty> getParty(@NotNull @NotNull org.bukkit.entity.Player player) Gets the party a player belongs to.- Parameters:
player- The player- Returns:
- Optional containing the party, or empty if not in a party
-
getParty
Gets the party a player belongs to by UUID.- Parameters:
playerId- The player's UUID- Returns:
- Optional containing the party, or empty if not in a party
-
isInParty
boolean isInParty(@NotNull @NotNull org.bukkit.entity.Player player) Checks if a player is currently in a party.- Parameters:
player- The player- Returns:
trueif the player is in a party
-
isInParty
Checks if a player is currently in a party by UUID.- Parameters:
playerId- The player's UUID- Returns:
trueif the player is in a party
-
isPartyLeader
boolean isPartyLeader(@NotNull @NotNull org.bukkit.entity.Player player) Checks if a player is the leader of their party.- Parameters:
player- The player- Returns:
trueif the player is a party leader
-
createParty
@NotNull @NotNull Optional<ZentrixParty> createParty(@NotNull @NotNull org.bukkit.entity.Player leader) Creates a new party with the given player as the leader.- Parameters:
leader- The player who will be the party leader- Returns:
- Optional containing the created party, or empty if the player is already in a party
-
disbandParty
boolean disbandParty(@NotNull @NotNull org.bukkit.entity.Player leader) Disbands the party the given player leads.Only the party leader can disband. All members are removed and notified.
- Parameters:
leader- The party leader- Returns:
trueif the party was disbanded,falseif the player is not a party leader
-
invitePlayer
boolean invitePlayer(@NotNull @NotNull org.bukkit.entity.Player leader, @NotNull @NotNull org.bukkit.entity.Player target) Sends a party invite from the leader to a target player.- Parameters:
leader- The party leader sending the invitetarget- The target player to invite- Returns:
trueif the invite was sent successfully
-
leaveParty
void leaveParty(@NotNull @NotNull org.bukkit.entity.Player player) Removes the given player from their party.If the player is the leader, leadership is transferred to another member. If the player is the last member, the party is disbanded.
- Parameters:
player- The player leaving the party
-
kickMember
boolean kickMember(@NotNull @NotNull org.bukkit.entity.Player leader, @NotNull @NotNull UUID targetId) Kicks a member from the party.Only the party leader can kick members.
- Parameters:
leader- The party leader performing the kicktargetId- The UUID of the member to kick- Returns:
trueif the member was kicked,falseif the leader doesn't have permission or the target is not in the party
-
promoteLeader
boolean promoteLeader(@NotNull @NotNull org.bukkit.entity.Player leader, @NotNull @NotNull UUID targetId) Promotes a party member to leader.Only the current leader can promote another member.
- Parameters:
leader- The current party leadertargetId- The UUID of the member to promote- Returns:
trueif the promotion was successful
-
getMaxPartySize
int getMaxPartySize()Gets the maximum party size allowed.- Returns:
- The maximum party size
-
getMaxPartySize
default int getMaxPartySize(@NotNull @NotNull org.bukkit.entity.Player leader) Gets the maximum size of the party a player leads, which their perk tier inperks.ymlcan change.- Parameters:
leader- The party's current leader- Returns:
- The maximum party size for that leader
- Since:
- 1.9.0
-
getPendingInvites
Gets the invitations a player has not answered yet.- Parameters:
inviteeId- The invited player's UUID- Returns:
- The pending invitations, oldest first (never null)
- Since:
- 1.8.0
-
getOutgoingInvites
@NotNull default @NotNull List<PartyInvitation> getOutgoingInvites(@NotNull @NotNull UUID inviterId) Gets the invitations a party leader has sent that are still pending.- Parameters:
inviterId- The leader's UUID- Returns:
- The pending invitations (never null)
- Since:
- 1.8.0
-
acceptInvite
default boolean acceptInvite(@NotNull @NotNull org.bukkit.entity.Player invitee, @NotNull @NotNull UUID inviterId) Accepts a pending invitation for a player, exactly as/party acceptdoes: the same checks, the same messages, andPartyInviteAcceptEventbefore joining. Main thread only.- Parameters:
invitee- The invited playerinviterId- The leader who sent the invitation- Returns:
trueif the player joined the party- Since:
- 1.8.0
-
denyInvite
default boolean denyInvite(@NotNull @NotNull org.bukkit.entity.Player invitee, @NotNull @NotNull UUID inviterId) Turns down a pending invitation for a player, exactly as/party denydoes, messages included. Main thread only.- Parameters:
invitee- The invited playerinviterId- The leader who sent the invitation- Returns:
trueif there was such an invitation and it was turned down- Since:
- 1.8.0
-
cancelInvite
Withdraws a pending invitation without messaging anyone; the caller explains it if it needs to.PartyInviteResolveEventreports it asPartyInvitation.Resolution.CANCELLED.- Parameters:
inviterId- The leader who sent the invitationinviteeId- The invited player- Returns:
trueif there was such an invitation and it was withdrawn- Since:
- 1.8.0
-