Class DominionAPI

java.lang.Object
cn.lunadeer.dominion.api.DominionAPI

@Experimental public abstract class DominionAPI extends Object
Interface representing the Dominion API.

This interface provides methods to interact with the Dominion plugin.

Use the getInstance() method to retrieve the singleton instance of the DominionAPI.

  • Constructor Details

    • DominionAPI

      public DominionAPI()
  • Method Details

    • getInstance

      Retrieves the singleton instance of the DominionAPI. This method checks if the Dominion plugin is enabled and if the version is compatible. If these checks pass, it retrieves the instance of the DominionAPI from the DominionInterface class.
      Returns:
      the singleton instance of the DominionAPI
      Throws:
      ClassNotFoundException - if the DominionInterface class cannot be found
      NoSuchFieldException - if the instance field cannot be found in the DominionInterface class
      IllegalAccessException - if the instance field is not accessible
      IllegalStateException - if the Dominion plugin is not installed or the version is not compatible
    • isDominionEnabled

      public static boolean isDominionEnabled()
      Checks if the Dominion plugin is enabled.
      Returns:
      true if the Dominion plugin is enabled, false otherwise
    • getPlayer

      @Nullable public abstract @Nullable PlayerDTO getPlayer(String name)
      Retrieves a PlayerDTO by the player's name.
      Parameters:
      name - the name of the player
      Returns:
      the PlayerDTO associated with the given name, or null if not found
    • getPlayer

      @Nullable public abstract @Nullable PlayerDTO getPlayer(@NotNull @NotNull UUID player)
      Retrieves a PlayerDTO by the player's UUID.
      Parameters:
      player - the UUID of the player
      Returns:
      the PlayerDTO associated with the given UUID, or null if not found
    • getPlayerName

      @NotNull public abstract @NotNull String getPlayerName(@NotNull @NotNull UUID uuid)
      Retrieves the name of a player by their UUID.
      Parameters:
      uuid - the UUID of the player
      Returns:
      the name of the player associated with the given UUID
    • getAllDominions

      public abstract List<DominionDTO> getAllDominions()
      Retrieves all DominionDTO objects.

      This method retrieves all dominions from the cache of this server. If multi-servers mode is enabled, it also retrieves dominions from the caches of other servers.

      Returns:
      a list of all DominionDTO objects
    • getChildrenDominionOf

      public abstract List<DominionDTO> getChildrenDominionOf(DominionDTO parent)
      Retrieves the child dominions of a given parent dominion.

      This method retrieves the child dominions of the specified parent dominion from the cache of this server. If multi-servers mode is enabled, it also retrieves child dominions from the caches of other servers.

      Parameters:
      parent - the parent DominionDTO whose children are to be retrieved
      Returns:
      a list of child DominionDTO objects
    • getDominion

      @Nullable public abstract @Nullable DominionDTO getDominion(Integer id)
      Retrieves a DominionDTO by its ID.

      This method will first attempt to retrieve the DominionDTO from the cache of this server. If the DominionDTO is not found, it will then attempt to retrieve the DominionDTO from the caches of other servers.

      Parameters:
      id - the ID of the dominion to retrieve
      Returns:
      the DominionDTO associated with the given ID
    • getDominion

      @NotNull public abstract @NotNull DominionDTO getDominion(String name)
      Retrieves a DominionDTO by its name.

      This method will first attempt to retrieve the DominionDTO from the cache of this server. If the DominionDTO is not found, it will then attempt to retrieve the DominionDTO from the caches of other servers.

      Parameters:
      name - the name of the dominion to retrieve
      Returns:
      the DominionDTO associated with the given name
    • getDominion

      @Nullable public abstract @Nullable DominionDTO getDominion(org.bukkit.Location location)
      Retrieves a DominionDTO by its location.

      This method retrieves the DominionDTO associated with the given location from the cache of this server.

      Parameters:
      location - the location to retrieve the dominion for
      Returns:
      the DominionDTO associated with the given location, or null if not found
    • getPlayerOwnDominionDTOs

      public abstract List<DominionDTO> getPlayerOwnDominionDTOs(UUID player)
      Retrieves the dominions owned by a player.

      This method retrieves the dominions owned by the player from the cache of this server. If multi-servers mode is enabled, it also retrieves the dominions owned by the player from the caches of other servers.

      Parameters:
      player - the UUID of the player
      Returns:
      a list of DominionDTO objects representing the dominions owned by the player
    • getPlayerAdminDominionDTOs

      public abstract List<DominionDTO> getPlayerAdminDominionDTOs(UUID player)
      Retrieves the dominions where a player is an admin.

      This method retrieves the dominions where the player is an admin from the cache of this server. If multi-servers mode is enabled, it also retrieves the dominions where the player is an admin from the caches of other servers.

      Parameters:
      player - the UUID of the player
      Returns:
      a list of DominionDTO objects representing the dominions where the player is an admin
    • getMember

      @Nullable public abstract @Nullable MemberDTO getMember(@Nullable @Nullable DominionDTO dominion, @NotNull @NotNull org.bukkit.entity.Player player)
      Retrieves a MemberDTO by the player's UUID.

      This method retrieves the MemberDTO associated with the given player from the specified dominion.

      Parameters:
      dominion - the DominionDTO to retrieve the member from
      player - the Player object representing the player
      Returns:
      the MemberDTO associated with the given player, or null if not found
    • getMember

      @Nullable public abstract @Nullable MemberDTO getMember(@Nullable @Nullable DominionDTO dominion, @NotNull @NotNull UUID player)
      Retrieves a MemberDTO by the player's UUID.

      This method retrieves the MemberDTO associated with the given player from the specified dominion. If the member is not found in the cache of this server, it will attempt to retrieve the member from the caches of other servers if multi-servers mode is enabled.

      Parameters:
      dominion - the DominionDTO to retrieve the member from
      player - the UUID of the player
      Returns:
      the MemberDTO associated with the given player, or null if not found
    • getGroup

      @Nullable public abstract @Nullable GroupDTO getGroup(MemberDTO member)
      Retrieves a GroupDTO by the member's group ID.

      This method retrieves the GroupDTO associated with the group ID of the given member.

      Parameters:
      member - the MemberDTO whose group ID is to be used for retrieval
      Returns:
      the GroupDTO associated with the given member's group ID, or null if not found
    • getGroup

      @Nullable public abstract @Nullable GroupDTO getGroup(Integer id)
      Retrieves a GroupDTO by its ID.

      This method retrieves the GroupDTO associated with the given ID from the cache of this server. If the GroupDTO is not found, it will then attempt to retrieve the GroupDTO from the caches of other servers if multi-servers mode is enabled.

      Parameters:
      id - the ID of the group to retrieve
      Returns:
      the GroupDTO associated with the given ID, or null if not found
    • getPlayerCurrentDominion

      @Nullable public abstract @Nullable DominionDTO getPlayerCurrentDominion(@NotNull @NotNull org.bukkit.entity.Player player)
      Retrieves the current dominion of a player.

      This method retrieves the current dominion of the player based on their location. It checks if the player is still in the same dominion and if the dominion has no children. If the player has moved to a different dominion, it triggers the appropriate events and updates the player's current dominion ID.

      Parameters:
      player - the Player object representing the player
      Returns:
      the DominionDTO associated with the player's current location, or null if not found
    • resetPlayerCurrentDominionId

      public abstract void resetPlayerCurrentDominionId(@NotNull @NotNull org.bukkit.entity.Player player)
      Resets the current dominion ID for a player.

      This method removes the current dominion ID associated with the player from the cache.

      Parameters:
      player - the Player object representing the player
    • dominionCount

      public abstract Integer dominionCount()
      Retrieves the total count of dominions.

      This method calculates the total number of dominions by summing the count of dominions on this server and, if multi-servers mode is enabled, the counts from other servers.

      Returns:
      the total count of dominions
    • groupCount

      public abstract Integer groupCount()
      Retrieves the total count of groups.

      This method calculates the total number of groups by summing the count of groups on this server and, if multi-servers mode is enabled, the counts from other servers.

      Returns:
      the total count of groups
    • memberCount

      public abstract Integer memberCount()
      Retrieves the total count of members.

      This method calculates the total number of members by summing the count of members on this server and, if multi-servers mode is enabled, the counts from other servers.

      Returns:
      the total count of members
    • checkPrivilegeFlag

      public abstract boolean checkPrivilegeFlag(@Nullable @Nullable DominionDTO dom, @NotNull @NotNull PriFlag flag, @NotNull @NotNull org.bukkit.entity.Player player)
      Checks if the specified player has the specified privilege flag in the given dominion.

      If no-permission, it will send a message to the player.

      Parameters:
      dom - the dominion to check
      flag - the privilege flag to check
      player - the player to check
      Returns:
      true if the player has the specified privilege flag, false otherwise
    • checkPrivilegeFlagSilence

      public abstract boolean checkPrivilegeFlagSilence(@Nullable @Nullable DominionDTO dom, @NotNull @NotNull PriFlag flag, @NotNull @NotNull org.bukkit.entity.Player player)
      Checks if the specified player has the specified privilege flag in the given dominion.

      If no-permission, it will not send a message to the player.

      Parameters:
      dom - the dominion to check
      flag - the privilege flag to check
      player - the player to check
      Returns:
      true if the player has the specified privilege flag, false otherwise
    • checkEnvironmentFlag

      public abstract boolean checkEnvironmentFlag(@Nullable @Nullable DominionDTO dom, @NotNull @NotNull EnvFlag flag)
      Checks if the specified environment flag is set in the given dominion.
      Parameters:
      dom - the dominion to check, or null to check the global environment
      flag - the environment flag to check
      Returns:
      true if the environment flag is set, false otherwise