How LuckPerms "predicts" permissions
This is not an issue, only something I was investigating for fun
I've been curious about how LuckPerms manages to "predict" permissions the server has available.
I made a very small single-file plugin to see this feature in action with just a single
Permissible.hasPermission(String)
function at the start of a command.
Apparently before trying to execute the command, luckperms is not yet aware of this permission, however after trying it once and opening the editor, it does show as a possible permission to choose.
This suggest that they might be caching permissions when Permissible.hasPermission(String)
or similar functions are executed, however in their repo there isn't a clear reference to a cache on hasPermission
, only on addPermission
.
I've been reading their repo for a while now, and learned a lot of how the plugin works but so far, no reference as how they resolve those permissions, closest I could find is AsyncPermissionRegistry
but there's nothing suggesting a possible cache.
This post is mostly for curiosity, if anyone had the same question and managed to find an answer before me.
This is the example plugin I made to test this:

9 Replies
Thanks for asking your question!
Make sure to provide as much helpful information as possible such as logs/what you tried and what your exact issue is
Make sure to mark solved when issue is solved!!!
/close
!close
!solved
!answered
Requested by duoslingo#0
Don't plugins declare their permissions in plugin.yml
No, try the code above as is without declaring anything in plugin.yml and Luckperms will be able to detect the permission regardless
I mean, declare the main class, plugin name, etc.
But no permissions
Haha I trust you I don't know java
Even though I probably should bc it's useful
Try the code above without any permission in plugin.yml
I feel is most likely cached
I opened an editor before and after joining the server
Before joining, the permission wasn't displayed in the editor
After joining and running the command that required said permission, it was displayed on the editor (had to open a new one)
Haven't try that before, but I don't think is likely that it mentiones the classes that are being called
Or does it?
I'll try
Doesn't give that much insight on how lp does it

I also took the chance to confirm, I opened one editor after joining the server but before executing that command.
The editor is definitely only able to recognize it after the permission has been consulted
Yh, but the point is where does it gets the permissions from in terms of code
It's not on the
plugin.yml
, I haven't manually added them with Permissible.addPermission()
it is registering the permission somewhere once its consultedSolution
I tried that and it lead me to
AsyncPermissionRegistry
I also tried looking into their
hasPermission
implementation and it lead me to PermissionCalculator
But nothing that could potentially store the permission to send it to the editor
Just to know what they did to store it
I made something similar with a regular map
And that left me wondering how they handled it
Just checking that one
Mostly, the issue is that when I look into those files I ran into a class that doesn't hold anything
Well, I'm also just checking via github on the browser
Maybe I should clone the repo and use the ide
But idk, it is kinda fun investigating this way