Interface VaultHolder<T>
- Type Parameters:
T- The type of the underlying source (e.g., Chat, LuckPerms).
The VaultHolder interface encapsulates a source object (e.g., a permission provider)
and exposes a unified API to access common functionalities such as:
- Retrieving the underlying source instance
- Getting the host plugin
- Querying group memberships, prefixes, and suffixes for players
- Fetching available groups in the system
-
Method Summary
Modifier and TypeMethodDescriptiondefault <V> VfromSource(Function<T, V> function) Applies a transformation function to the underlying source.default @Nullable StringgetGroupPrefix(String group) A convenience method to retrieve the group prefix without specifying a world.@Nullable StringgetGroupPrefix(org.bukkit.World world, String group) Retrieves the group prefix for the specified group in the given world.Retrieves all available groups from the underlying source.getGroups(org.bukkit.entity.Player player) Retrieves all groups the specified player belongs to.default @Nullable StringgetGroupSuffix(String group) A convenience method to retrieve the group suffix without specifying a world.@Nullable StringgetGroupSuffix(org.bukkit.World world, String group) Retrieves the group suffix for the specified group in the given world.org.bukkit.plugin.PluginReturns the plugin associated with this holder.@Nullable StringgetPrefix(org.bukkit.entity.Player player) Retrieves the prefix of the specified player.@Nullable StringgetPrimaryGroup(org.bukkit.entity.Player player) Retrieves the primary group of the specified player.Retrieves the underlying source object that provides the core functionality.@Nullable StringgetSuffix(org.bukkit.entity.Player player) Retrieves the suffix of the specified player.booleanChecks whether the underlying source is currently enabled.booleanChecks if the specified player is a member of a given group.static VaultHolder<?> Loads and returns an appropriateVaultHolderinstance based on the enabled plugins.
-
Method Details
-
getSource
Retrieves the underlying source object that provides the core functionality. This could be an instance from a permission or chat plugin.- Returns:
- the underlying source instance
-
getPlugin
org.bukkit.plugin.Plugin getPlugin()Returns the plugin associated with this holder.Typically, this is the plugin that supplies the underlying source object.
- Returns:
- the associated
Pluginornullif unavailable
-
isEnabled
boolean isEnabled()Checks whether the underlying source is currently enabled.This can be used to determine if the related service is active before invoking any operations.
- Returns:
trueif the service is enabled;falseotherwise
-
fromSource
Applies a transformation function to the underlying source.This is a convenience method that allows for fluent extraction of data from the underlying source object.
- Type Parameters:
V- the type of the result- Parameters:
function- the function to apply to the source- Returns:
- the result of applying the function to the source
-
getPrimaryGroup
Retrieves the primary group of the specified player.Depending on the underlying system, this may return the most important group a player is assigned to.
- Parameters:
player- the player whose primary group is requested- Returns:
- the primary group name, or
nullif unavailable
-
isInGroup
Checks if the specified player is a member of a given group.This method abstracts the logic for determining group membership, which may vary between different permission systems.
- Parameters:
player- the player to checkgroup- the name of the group- Returns:
trueif the player is in the group;falseotherwise
-
getGroups
Retrieves all groups the specified player belongs to.- Parameters:
player- the player for whom to retrieve group memberships- Returns:
- a list of group names associated with the player
-
getPrefix
Retrieves the prefix of the specified player.The prefix is often used to display a player's rank or role before their name.
- Parameters:
player- the player whose prefix is requested- Returns:
- the prefix string, or
nullif unavailable
-
getSuffix
Retrieves the suffix of the specified player.The suffix is commonly used to show additional information, such as a team or status indicator.
- Parameters:
player- the player whose suffix is requested- Returns:
- the suffix string, or
nullif unavailable
-
getGroupPrefix
Retrieves the group prefix for the specified group in the given world.Group prefixes are used to represent the group in chat or on display.
- Parameters:
world- the world context (can benull)group- the group name- Returns:
- the group prefix, or
nullif not defined
-
getGroupPrefix
A convenience method to retrieve the group prefix without specifying a world.- Parameters:
group- the group name- Returns:
- the group prefix, or
nullif not defined
-
getGroupSuffix
Retrieves the group suffix for the specified group in the given world.Group suffixes can be used to display additional group-related information.
- Parameters:
world- the world context (can benull)group- the group name- Returns:
- the group suffix, or
nullif not defined
-
getGroupSuffix
A convenience method to retrieve the group suffix without specifying a world.- Parameters:
group- the group name- Returns:
- the group suffix, or
nullif not defined
-
getGroups
Retrieves all available groups from the underlying source.This method returns a comprehensive list of all group names, which can be used for administrative or display purposes.
- Returns:
- a list of all group names
-
loadHolder
Loads and returns an appropriateVaultHolderinstance based on the enabled plugins.This method first checks if LuckPerms is enabled; if so, it returns a new
HolderUtils.LuckHolder. Otherwise, it attempts to return aHolderUtils.BasicHolderfrom Vault's Chat API. If both attempts fail, it returns aHolderUtils.NoHolderinstance as a fallback.- Returns:
- a valid
VaultHolderinstance, or a fallbackHolderUtils.NoHolderif none is available
-