Skip to content

Economy Bridge

Hempfest edited this page Sep 3, 2021 · 2 revisions

The connection for the interfaces.

Get the bridge instance:

	EconomyProvision provision = EconomyProvision.getInstance();

Wrapping both VaultEco & EnterpriseEco support.

(AdvancedEco has highest priority only if validated)


As you can see below its simply a wrapper forming around both vault and our own interface. 
It accepts the use of multi world and has account support aswell.
public class PlayerWrapperObject {

	private final OfflinePlayer player;
	private final EconomyProvision provision;

	public PlayerWrapperObject(OfflinePlayer op) {
		this.player = op;
		this.provision = EconomyProvision.getInstance();
	}

	public boolean has(double amount) {
		return provision.has(BigDecimal.valueOf(amount), player).orElse(false);
	}

	public boolean deposit(double amount) {
		return provision.deposit(BigDecimal.valueOf(amount), player).orElse(false);
	}

	public boolean withdraw(double amount) {
		return provision.withdraw(BigDecimal.valueOf(amount), player).orElse(false);
	}


}

If you so choose you can provide your own economy wrapper using the provision abstraction. We simply register a service on start up.

Clone this wiki locally