From fbe7f1579a553c596bfd274ab4a27f8e6aca98ea Mon Sep 17 00:00:00 2001 From: BONNe Date: Mon, 28 Jan 2019 08:49:43 +0200 Subject: [PATCH] Update to BentoBox 1.2 For users who are not ready to use unfinished Challenges 0.5 --- .../bentobox/challenges/ChallengesAddon.java | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/main/java/world/bentobox/challenges/ChallengesAddon.java b/src/main/java/world/bentobox/challenges/ChallengesAddon.java index 4d3f27d..55ed5d9 100644 --- a/src/main/java/world/bentobox/challenges/ChallengesAddon.java +++ b/src/main/java/world/bentobox/challenges/ChallengesAddon.java @@ -41,27 +41,20 @@ public class ChallengesAddon extends Addon { // Challenge import setup importManager = new FreshSqueezedChallenges(this); - // Register commands - run one tick later to allow all addons to load - // AcidIsland hook in - getPlugin().getAddonsManager().getAddonByName("AcidIsland").ifPresent(a -> { - CompositeCommand acidIslandCmd = getPlugin().getCommandsManager().getCommand("ai"); - if (acidIslandCmd != null) { - new ChallengesCommand(this, acidIslandCmd); - CompositeCommand acidCmd = getPlugin().getCommandsManager().getCommand("acid"); - new Challenges(this, acidCmd); - hooked = true; - } - }); - getPlugin().getAddonsManager().getAddonByName("BSkyBlock").ifPresent(a -> { - // BSkyBlock hook in - CompositeCommand bsbIslandCmd = getPlugin().getCommandsManager().getCommand("island"); - if (bsbIslandCmd != null) { - new ChallengesCommand(this, bsbIslandCmd); - CompositeCommand bsbAdminCmd = getPlugin().getCommandsManager().getCommand("bsbadmin"); - new Challenges(this, bsbAdminCmd); - hooked = true; + this.getPlugin().getAddonsManager().getGameModeAddons().forEach(gameModeAddon -> { + if (gameModeAddon.getPlayerCommand().isPresent()) + { + new ChallengesCommand(this, gameModeAddon.getPlayerCommand().get()); + this.hooked = true; + } + + if (gameModeAddon.getAdminCommand().isPresent()) + { + new Challenges(this, gameModeAddon.getAdminCommand().get()); + this.hooked = true; } }); + // If the add-on never hooks in, then it is useless if (!hooked) { logError("Challenges could not hook into AcidIsland or BSkyBlock so will not do anything!");