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?

Legacy Vault Migration Guide

Migrating from the legacy Vault API to OlaVault is straightforward. OlaVault was designed to solve Vault's largest issues: lack of thread-safety, lack of events, and floating-point inaccuracy.

1. Updating Dependencies

Remove the legacy Vault API from your build.gradle.kts / pom.xml and replace it with OlaVault:

Gradle (Kotlin DSL)

dependencies {
    compileOnly("com.olaneria.repo:olavault-api:1.0.2")
}

Gradle (Groovy DSL)

dependencies {
    compileOnly 'com.olaneria.repo:olavault-api:1.0.2'
}

Maven (pom.xml)

<dependencies>
    <dependency>
        <groupId>com.olaneria.repo</groupId>
        <artifactId>olavault-api</artifactId>
        <version>1.0.2</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

2. Accessing the API (Consumers)

In legacy Vault, you had to manually query the ServicesManager or write boilerplate setup methods to find the providers. In OlaVault, this is done via static lock-free caches.

Legacy Vault:

RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp != null) {
    Economy econ = rsp.getProvider();
}

OlaVault:

import com.olaneria.olavault.api.OlaVault;
import com.olaneria.olavault.api.Economy;

Economy econ = OlaVault.getEconomy();
if (econ != null) {
    // Ready to use!
}

3. Waiting for Providers safely

Because server owners might install an Economy plugin that loads after your plugin, you shouldn't just check OlaVault.getEconomy() in onEnable() and give up if it's null.

Instead, listen to ProviderReadyEvent:

import com.olaneria.olavault.api.events.ProviderReadyEvent;
import org.bukkit.event.EventHandler;

@EventHandler
public void onProviderReady(ProviderReadyEvent event) {
    if (event.getServiceType() == ProviderReadyEvent.ServiceType.ECONOMY) {
        getLogger().info("Economy provider found! Initializing shops...");
    }
}

4. BigDecimal vs Double

The largest change when interacting with the Economy API is that all transactions now strictly use java.math.BigDecimal instead of double.

Legacy Vault:

econ.withdrawPlayer(player, 10.50);

OlaVault:

econ.withdraw(player.getUniqueId(), BigDecimal.valueOf(10.50));

5. Event-Driven Updates

If you are maintaining a Scoreboard plugin or GUI, you no longer need to use Bukkit.getScheduler().runTaskTimer to constantly poll player balances or permission groups.

Simply listen to the API's events!

  • EconomyTransactionEvent
  • PlayerGroupChangeEvent
  • PlayerPrimaryGroupChangeEvent
  • PlayerMetaChangeEvent
  • PlayerPermissionChangeEvent