Interface VaultHolder<T>

Type Parameters:
T - The type of the underlying source (e.g., Chat, LuckPerms).

public interface VaultHolder<T>
An abstraction for interfacing with various permission and chat systems, typically provided by plugins like Vault, LuckPerms, and others.

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 Type
    Method
    Description
    default <V> V
    fromSource(Function<T,V> function)
    Applies a transformation function to the underlying source.
    default @Nullable String
    A convenience method to retrieve the group prefix without specifying a world.
    @Nullable String
    getGroupPrefix(org.bukkit.World world, String group)
    Retrieves the group prefix for the specified group in the given world.
    @NotNull List<String>
    Retrieves all available groups from the underlying source.
    @NotNull List<String>
    getGroups(org.bukkit.entity.Player player)
    Retrieves all groups the specified player belongs to.
    default @Nullable String
    A convenience method to retrieve the group suffix without specifying a world.
    @Nullable String
    getGroupSuffix(org.bukkit.World world, String group)
    Retrieves the group suffix for the specified group in the given world.
    org.bukkit.plugin.Plugin
    Returns the plugin associated with this holder.
    @Nullable String
    getPrefix(org.bukkit.entity.Player player)
    Retrieves the prefix of the specified player.
    @Nullable String
    getPrimaryGroup(org.bukkit.entity.Player player)
    Retrieves the primary group of the specified player.
    Retrieves the underlying source object that provides the core functionality.
    @Nullable String
    getSuffix(org.bukkit.entity.Player player)
    Retrieves the suffix of the specified player.
    boolean
    Checks whether the underlying source is currently enabled.
    boolean
    isInGroup(org.bukkit.entity.Player player, String group)
    Checks if the specified player is a member of a given group.
    static VaultHolder<?>
    Loads and returns an appropriate VaultHolder instance based on the enabled plugins.
  • Method Details

    • getSource

      @NotNull T 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 Plugin or null if 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:
      true if the service is enabled; false otherwise
    • fromSource

      default <V> V fromSource(Function<T,V> function)
      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

      @Nullable @Nullable String getPrimaryGroup(org.bukkit.entity.Player player)
      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 null if unavailable
    • isInGroup

      boolean isInGroup(org.bukkit.entity.Player player, String group)
      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 check
      group - the name of the group
      Returns:
      true if the player is in the group; false otherwise
    • getGroups

      @NotNull @NotNull List<String> getGroups(org.bukkit.entity.Player player)
      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

      @Nullable @Nullable String getPrefix(org.bukkit.entity.Player player)
      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 null if unavailable
    • getSuffix

      @Nullable @Nullable String getSuffix(org.bukkit.entity.Player player)
      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 null if unavailable
    • getGroupPrefix

      @Nullable @Nullable String getGroupPrefix(org.bukkit.World world, String group)
      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 be null)
      group - the group name
      Returns:
      the group prefix, or null if not defined
    • getGroupPrefix

      @Nullable default @Nullable String getGroupPrefix(String group)
      A convenience method to retrieve the group prefix without specifying a world.
      Parameters:
      group - the group name
      Returns:
      the group prefix, or null if not defined
    • getGroupSuffix

      @Nullable @Nullable String getGroupSuffix(org.bukkit.World world, String group)
      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 be null)
      group - the group name
      Returns:
      the group suffix, or null if not defined
    • getGroupSuffix

      @Nullable default @Nullable String getGroupSuffix(String group)
      A convenience method to retrieve the group suffix without specifying a world.
      Parameters:
      group - the group name
      Returns:
      the group suffix, or null if not defined
    • getGroups

      @NotNull @NotNull List<String> 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

      static VaultHolder<?> loadHolder()
      Loads and returns an appropriate VaultHolder instance 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 a HolderUtils.BasicHolder from Vault's Chat API. If both attempts fail, it returns a HolderUtils.NoHolder instance as a fallback.

      Returns:
      a valid VaultHolder instance, or a fallback HolderUtils.NoHolder if none is available