Skip to main content
Vault provides a unified API for economy, permissions, and chat plugins. Foundation’s Vault integration gives you easy access to these features without direct dependencies.

Check if loaded

Always verify Vault is available before using its features:
if (HookManager.isVaultLoaded()) {
    // Use Vault features
}

Economy integration

Check economy availability

Vault may be installed without an economy plugin:
if (HookManager.isEconomyIntegrated()) {
    // Economy plugin is available
}

Get player balance

double balance = HookManager.getBalance(player);
Common.tell(player, "Your balance: " + balance);

Withdraw money

if (HookManager.getBalance(player) >= 100) {
    HookManager.withdraw(player, 100);
    Common.tell(player, "Purchased for 100 coins!");
} else {
    Common.tell(player, "Insufficient funds!");
}

Deposit money

HookManager.deposit(player, 50);
Common.tell(player, "Added 50 to your balance!");

Currency names

String singular = HookManager.getCurrencySingular(); // "Dollar"
String plural = HookManager.getCurrencyPlural();     // "Dollars"

Common.tell(player, "You earned 1 " + singular);
Common.tell(player, "You have 100 " + plural);

Permissions integration

Get player’s primary group

String group = HookManager.getPlayerPrimaryGroup(player);
Common.tell(player, "Your rank: " + group);

Get permission group

String group = HookManager.getPlayerPermissionGroup(player);
// Returns all groups if player has multiple

Check permissions (Vault)

For offline players or special cases:
if (HookManager.isVaultLoaded()) {
    boolean hasPerm = HookManager.hasVaultPermission(offlinePlayer, "myplugin.admin");
}
For online players, use the standard Bukkit permission system (player.hasPermission()) instead.

Fast permission check

Optimized permission checking when you know Vault is loaded:
// Returns null if no permission plugin found
// Returns true/false based on permission check
Boolean result = HookManager.hasVaultPermissionFast(player, "permission.node");

if (result != null && result) {
    // Player has permission
}

Chat integration

Check chat availability

if (HookManager.isChatIntegrated()) {
    // Chat plugin is available (LuckPerms, etc.)
}

Get player prefix

String prefix = HookManager.getPlayerPrefix(player);
String message = prefix + player.getName() + ": Hello!";

Get player suffix

String suffix = HookManager.getPlayerSuffix(player);

Complete example

Here’s a practical shop system using Vault:
public class ShopCommand extends SimpleCommand {

    public ShopCommand() {
        super("shop");
    }

    @Override
    protected void onCommand() {
        Player player = getPlayer();
        
        // Ensure Vault and economy are available
        checkBoolean(HookManager.isVaultLoaded(), 
            "This server doesn't have Vault installed!");
        checkBoolean(HookManager.isEconomyIntegrated(), 
            "No economy plugin found!");
        
        String item = args[0];
        double price = 100.0;
        
        // Check balance
        double balance = HookManager.getBalance(player);
        
        if (balance < price) {
            String currency = HookManager.getCurrencyPlural();
            tellError("You need " + price + " " + currency + "!");
            tellError("Your balance: " + balance + " " + currency);
            return;
        }
        
        // Process purchase
        HookManager.withdraw(player, price);
        
        // Give item to player
        giveItem(player, item);
        
        String currency = price == 1 
            ? HookManager.getCurrencySingular()
            : HookManager.getCurrencyPlural();
            
        tellSuccess("Purchased " + item + " for " + price + " " + currency);
        tell("New balance: " + HookManager.getBalance(player));
    }
}

Permission group example

public void showPlayerInfo(Player player) {
    if (!HookManager.isVaultLoaded())
        return;
        
    String prefix = HookManager.getPlayerPrefix(player);
    String suffix = HookManager.getPlayerSuffix(player);
    String group = HookManager.getPlayerPrimaryGroup(player);
    
    Common.tell(player, "&7&m-----&r Your Info &7&m-----");
    Common.tell(player, "Prefix: " + prefix);
    Common.tell(player, "Suffix: " + suffix);
    Common.tell(player, "Group: " + group);
}

Implementation details

Foundation’s Vault hook automatically detects service providers:
VaultHook.java
void setIntegration() {
    final RegisteredServiceProvider<Economy> economyProvider = 
        Bukkit.getServicesManager().getRegistration(Economy.class);
    final RegisteredServiceProvider<Chat> chatProvider = 
        Bukkit.getServicesManager().getRegistration(Chat.class);
    final RegisteredServiceProvider<Permission> permProvider = 
        Bukkit.getServicesManager().getRegistration(Permission.class);

    if (economyProvider != null)
        this.economy = economyProvider.getProvider();

    if (chatProvider != null)
        this.chat = chatProvider.getProvider();

    if (permProvider != null)
        this.permissions = permProvider.getProvider();
}

Safe defaults

When Vault isn’t loaded, methods return safe defaults:
HookManager.java
public static double getBalance(final Player player) {
    return isVaultLoaded() ? vaultHook.getBalance(player) : 0;
}

public static String getPlayerPrefix(final Player player) {
    return isVaultLoaded() ? vaultHook.getPlayerPrefix(player) : "";
}

public static String getCurrencySingular() {
    return isVaultLoaded() ? vaultHook.getCurrencyNameSG() : "";
}
Always check isVaultLoaded() before using Vault features. While methods return safe defaults, you should inform users if economy features aren’t available.

Supported economy plugins

Vault works with these economy plugins:
  • EssentialsX Economy
  • CMI Economy
  • PlayerPoints
  • TokenManager
  • GemsEconomy
  • And many more

Supported permission plugins

Vault works with these permission plugins:
  • LuckPerms
  • PermissionsEx
  • GroupManager
  • bPermissions
  • zPermissions

Build docs developers (and LLMs) love