Interface ConfigurableUnit
A ConfigurableUnit provides methods to access the underlying ConfigurationSection,
retrieve its name, permission, group, and priority settings, and perform permission and group checks
on a CommandSender. It serves as a basic unit for representing configuration-based access control.
The interface also includes static factory methods to create new instances based on an existing
ConfigurationSection or another ConfigurableUnit.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable StringgetGroup()Gets the group associated with this unit.default @NotNull StringgetName()Gets the name of the configuration section.default @NotNull StringGets the permission associated with this unit.default intGets the priority associated with this unit.@NotNull org.bukkit.configuration.ConfigurationSectionGets the configuration section associated with this unit.default booleanhasPerm(org.bukkit.command.CommandSender sender) Checks if the given command sender has the permission associated with this unit.booleanisInGroup(org.bukkit.command.CommandSender sender) Checks if the given command sender is in the group associated with this unit.default booleanisInGroupAsNull(org.bukkit.command.CommandSender sender) Checks if the group associated with this unit is blank or the given sender is in that group.default booleanisInGroupNonNull(org.bukkit.command.CommandSender sender) Checks if the group associated with this unit is not blank and the given sender is in that group.static ConfigurableUnitof(ConfigurableUnit unit) Creates a newConfigurableUnitinstance based on the providedConfigurableUnit.static ConfigurableUnitof(org.bukkit.configuration.ConfigurationSection section) Creates a newConfigurableUnitinstance based on the provided configuration section.
-
Method Details
-
getSection
@NotNull @NotNull org.bukkit.configuration.ConfigurationSection getSection() throws NullPointerExceptionGets the configuration section associated with this unit.- Returns:
- the configuration section (never
null). - Throws:
NullPointerException- if the configuration section is null.
-
getName
Gets the name of the configuration section.- Returns:
- the name of the configuration section.
-
getPermission
Gets the permission associated with this unit.- Returns:
- the permission string; if not specified, returns "DEFAULT".
-
hasPerm
default boolean hasPerm(org.bukkit.command.CommandSender sender) Checks if the given command sender has the permission associated with this unit.- Parameters:
sender- the command sender.- Returns:
trueif the sender has the permission,falseotherwise.
-
getGroup
Gets the group associated with this unit.- Returns:
- the group string, or
nullif not specified.
-
isInGroup
boolean isInGroup(org.bukkit.command.CommandSender sender) Checks if the given command sender is in the group associated with this unit.- Parameters:
sender- the command sender.- Returns:
trueif the sender is in the group,falseotherwise.
-
isInGroupNonNull
default boolean isInGroupNonNull(org.bukkit.command.CommandSender sender) Checks if the group associated with this unit is not blank and the given sender is in that group.- Parameters:
sender- the command sender.- Returns:
trueif the group is not blank and the sender is in that group,falseotherwise.
-
isInGroupAsNull
default boolean isInGroupAsNull(org.bukkit.command.CommandSender sender) Checks if the group associated with this unit is blank or the given sender is in that group.- Parameters:
sender- the command sender.- Returns:
trueif the group is blank or the sender is in that group,falseotherwise.
-
getPriority
default int getPriority()Gets the priority associated with this unit.The priority is determined by the "priority" value in the configuration section. If not specified, it returns 0 when the permission is "DEFAULT" (case-insensitive), and 1 otherwise.
- Returns:
- the priority value.
-
of
Creates a newConfigurableUnitinstance based on the provided configuration section.This factory method returns a simple implementation of
ConfigurableUnitwhere the group check always returnstrue.- Parameters:
section- the configuration section.- Returns:
- a new
ConfigurableUnitinstance. - Throws:
NullPointerException- if the configuration section is null.
-
of
Creates a newConfigurableUnitinstance based on the providedConfigurableUnit.- Parameters:
unit- the existingConfigurableUnitinstance.- Returns:
- a new
ConfigurableUnitinstance based on the unit's configuration section.
-