diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index bae6d47e..b7292209 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -59,6 +59,8 @@ public class MultiverseCore extends JavaPlugin implements MVCore { private Provider worldManagerProvider; @Inject private Provider anchorManagerProvider; + @Inject + private Provider commandManagerProvider; // Counter for the number of plugins that have registered with us private int pluginCount; @@ -183,8 +185,12 @@ public class MultiverseCore extends JavaPlugin implements MVCore { * Register Multiverse-Core commands to Command Manager. */ private void registerCommands() { - var commandManager = serviceLocator.getService(MVCommandManager.class); - serviceLocator.getAllServices(MultiverseCommand.class).forEach(commandManager::registerCommand); + Try.of(() -> commandManagerProvider.get()) + .andThenTry(commandManager -> { + serviceLocator.getAllServices(MultiverseCommand.class) + .forEach(commandManager::registerCommand); + }) + .onFailure(throwable -> Logging.severe("Failed to register commands", throwable)); } /** diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java index a65a3228..b64236ce 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java @@ -13,7 +13,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.commandtools.flags.CommandFlagsManager; import com.onarandombox.MultiverseCore.commandtools.queue.CommandQueueManager; -import com.onarandombox.MultiverseCore.inject.EagerlyLoaded; import jakarta.inject.Inject; import jakarta.inject.Provider; import org.jetbrains.annotations.NotNull; @@ -23,7 +22,7 @@ import org.jvnet.hk2.annotations.Service; * Main class to manage permissions. */ @Service -public class MVCommandManager extends PaperCommandManager implements EagerlyLoaded { +public class MVCommandManager extends PaperCommandManager { private final CommandFlagsManager flagsManager; private final CommandQueueManager commandQueueManager;