Skip to content

Economy Wrapper

Hempfest edited this page May 21, 2021 · 3 revisions

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