Welcome to the Hangar Open Beta. Please report any issue you encounter on GitHub!
Avatar for Olaneria

The all new modern version of Vault API.

Report OlaVault?

Provider Implementation Guide

If you are developing a plugin that manages economy, permissions, or chat (e.g., an Economy core, or a permissions manager), you need to register yourself as the service provider for OlaVault.

1. Implement the API Interface

First, create a class that implements the respective interface. OlaVault has three core interfaces:

  • Economy
  • Permissions
  • Chat

Example: Economy Provider

import com.olaneria.olavault.api.Economy;
import com.olaneria.olavault.api.TransactionResult;
import org.jetbrains.annotations.NotNull;
import java.math.BigDecimal;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

public class MyCustomEconomy implements Economy {

    @Override
    public @NotNull String getName() {
        return "MyCustomEconomy";
    }

    @Override
    public @NotNull Set<String> getSupportedCurrencies() {
        return Set.of("coins", "gems");
    }

    @Override
    public @NotNull String getDefaultCurrency() {
        return "coins";
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    // ... Implement the rest of the required methods
}

2. Register the Provider to Bukkit

In your plugin's onEnable(), you must register your implementation using Bukkit's built-in ServicesManager. OlaVault automatically listens to this registry.

@Override
public void onEnable() {
    MyCustomEconomy myEconomy = new MyCustomEconomy();
    
    getServer().getServicesManager().register(
        Economy.class,
        myEconomy, 
        this,
        org.bukkit.plugin.ServicePriority.Normal
    );
    
    getLogger().info("Successfully registered as an OlaVault Economy Provider!");
}

3. Firing Events

Unlike the legacy Vault API where consumer plugins had to constantly poll data (like checking a player's balance repeatedly), OlaVault is completely event-driven.

As a provider, you are highly encouraged to fire the appropriate Bukkit events located in com.olaneria.olavault.api.events whenever a change occurs in your system.

For example, when a transaction succeeds:

getServer().getPluginManager().callEvent(
    new EconomyTransactionEvent(
        playerUuid,
        "coins",
        TransactionResult.TransactionType.DEPOSIT,
        amount,
        newBalance
    )
);

This ensures that Scoreboard plugins, GUIs, and other consumers update instantly without lag!