diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index e95c5f65..bae6d47e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -52,12 +52,13 @@ import org.jvnet.hk2.annotations.Service; public class MultiverseCore extends JavaPlugin implements MVCore { private static final int PROTOCOL = 50; - // Setup various managers private ServiceLocator serviceLocator; @Inject + private MVCoreConfigProvider configProvider; + @Inject private Provider worldManagerProvider; @Inject - private MVCoreConfigProvider configProvider; + private Provider anchorManagerProvider; // Counter for the number of plugins that have registered with us private int pluginCount; @@ -119,8 +120,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore { // this.economist = new MVEconomist(this); // Init all the other stuff - // TODO consider moving this into the AnchorManager constructor - serviceLocator.getService(AnchorManager.class).loadAnchors(); + this.loadAnchors(); this.registerEvents(); this.registerCommands(); this.setUpLocales(); @@ -164,6 +164,12 @@ public class MultiverseCore extends JavaPlugin implements MVCore { return !getConfigProvider().getConfig().getSilentStart(); } + private void loadAnchors() { + Try.of(() -> anchorManagerProvider.get()) + .onSuccess(AnchorManager::loadAnchors) + .onFailure(throwable -> Logging.severe("Failed to load anchors", throwable)); + } + /** * Function to Register all the Events needed. */ diff --git a/src/main/java/com/onarandombox/MultiverseCore/anchor/AnchorManager.java b/src/main/java/com/onarandombox/MultiverseCore/anchor/AnchorManager.java index 1b3c28d7..18cfa0d5 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/anchor/AnchorManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/anchor/AnchorManager.java @@ -11,7 +11,6 @@ import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.LocationManipulation; import com.onarandombox.MultiverseCore.config.MVCoreConfigProvider; -import com.onarandombox.MultiverseCore.inject.EagerlyLoaded; import jakarta.inject.Inject; import org.bukkit.Location; import org.bukkit.configuration.ConfigurationSection; @@ -33,7 +32,7 @@ import java.util.Set; * Manages anchors. */ @Service -public class AnchorManager implements EagerlyLoaded { +public class AnchorManager { private Map anchors; private FileConfiguration anchorConfig; diff --git a/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt b/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt index 69848840..cf4c354c 100644 --- a/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt @@ -18,7 +18,6 @@ import com.onarandombox.MultiverseCore.listeners.MVPortalListener import com.onarandombox.MultiverseCore.listeners.MVWeatherListener import com.onarandombox.MultiverseCore.listeners.MVWorldInitListener import com.onarandombox.MultiverseCore.listeners.MVWorldListener -import com.onarandombox.MultiverseCore.placeholders.MultiverseCorePlaceholders import com.onarandombox.MultiverseCore.teleportation.SimpleBlockSafety import com.onarandombox.MultiverseCore.teleportation.SimpleLocationManipulation import com.onarandombox.MultiverseCore.teleportation.SimpleSafeTTeleporter