lucko/helper

IllegalStateException when creating scoreboard

devloper24 opened this issue · 5 comments

public void onPlayerJoinEvent(PlayerJoinEvent event) {
        val player = event.getPlayer();
        val playerData = Main.INSTANCE.getPlayerDataManager().registerPlayer(player);

        val scoreboardKey = MetadataKey.create("scoreboard", ScoreboardObjective.class);
        val scoreboard = Services.load(ScoreboardProvider.class).getScoreboard();

        val scoreboardObjective = scoreboard.createPlayerObjective(player, "null", DisplaySlot.SIDEBAR);
        Metadata.provideForPlayer(player).put(scoreboardKey, scoreboardObjective);

        Main.INSTANCE.getScoreboardManager().getUpdater().accept(player, scoreboardObjective);
    }

(mainly taken straight from the tutorial on the api page)
produced this error my console, with a scoreboard failing to be produced:

[06:32:22 ERROR]: [Core] [EVENTS] Exception thrown whilst handling event: org.bukkit.event.player.PlayerJoinEvent [06:32:22 WARN]: java.lang.IllegalStateException: No registration present for service 'me.lucko.helper.scoreboard.ScoreboardProvider' [06:32:22 WARN]: at me.lucko.helper.Services.lambda$load$0(Services.java:57) [06:32:22 WARN]: at java.util.Optional.orElseThrow(Optional.java:290) [06:32:22 WARN]: at me.lucko.helper.Services.load(Services.java:57) [06:32:22 WARN]: at me.devloper24.core.listener.impl.PlayerListener.onPlayerJoinEvent(PlayerListener.java:35) [06:32:22 WARN]: at me.lucko.helper.utils.Delegates$ConsumerToBiConsumerSecond.accept(Delegates.java:147) [06:32:22 WARN]: at me.lucko.helper.event.functional.single.HelperEventListener.execute(HelperEventListener.java:133) [06:32:22 WARN]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) [06:32:22 WARN]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [06:32:22 WARN]: at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) [06:32:22 WARN]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:314) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:173) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:875) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [06:32:22 WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [06:32:22 WARN]: at java.lang.Thread.run(Thread.java:748)
Any help would be appreciated.

Make sure ProtocolLib installed

already installed, I had the same issue with it both installed and not installed, which is causing me a lot of confusion

have you added a helpe in plugin.yml (or @plugin annotation) depends block ?

Yes, I have depends for ProtocolLib

lucko commented

Should be fixed in newer helper versions