LuckPerms

LuckPerms

905k Downloads

Neoforge Capability has not been initialised

Belu97 opened this issue · 4 comments

commented

Description

Hey, I added the luckperms neoforge mod to my modpack server ( all mods 10) v 0.38 I got the kick message in the client "Internal Exception: Java.net.SocketException: Connection reset I also removed ftb ranks but it still did not work (another permission mod)

Reproduction Steps

Use the serverpack from courseforge ( v0.38) All mods 10
added the luckperms mod

Expected Behaviour

I think there are some problems with the capability because the log says that the capability was not initialized.

Server Details

1.21 Neoforge (all the mods 10 v0.38)

LuckPerms Version

v5.4.140

Logs and Configs

[23Aug.2024 14:46:29.854] [Server thread/INFO] [net.minecraft.server.players.PlayerList/]: Belu97[/*********] logged in with entity id 235 at (69.58791324768531, 64.84024969618058, 74.04475131671492)
[23Aug.2024 14:46:30.419] [Server thread/INFO] [cy.jdkdigital.jearchaeology.JEArchaeology/]: table net.minecraft.world.level.storage.loot.LootTable@504ae2b4
[23Aug.2024 14:46:30.483] [Server thread/INFO] [Modonomicon/]: Building books ...
[23Aug.2024 14:46:30.494] [Server thread/INFO] [Modonomicon/]: Books built.
[23Aug.2024 14:46:30.532] [Server thread/ERROR] [net.minecraft.server.network.ServerConfigurationPacketListenerImpl/]: Couldn't place player in world
java.lang.IllegalStateException: Capability has not been initialised
at me.lucko.luckperms.neoforge.capabilities.UserCapabilityImpl.assertInitialised(UserCapabilityImpl.java:98) ~[?:?]
at me.lucko.luckperms.neoforge.capabilities.UserCapabilityImpl.getUser(UserCapabilityImpl.java:141) ~[?:?]
at me.lucko.luckperms.neoforge.service.NeoForgePermissionHandler.getPermission(NeoForgePermissionHandler.java:84) ~[?:?]
at TRANSFORMER/[email protected]/net.neoforged.neoforge.server.permission.PermissionAPI.getPermission(PermissionAPI.java:63) ~[neoforge-21.1.23-universal.jar%23333!/:?]
at TRANSFORMER/[email protected]/mekanism.common.base.MekanismPermissions$CommandPermissionNode.test(MekanismPermissions.java:118) ~[Mekanism-1.21-10.6.7.54.jar%23464!/:10.6.7]
at TRANSFORMER/[email protected]/mekanism.common.base.MekanismPermissions$CommandPermissionNode.test(MekanismPermissions.java:112) ~[Mekanism-1.21-10.6.7.54.jar%23464!/:10.6.7]
at java.base/java.util.function.Predicate.lambda$and$0(Predicate.java:69) ~[?:?]
at me.lucko.luckperms.neoforge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:164) ~[?:?]
at me.lucko.luckperms.neoforge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:130) ~[?:?]
at MC-BOOTSTRAP/[email protected]/com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:65) ~[brigadier-1.3.10.jar%23101!/:?]
at TRANSFORMER/[email protected]/net.neoforged.neoforge.server.command.CommandHelper.mergeCommandNode(CommandHelper.java:44) ~[neoforge-21.1.23-universal.jar%23333!/:?]
at TRANSFORMER/[email protected]/net.neoforged.neoforge.server.command.CommandHelper.toResult(CommandHelper.java:93) ~[neoforge-21.1.23-universal.jar%23333!/:?]
at TRANSFORMER/[email protected]/net.neoforged.neoforge.server.command.CommandHelper.mergeCommandNode(CommandHelper.java:45) ~[neoforge-21.1.23-universal.jar%23333!/:?]
at TRANSFORMER/[email protected]/net.minecraft.commands.Commands.sendCommands(Commands.java:377) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.sendPlayerPermissionLevel(PlayerList.java:630) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.sendPlayerPermissionLevel(PlayerList.java:530) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:207) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerConfigurationPacketListenerImpl.handleConfigurationFinished(ServerConfigurationPacketListenerImpl.java:188) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:22) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:8) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:27) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.TickTask.run(TickTask.java:18) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:148) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:872) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:170) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:855) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:849) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:821) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:826) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:712) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:267) ~[server-1.21.1-20240808.144430-srg.jar%23332!/:?]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
[23Aug.2024 14:46:31.748] [Server thread/WARN] [net.minecraft.server.MinecraftServer/]: Can't keep up! Is the server overloaded? Running 2079ms or 41 ticks behind
[23Aug.2024 14:46:31.754] [Server thread/INFO] [net.minecraft.server.network.ServerGamePacketListenerImpl/]: Belu97 lost connection: Invalid player data
[23Aug.2024 14:46:31.755] [Server thread/INFO] [net.minecraft.server.MinecraftServer/]: Belu97 left the game

Extra Details

No response

commented

Can confirm the same issue.

Click to show related log excerpt
[11:35:37] [Server thread/ERROR] [ne.ne.bu.EventBus/EVENTBUS]: Exception caught during firing event: Capability has not been initialised
	Index: 0
	Listeners:
		0: me.lucko.luckperms.neoforge.util.NeoForgeEventBusFacade$$Lambda/0x0000000800e07ae8@eabcba8
		1: net.neoforged.bus.EventListenerFactory$playerLogin/0x0000000800d5d800@73f12ebf
java.lang.IllegalStateException: Capability has not been initialised
	at me.lucko.luckperms.neoforge.capabilities.UserCapabilityImpl.assertInitialised(UserCapabilityImpl.java:98)
	at me.lucko.luckperms.neoforge.capabilities.UserCapabilityImpl.getQueryOptionsCache(UserCapabilityImpl.java:151)
	at me.lucko.luckperms.neoforge.context.NeoForgeContextManager.invalidateCache(NeoForgeContextManager.java:75)
	at me.lucko.luckperms.neoforge.context.NeoForgeContextManager.invalidateCache(NeoForgeContextManager.java:40)
	at me.lucko.luckperms.common.context.manager.ContextManager.signalContextUpdate(ContextManager.java:110)
	at me.lucko.luckperms.neoforge.listeners.NeoForgeConnectionListener.onPlayerLoggedIn(NeoForgeConnectionListener.java:153)
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.ConsumerEventHandler.invoke(ConsumerEventHandler.java:26)
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:350)
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:315)
	at TRANSFORMER/[email protected]/net.neoforged.neoforge.event.EventHooks.firePlayerLoggedIn(EventHooks.java:876)
	at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:270)
	at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerConfigurationPacketListenerImpl.handleConfigurationFinished(ServerConfigurationPacketListenerImpl.java:188)
	at TRANSFORMER/[email protected]/net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:22)
	at TRANSFORMER/[email protected]/net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:8)
	at TRANSFORMER/[email protected]/net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:27)
	at TRANSFORMER/[email protected]/net.minecraft.server.TickTask.run(TickTask.java:18)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:148)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:872)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:170)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:855)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:849)
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:821)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:826)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:712)
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:267)
	at java.base/java.lang.Thread.run(Thread.java:1583)

[11:35:37] [Server thread/ERROR] [minecraft/ServerConfigurationPacketListenerImpl]: Couldn't place player in world
java.lang.IllegalStateException: Capability has not been initialised
	at me.lucko.luckperms.neoforge.capabilities.UserCapabilityImpl.assertInitialised(UserCapabilityImpl.java:98) ~[?:?] {re:classloading,re:classloading}
	at me.lucko.luckperms.neoforge.capabilities.UserCapabilityImpl.getQueryOptionsCache(UserCapabilityImpl.java:151) ~[?:?] {re:classloading,re:classloading}
	at me.lucko.luckperms.neoforge.context.NeoForgeContextManager.invalidateCache(NeoForgeContextManager.java:75) ~[?:?] {}
	at me.lucko.luckperms.neoforge.context.NeoForgeContextManager.invalidateCache(NeoForgeContextManager.java:40) ~[?:?] {}
	at me.lucko.luckperms.common.context.manager.ContextManager.signalContextUpdate(ContextManager.java:110) ~[?:?] {}
	at me.lucko.luckperms.neoforge.listeners.NeoForgeConnectionListener.onPlayerLoggedIn(NeoForgeConnectionListener.java:153) ~[?:?] {}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.ConsumerEventHandler.invoke(ConsumerEventHandler.java:26) ~[bus-8.0.1.jar%2367!/:?] {}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:350) ~[bus-8.0.1.jar%2367!/:?] {}
	at MC-BOOTSTRAP/net.neoforged.bus/net.neoforged.bus.EventBus.post(EventBus.java:315) ~[bus-8.0.1.jar%2367!/:?] {}
	at TRANSFORMER/[email protected]/net.neoforged.neoforge.event.EventHooks.firePlayerLoggedIn(EventHooks.java:876) ~[neoforge-21.1.23-universal.jar%23121!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:270) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerConfigurationPacketListenerImpl.handleConfigurationFinished(ServerConfigurationPacketListenerImpl.java:188) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:22) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:8) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:27) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.server.TickTask.run(TickTask.java:18) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:148) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:872) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:170) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:855) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:849) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:821) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:826) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:712) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:267) ~[server-1.21.1-20240808.144430-srg.jar%23120!/:?] {re:classloading,pl:accesstransformer:B}
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?] {}

A quick dirty investigation shows that the issue possibly relates to this part of code:

@SubscribeEvent
public void onRegisterCapabilities(RegisterCapabilitiesEvent event) {
event.registerEntity(
UserCapability.CAPABILITY,
EntityType.PLAYER,
(player, ctx) -> {
if (!(player instanceof ServerPlayer)) {
// Don't attach to LocalPlayer
return null;
}
return new UserCapabilityImpl();
}
);
}

Notice that we create a new UserCapabilityImpl every time we query it via UserCapabilityImpl.get(player).

This means we will have different instances of UserCapabilityImpl during PlayerLoggedInEvent here:

UserCapabilityImpl userCapability = UserCapabilityImpl.get(player);
userCapability.initialise(user, player, this.plugin.getContextManager());
this.plugin.getContextManager().signalContextUpdate(player);

i.e. After we call userCapability.initialise, the state was lost, and when we call signalContextUpdate(player):

@Override
public void invalidateCache(ServerPlayer subject) {
UserCapabilityImpl capability = UserCapabilityImpl.getNullable(subject);
if (capability != null) {
capability.getQueryOptionsCache().invalidate();
}
}

we will end up with a new UserCapabilityImpl with initialised = false.

Ultimately, this is related to a major design change in NeoForge: NeoForge split the "data storage" function of capability into a separate system, called Data Attachments.

The data attachment system allows mods to attach and store additional data on block entities, chunks, and entities.

- NeoForge Documentation, section "Data Storage § Data Attachments"

Based on my limited understanding of how LuckPerms uses UserCapabilityImpl, I believe this stateful information should be registered as a Data Attachment in NeoForge, rather than Capability.

I am willing to create a new PR for this one, for I need to get LuckPerms working properly on NeoForge as soon as possible.


I am still deeply confused why I did not caught this while fixing the configuration task issue. Both issues block players from joining the game, and this new one should have blocked me from joining game at very beginning.

commented

Yea thats weird i thought First a other mod is the Problem so i tried it in a new neoforge server (without all other mods) and still have same issue

commented

Confirmed in neoforge 1.21~1.21.1

commented

See comment in #4002, should be fixed by b18717e