From 86b51df4128c41c3ecccd82394ff6b59d3ce4e46 Mon Sep 17 00:00:00 2001 From: BONNe Date: Mon, 28 Jan 2019 20:21:48 +0200 Subject: [PATCH] Update to BentoBox 1.2.0 In BentoBox 1.2 hooks are enabled before addons. --- .../bentobox/challenges/ChallengesAddon.java | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesAddon.java b/src/main/java/world/bentobox/challenges/ChallengesAddon.java index 6f4cc94..f4089c6 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesAddon.java +++ b/src/main/java/world/bentobox/challenges/ChallengesAddon.java @@ -40,9 +40,8 @@ public class ChallengesAddon extends Addon { /** * VaultHook that process economy. - * todo: because of BentoBox limitations. */ - private Optional vaultHook = null; + private VaultHook vaultHook; /** * Level addon. @@ -132,19 +131,18 @@ public class ChallengesAddon extends Addon { this.levelAddon = (Level) level.get(); } - // BentoBox limitation. Cannot check hooks, as HookManager is created after loading addons. -// Optional vault = this.getPlugin().getVault(); -// -// if (!vault.isPresent() || !vault.get().hook()) -// { -// this.vaultHook = null; -// this.logWarning("Economy plugin not found so money options will not work!"); -// } -// else -// { -// this.economyProvided = true; -// this.vaultHook = vault.get(); -// } + Optional vault = this.getPlugin().getVault(); + + if (!vault.isPresent() || !vault.get().hook()) + { + this.vaultHook = null; + this.logWarning("Economy plugin not found so money options will not work!"); + } + else + { + this.economyProvided = true; + this.vaultHook = vault.get(); + } // Register the reset listener this.registerListener(new ResetListener(this)); @@ -247,12 +245,6 @@ public class ChallengesAddon extends Addon { */ 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; } @@ -264,7 +256,7 @@ public class ChallengesAddon extends Addon { */ public VaultHook getEconomyProvider() { - return vaultHook.orElseGet(null); + return vaultHook; }