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
A logical, ordered group of flags used for presentation and bulk editing.
Flag groups do not participate in permission evaluation.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFlagGroup(@NotNull String id, @NotNull String displayName, @NotNull String description, @NotNull org.bukkit.Material material, @NotNull Class<T> flagType, @NotNull Collection<? extends T> flags) Constructs a flag group without a Dialog UI icon.protectedFlagGroup(@NotNull String id, @NotNull String displayName, @NotNull String description, @NotNull org.bukkit.Material material, @Nullable String icon, @NotNull Class<T> flagType, @NotNull Collection<? extends T> flags) Constructs a flag group. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a flag to this group.booleancontainsFlag(T flag) Checks whether this group contains a flag.final @NotNull StringReturns theflags.ymlkey for this group's Dialog UI icon.@NotNull StringGets the group's description.final @NotNull StringReturns the language key used for this group's description.@NotNull StringGets the group's display name.final @NotNull StringReturns the language key used for this group's display name.getFlags()Gets the flags in their configured order.Gets the flag type accepted by this group.@Nullable StringgetIcon()Gets the native Dialog UI sprite path for this group.final @NotNull StringgetId()Gets the stable identifier of this group.protected abstract @NotNull StringGets the language-file namespace used by this group type.@NotNull org.bukkit.MaterialGets the material used to represent this group in chest UIs.booleanremoveFlag(T flag) Removes a flag from this group.voidsetDescription(@NotNull String description) Sets the group's description.voidsetDisplayName(@NotNull String displayName) Sets the group's display name.voidSets the native Dialog UI sprite path.voidsetMaterial(@NotNull org.bukkit.Material material) Sets the material used to represent this group in chest UIs.
-
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 identifierdisplayName- the default display namedescription- the default descriptionmaterial- the material used to represent the group in chest UIsflagType- the concrete flag type accepted by the groupflags- 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 namedescription- the default descriptionmaterial- the material used to represent the group in chest UIsicon- the Dialog UI sprite path, ornullfor no iconflagType- the concrete flag type accepted by the groupflags- the initial flags, kept in iteration order- Throws:
IllegalArgumentException- ifidis not a valid group identifier
-
-
Method Details
-
getId
Gets the stable identifier of this group.- Returns:
- the group identifier
-
getDisplayName
Gets the group's display name.- Returns:
- the display name
-
setDisplayName
Sets the group's display name.- Parameters:
displayName- the new display name
-
getDescription
Gets the group's description.- Returns:
- the description
-
setDescription
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
Gets the native Dialog UI sprite path for this group.- Returns:
- the sprite path, or
nullwhen the group has no icon
-
setIcon
Sets the native Dialog UI sprite path. Null or blank means that this group has no Dialog UI icon.- Parameters:
icon- the sprite path, ornullto remove the icon
-
addFlag
Adds a flag to this group.- Parameters:
flag- the flag to add- Returns:
trueif the flag was not already present- Throws:
IllegalArgumentException- if the flag is not an instance of this group's flag type
-
removeFlag
Removes a flag from this group.- Parameters:
flag- the flag to remove- Returns:
trueif the flag was present
-
containsFlag
Checks whether this group contains a flag.- Parameters:
flag- the flag to look up- Returns:
trueif the flag is in this group
-
getFlags
Gets the flags in their configured order.- Returns:
- an immutable snapshot of the group's flags
-
getFlagType
Gets the flag type accepted by this group.- Returns:
- the concrete flag class
-
getDisplayNameKey
Returns the language key used for this group's display name.- Returns:
- language key for the display name
-
getDescriptionKey
Returns the language key used for this group's description.- Returns:
- language key for the description
-
getConfigurationDialogUiIconKey
Returns theflags.ymlkey for this group's Dialog UI icon.- Returns:
- the configuration key for the group's icon
-
getLanguageNamespace
Gets the language-file namespace used by this group type.- Returns:
- the language namespace
-