Remove EagerlyLoaded from MVCommandManager.

This commit is contained in:
Jeremy Wood 2023-03-26 13:01:08 -04:00
parent 8b244e7d3b
commit e8a33c0cdf
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
2 changed files with 9 additions and 4 deletions

View File

@ -59,6 +59,8 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
private Provider<MVWorldManager> worldManagerProvider;
@Inject
private Provider<AnchorManager> anchorManagerProvider;
@Inject
private Provider<MVCommandManager> 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));
}
/**

View File

@ -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;