Package cn.lunadeer.dominion.providers
Class TemplateProvider
java.lang.Object
cn.lunadeer.dominion.providers.TemplateProvider
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static TemplateProviderThe provider instance initialized by Dominion. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract CompletableFuture<MemberDTO>applyTemplate(@NotNull org.bukkit.entity.Player operator, @NotNull DominionDTO dominion, @NotNull MemberDTO member, @NotNull TemplateDTO template) Applies a template's privilege values to a dominion member.abstract CompletableFuture<TemplateDTO>createTemplate(@NotNull org.bukkit.entity.Player operator, @NotNull String name) Creates a template owned by the operator.abstract CompletableFuture<TemplateDTO>deleteTemplate(@NotNull org.bukkit.entity.Player operator, @NotNull TemplateDTO template) Deletes a template owned by the operator.static TemplateProviderGets the initialized provider instance.abstract @Nullable TemplateDTOgetTemplate(@NotNull UUID creator, @NotNull Integer id) Looks up a template by owner and numeric identifier.abstract @Nullable TemplateDTOgetTemplate(@NotNull UUID creator, @NotNull String name) Looks up a template by owner and name.abstract @NotNull List<TemplateDTO>getTemplates(@NotNull UUID creator) Gets all templates owned by a player.abstract CompletableFuture<TemplateDTO>renameTemplate(@NotNull org.bukkit.entity.Player operator, @NotNull TemplateDTO template, @NotNull String newName) Renames a template owned by the operator.abstract CompletableFuture<TemplateDTO>setTemplateFlag(@NotNull org.bukkit.entity.Player operator, @NotNull TemplateDTO template, @NotNull PriFlag flag, boolean value) Sets a privilege value in a template owned by the operator.
-
Field Details
-
instance
The provider instance initialized by Dominion.
-
-
Constructor Details
-
TemplateProvider
public TemplateProvider()
-
-
Method Details
-
getInstance
Gets the initialized provider instance.- Returns:
- the provider, or
nullbefore Dominion initialization
-
getTemplates
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 UUIDname- the template name- Returns:
- the matching template, or
nullwhen 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 UUIDid- the template identifier- Returns:
- the matching template, or
nullwhen 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 templatename- the new template name- Returns:
- a future that completes with the created template, or
nullwhen 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 ownertemplate- the template to renamenewName- the new template name- Returns:
- a future that completes with the renamed template, or
nullwhen 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 ownertemplate- the template to delete- Returns:
- a future that completes with the deleted template, or
nullwhen 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 ownertemplate- the template to updateflag- the privilege flagvalue- the new value- Returns:
- a future that completes with the updated template, or
nullwhen 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 templatedominion- the dominion containing the membermember- the member to updatetemplate- the template to apply- Returns:
- a future that completes with the updated member, or
nullwhen authorization or persistence fails
-