I want to register my own PermissionService
to Sponge, but when i try to add it to the ServiceManager
it says there is already one. Am i doing something wrong?
This is the method that adds the service:
@Override
public void init() throws ProviderExistsException {
logger.info("Current GameState: " + game.getState());
logger.info("Current Permission Service: " + game.getServiceManager().provide(PermissionService.class).orElse(null));
game.getServiceManager().setProvider(Plugin.getInstance(), PermissionService.class, this);
}
And that’s the resulting log:
[01:41:28] [Server thread/INFO] [CNPlugin]: Adding module: de.craftednature.sponge.cnplugin.permission.PermissionHandler
[01:41:28] [Server thread/INFO] [CNPlugin]: Current GameState: INITIALIZATION
[01:41:28] [Server thread/INFO] [CNPlugin]: Current Permission Service: org.spongepowered.common.service.permission.SpongePermissionService@650d2fc6
[01:41:28] [Server thread/ERROR] [CNPlugin]: Failed to init module: de.craftednature.sponge.cnplugin.permission.PermissionHandler
org.spongepowered.api.service.ProviderExistsException: Provider for service org.spongepowered.api.service.permission.PermissionService has already been registered!
at org.spongepowered.api.service.SimpleServiceManager.setProvider(SimpleServiceManager.java:85) ~[SimpleServiceManager.class:1.8-1577-2.1-DEV-922]
at de.craftednature.sponge.cnplugin.permission.PermissionHandler.init(PermissionHandler.java:53) ~[PermissionHandler.class:?]
at de.craftednature.sponge.cnplugin.Main.addModule(Main.java:74) [Main.class:?]
at de.craftednature.sponge.cnplugin.Plugin.init(Plugin.java:49) [Plugin.class:?]
at org.spongepowered.common.event.listener.GameInitializationEventListener_Plugin_init1.handle(Unknown Source) [?:?]
at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:86) [RegisteredListener.class:1.8-1577-2.1-DEV-922]
at org.spongepowered.common.event.SpongeEventManager.post(SpongeEventManager.java:247) [SpongeEventManager.class:1.8-1577-2.1-DEV-922]
at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:274) [SpongeModEventManager.class:1.8-1577-2.1-DEV-922]
at org.spongepowered.mod.SpongeMod.onStateEvent(SpongeMod.java:171) [SpongeMod.class:1.8-1577-2.1-DEV-922]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) [LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [minecraft_server.1.8.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [minecraft_server.1.8.jar:?]
at net.minecraftforge.fml.common.LoadController.onPost(LoadController.java:49) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:731) [Loader.class:?]
at net.minecraftforge.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:97) [FMLServerHandler.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:360) [FMLCommonHandler.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:210) [po.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]