Class FlagGroup<T extends Flag>

java.lang.Object
cn.lunadeer.dominion.api.dtos.flag.FlagGroup<T>
Type Parameters:
T - the supported flag type
Direct Known Subclasses:
EnvFlagGroup, PriFlagGroup

public abstract class FlagGroup<T extends Flag> extends Object
A logical, ordered group of flags used for presentation and bulk editing. Flag groups do not participate in permission evaluation.
  • Constructor Details

    • FlagGroup

      protected FlagGroup(@NotNull @NotNull String id, @NotNull @NotNull String displayName, @NotNull @NotNull String description, @NotNull @NotNull org.bukkit.Material material, @NotNull @NotNull Class<T> flagType, @NotNull @NotNull Collection<? extends T> flags)
      Constructs a flag group without a Dialog UI icon.
      Parameters:
      id - the stable group identifier
      displayName - the default display name
      description - the default description
      material - the material used to represent the group in chest UIs
      flagType - the concrete flag type accepted by the group
      flags - the initial flags, kept in iteration order
    • FlagGroup

      protected FlagGroup(@NotNull @NotNull String id, @NotNull @NotNull String displayName, @NotNull @NotNull String description, @NotNull @NotNull org.bukkit.Material material, @Nullable @Nullable String icon, @NotNull @NotNull Class<T> flagType, @NotNull @NotNull Collection<? extends T> flags)
      Constructs a flag group.
      Parameters:
      id - the stable group identifier; it must match [a-z0-9_-]+
      displayName - the default display name
      description - the default description
      material - the material used to represent the group in chest UIs
      icon - the Dialog UI sprite path, or null for no icon
      flagType - the concrete flag type accepted by the group
      flags - the initial flags, kept in iteration order
      Throws:
      IllegalArgumentException - if id is not a valid group identifier
  • Method Details

    • getId

      @NotNull public final @NotNull String getId()
      Gets the stable identifier of this group.
      Returns:
      the group identifier
    • getDisplayName

      @NotNull public @NotNull String getDisplayName()
      Gets the group's display name.
      Returns:
      the display name
    • setDisplayName

      public void setDisplayName(@NotNull @NotNull String displayName)
      Sets the group's display name.
      Parameters:
      displayName - the new display name
    • getDescription

      @NotNull public @NotNull String getDescription()
      Gets the group's description.
      Returns:
      the description
    • setDescription

      public void setDescription(@NotNull @NotNull String description)
      Sets the group's description.
      Parameters:
      description - the new description
    • getMaterial

      @NotNull public @NotNull org.bukkit.Material getMaterial()
      Gets the material used to represent this group in chest UIs.
      Returns:
      the group's material
    • setMaterial

      public void setMaterial(@NotNull @NotNull org.bukkit.Material material)
      Sets the material used to represent this group in chest UIs.
      Parameters:
      material - the new material
    • getIcon

      @Nullable public @Nullable String getIcon()
      Gets the native Dialog UI sprite path for this group.
      Returns:
      the sprite path, or null when the group has no icon
    • setIcon

      public void setIcon(@Nullable @Nullable String icon)
      Sets the native Dialog UI sprite path. Null or blank means that this group has no Dialog UI icon.
      Parameters:
      icon - the sprite path, or null to remove the icon
    • addFlag

      public boolean addFlag(@NotNull T flag)
      Adds a flag to this group.
      Parameters:
      flag - the flag to add
      Returns:
      true if the flag was not already present
      Throws:
      IllegalArgumentException - if the flag is not an instance of this group's flag type
    • removeFlag

      public boolean removeFlag(@NotNull T flag)
      Removes a flag from this group.
      Parameters:
      flag - the flag to remove
      Returns:
      true if the flag was present
    • containsFlag

      public boolean containsFlag(@NotNull T flag)
      Checks whether this group contains a flag.
      Parameters:
      flag - the flag to look up
      Returns:
      true if the flag is in this group
    • getFlags

      @NotNull public @NotNull List<T> getFlags()
      Gets the flags in their configured order.
      Returns:
      an immutable snapshot of the group's flags
    • getFlagType

      @NotNull public final @NotNull Class<T> getFlagType()
      Gets the flag type accepted by this group.
      Returns:
      the concrete flag class
    • getDisplayNameKey

      @NotNull public final @NotNull String getDisplayNameKey()
      Returns the language key used for this group's display name.
      Returns:
      language key for the display name
    • getDescriptionKey

      @NotNull public final @NotNull String getDescriptionKey()
      Returns the language key used for this group's description.
      Returns:
      language key for the description
    • getConfigurationDialogUiIconKey

      @NotNull public final @NotNull String getConfigurationDialogUiIconKey()
      Returns the flags.yml key for this group's Dialog UI icon.
      Returns:
      the configuration key for the group's icon
    • getLanguageNamespace

      @NotNull protected abstract @NotNull String getLanguageNamespace()
      Gets the language-file namespace used by this group type.
      Returns:
      the language namespace