LuckPerms

LuckPerms

41.4k Downloads

Delay Applying Group Permissions

DarkArc opened this issue ยท 1 comments

commented

When activating "admin mode" (somewhat similar to op/deop), it seems permissions are sometimes delayed. In the following log, /gm 1 adds the player to the admin group, then I attempted to place a block, resulting in the WorldGuard checks.

[21:52:34 INFO]: Dark_Arc issued server command: /gm 1
[21:52:34 INFO]: [LP] VB > dark_arc - worldguard.region.bypass.Halzeil - undefined
[21:52:34 INFO]: [LP] VB > dark_arc - worldguard.region.bypass.* - undefined
[21:52:34 INFO]: [LP] VB > dark_arc - worldguard.region.* - undefined
[21:52:34 INFO]: [LP] VB > dark_arc - worldguard.* - undefined
[21:52:34 INFO]: [LP] VB > dark_arc - * - undefined

A flood of permissions follows, in the log, I assume this to be related to resending player commands.

This is the code that adds the group:
https://github.com/packet-loss-gaming/Grindstone/blob/master/src/main/java/gg/packetloss/grindstone/admin/AdminComponent.java#L122-L169

This is code that automatically enables admin mode on gamemode change:
https://github.com/packet-loss-gaming/Grindstone/blob/master/src/main/java/gg/packetloss/grindstone/GrounderComponent.java#L50-L56


/lp info:

[23:25:29 INFO]: [LP] Running LuckPerms v5.0.39 by Luck.
[23:25:29 INFO]: [LP] -  Platform: Bukkit
[23:25:29 INFO]: [LP] -  Server Brand: Paper
[23:25:29 INFO]: [LP] -  Server Version:
[23:25:29 INFO]: [LP] -  git-Paper-32 (MC: 1.15.1) - 1.15.1-R0.1-SNAPSHOT
[23:25:29 INFO]: [LP] -  Storage:
[23:25:29 INFO]: [LP] -     Type: MariaDB
[23:25:29 INFO]: [LP] -     Ping: 1ms
[23:25:29 INFO]: [LP] -     Connected: true
[23:25:29 INFO]: [LP] -  Messaging: Sql
[23:25:29 INFO]: [LP] -  Instance:
[23:25:29 INFO]: [LP] -     Static contexts: None
[23:25:29 INFO]: [LP] -     Online Players: 1 (1 unique)
[23:25:29 INFO]: [LP] -     Uptime: 8m 1s
[23:25:29 INFO]: [LP] -     Local Data: 1 users, 10 groups, 1 tracks
commented

Without seeing your Verbose logs, it might be that WorldGuard is listening to the Command preprocess event and/or the gamemode change event on a priority "sooner" than HIGHEST, and is therefore checking permissions before your plugin applies admin permissions.

Using /lp verbose paste will let you see the stack traces of the checks, which will clear that up.

As for delayed updates to WorldGuard bypass permissions - this is a WorldGuard issue and is not being caused by LuckPerms, in my testing at least.

Upon inspection of the WorldGuard code, it seems that bypass permission checks are cached - for a minimum of 2 seconds, and a maximum of ??? - possibly until the player logs out or changes world.

https://github.com/EngineHub/WorldGuard/blob/637665f52d17bdafb3805125b2585a94194e144a/worldguard-core/src/main/java/com/sk89q/worldguard/session/AbstractSessionManager.java#L60-L64

The cached permission check will only expire if the cache grows above 1000 entries, or if a player doesn't attempt any restricted action for at least 2 seconds. In my opinion that's a bug in WorldGuard - it should be expireAfterWrite instead of expireAfterAccess so the cached permission check expires after at most 2 seconds, not at least 2 seconds.