Update to BentoBox 1.2.0

In BentoBox 1.2 hooks are enabled before addons.
This commit is contained in:
BONNe 2019-01-28 20:21:48 +02:00
parent c304dba5e3
commit 86b51df412

View File

@ -40,9 +40,8 @@ public class ChallengesAddon extends Addon {
/** /**
* VaultHook that process economy. * VaultHook that process economy.
* todo: because of BentoBox limitations.
*/ */
private Optional<VaultHook> vaultHook = null; private VaultHook vaultHook;
/** /**
* Level addon. * Level addon.
@ -132,19 +131,18 @@ public class ChallengesAddon extends Addon {
this.levelAddon = (Level) level.get(); this.levelAddon = (Level) level.get();
} }
// BentoBox limitation. Cannot check hooks, as HookManager is created after loading addons. Optional<VaultHook> vault = this.getPlugin().getVault();
// Optional<VaultHook> vault = this.getPlugin().getVault();
// if (!vault.isPresent() || !vault.get().hook())
// if (!vault.isPresent() || !vault.get().hook()) {
// { this.vaultHook = null;
// this.vaultHook = null; this.logWarning("Economy plugin not found so money options will not work!");
// this.logWarning("Economy plugin not found so money options will not work!"); }
// } else
// else {
// { this.economyProvided = true;
// this.economyProvided = true; this.vaultHook = vault.get();
// this.vaultHook = vault.get(); }
// }
// Register the reset listener // Register the reset listener
this.registerListener(new ResetListener(this)); this.registerListener(new ResetListener(this));
@ -247,12 +245,6 @@ public class ChallengesAddon extends Addon {
*/ */
public boolean isEconomyProvided() public boolean isEconomyProvided()
{ {
if (!this.economyProvided && this.getPlugin().getVault().isPresent() && this.vaultHook == null)
{
this.vaultHook = this.getPlugin().getVault();
this.economyProvided = this.vaultHook.get().hook();
}
return this.economyProvided; return this.economyProvided;
} }
@ -264,7 +256,7 @@ public class ChallengesAddon extends Addon {
*/ */
public VaultHook getEconomyProvider() public VaultHook getEconomyProvider()
{ {
return vaultHook.orElseGet(null); return vaultHook;
} }