Class TemplateProvider

java.lang.Object
cn.lunadeer.dominion.providers.TemplateProvider

public abstract class TemplateProvider extends Object
API operations for player-owned privilege templates.

Template lookups are synchronous cache/database reads. Mutations are asynchronous and complete with the affected DTO, or null when the operation is rejected or fails.

  • Field Details

    • instance

      protected static TemplateProvider instance
      The provider instance initialized by Dominion.
  • Constructor Details

    • TemplateProvider

      public TemplateProvider()
  • Method Details

    • getInstance

      public static TemplateProvider getInstance()
      Gets the initialized provider instance.
      Returns:
      the provider, or null before Dominion initialization
    • getTemplates

      @NotNull public abstract @NotNull List<TemplateDTO> getTemplates(@NotNull @NotNull UUID creator)
      Gets all templates owned by a player.
      Parameters:
      creator - the owner's UUID
      Returns:
      the owner's templates, or an empty list when none are available
    • getTemplate

      @Nullable public abstract @Nullable TemplateDTO getTemplate(@NotNull @NotNull UUID creator, @NotNull @NotNull String name)
      Looks up a template by owner and name.
      Parameters:
      creator - the owner's UUID
      name - the template name
      Returns:
      the matching template, or null when it does not exist
    • getTemplate

      @Nullable public abstract @Nullable TemplateDTO getTemplate(@NotNull @NotNull UUID creator, @NotNull @NotNull Integer id)
      Looks up a template by owner and numeric identifier.
      Parameters:
      creator - the owner's UUID
      id - the template identifier
      Returns:
      the matching template, or null when it does not exist
    • createTemplate

      public abstract CompletableFuture<TemplateDTO> createTemplate(@NotNull @NotNull org.bukkit.entity.Player operator, @NotNull @NotNull String name)
      Creates a template owned by the operator.
      Parameters:
      operator - the player creating the template
      name - the new template name
      Returns:
      a future that completes with the created template, or null when validation or persistence fails
    • renameTemplate

      public abstract CompletableFuture<TemplateDTO> renameTemplate(@NotNull @NotNull org.bukkit.entity.Player operator, @NotNull @NotNull TemplateDTO template, @NotNull @NotNull String newName)
      Renames a template owned by the operator.
      Parameters:
      operator - the template owner
      template - the template to rename
      newName - the new template name
      Returns:
      a future that completes with the renamed template, or null when validation or ownership checks fail
    • deleteTemplate

      public abstract CompletableFuture<TemplateDTO> deleteTemplate(@NotNull @NotNull org.bukkit.entity.Player operator, @NotNull @NotNull TemplateDTO template)
      Deletes a template owned by the operator.
      Parameters:
      operator - the template owner
      template - the template to delete
      Returns:
      a future that completes with the deleted template, or null when the operation fails
    • setTemplateFlag

      public abstract CompletableFuture<TemplateDTO> setTemplateFlag(@NotNull @NotNull org.bukkit.entity.Player operator, @NotNull @NotNull TemplateDTO template, @NotNull @NotNull PriFlag flag, boolean value)
      Sets a privilege value in a template owned by the operator.
      Parameters:
      operator - the template owner
      template - the template to update
      flag - the privilege flag
      value - the new value
      Returns:
      a future that completes with the updated template, or null when the operation fails
    • applyTemplate

      public abstract CompletableFuture<MemberDTO> applyTemplate(@NotNull @NotNull org.bukkit.entity.Player operator, @NotNull @NotNull DominionDTO dominion, @NotNull @NotNull MemberDTO member, @NotNull @NotNull TemplateDTO template)
      Applies a template's privilege values to a dominion member. The operator must own the template and have the required dominion management privilege.
      Parameters:
      operator - the player applying the template
      dominion - the dominion containing the member
      member - the member to update
      template - the template to apply
      Returns:
      a future that completes with the updated member, or null when authorization or persistence fails