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 Type
    Method
    Description
    default boolean
    acceptInvite(@NotNull org.bukkit.entity.Player invitee, @NotNull UUID inviterId)
    Accepts a pending invitation for a player, exactly as /party accept does: the same checks, the same messages, and PartyInviteAcceptEvent before joining.
    default boolean
    cancelInvite(@NotNull UUID inviterId, @NotNull UUID inviteeId)
    Withdraws a pending invitation without messaging anyone; the caller explains it if it needs to.
    createParty(@NotNull org.bukkit.entity.Player leader)
    Creates a new party with the given player as the leader.
    default boolean
    denyInvite(@NotNull org.bukkit.entity.Player invitee, @NotNull UUID inviterId)
    Turns down a pending invitation for a player, exactly as /party deny does, messages included.
    boolean
    disbandParty(@NotNull org.bukkit.entity.Player leader)
    Disbands the party the given player leads.
    int
    Gets the maximum party size allowed.
    default int
    getMaxPartySize(@NotNull org.bukkit.entity.Player leader)
    Gets the maximum size of the party a player leads, which their perk tier in perks.yml can change.
    default @NotNull List<PartyInvitation>
    getOutgoingInvites(@NotNull UUID inviterId)
    Gets the invitations a party leader has sent that are still pending.
    getParty(@NotNull UUID playerId)
    Gets the party a player belongs to by UUID.
    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.
    boolean
    invitePlayer(@NotNull org.bukkit.entity.Player leader, @NotNull org.bukkit.entity.Player target)
    Sends a party invite from the leader to a target player.
    boolean
    isInParty(@NotNull UUID playerId)
    Checks if a player is currently in a party by UUID.
    boolean
    isInParty(@NotNull org.bukkit.entity.Player player)
    Checks if a player is currently in a party.
    boolean
    isPartyLeader(@NotNull org.bukkit.entity.Player player)
    Checks if a player is the leader of their party.
    boolean
    kickMember(@NotNull org.bukkit.entity.Player leader, @NotNull UUID targetId)
    Kicks a member from the party.
    void
    leaveParty(@NotNull org.bukkit.entity.Player player)
    Removes the given player from their party.
    boolean
    promoteLeader(@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

      @NotNull @NotNull Optional<ZentrixParty> getParty(@NotNull @NotNull UUID playerId)
      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:
      true if the player is in a party
    • isInParty

      boolean isInParty(@NotNull @NotNull UUID playerId)
      Checks if a player is currently in a party by UUID.
      Parameters:
      playerId - The player's UUID
      Returns:
      true if 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:
      true if 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:
      true if the party was disbanded, false if 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 invite
      target - The target player to invite
      Returns:
      true if 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 kick
      targetId - The UUID of the member to kick
      Returns:
      true if the member was kicked, false if 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 leader
      targetId - The UUID of the member to promote
      Returns:
      true if 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 in perks.yml can change.
      Parameters:
      leader - The party's current leader
      Returns:
      The maximum party size for that leader
      Since:
      1.9.0
    • getPendingInvites

      @NotNull default @NotNull List<PartyInvitation> getPendingInvites(@NotNull @NotNull UUID inviteeId)
      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 accept does: the same checks, the same messages, and PartyInviteAcceptEvent before joining. Main thread only.
      Parameters:
      invitee - The invited player
      inviterId - The leader who sent the invitation
      Returns:
      true if 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 deny does, messages included. Main thread only.
      Parameters:
      invitee - The invited player
      inviterId - The leader who sent the invitation
      Returns:
      true if there was such an invitation and it was turned down
      Since:
      1.8.0
    • cancelInvite

      default boolean cancelInvite(@NotNull @NotNull UUID inviterId, @NotNull @NotNull UUID inviteeId)
      Withdraws a pending invitation without messaging anyone; the caller explains it if it needs to. PartyInviteResolveEvent reports it as PartyInvitation.Resolution.CANCELLED.
      Parameters:
      inviterId - The leader who sent the invitation
      inviteeId - The invited player
      Returns:
      true if there was such an invitation and it was withdrawn
      Since:
      1.8.0