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:
27 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
I might be wrong but pretty sure its basically grabbing it from tab completion then checking the commands permission from plugin.yml?
thats probs at least partially how its done
Try the code above without any permission in plugin.yml
i know
just stating partially thats how they likely do it
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
also it could just be the plugin listening into permission checks and caching it
After joining and running the command that required said permission, it was displayed on the editor (had to open a new one)
lp verbose does exist after all
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
because web editor is a web socket connection and you create a connection to the web editor and your server and upload permission to the web editor
GitHub
LuckPerms/common/src/main/java/me/lucko/luckperms/common/api/implem...
A permissions plugin for Minecraft servers. Contribute to LuckPerms/LuckPerms development by creating an account on GitHub.
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 consultedtab completion?
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 editoris that what you really want?
just wondering whats your goal here
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
GitHub
LuckPerms/common/src/main/java/me/lucko/luckperms/common/webeditor/...
A permissions plugin for Minecraft servers. Contribute to LuckPerms/LuckPerms development by creating an account on GitHub.
https://github.com/LuckPerms/LuckPerms/blob/master/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java is interesting
GitHub
LuckPerms/common/src/main/java/me/lucko/luckperms/common/model/Perm...
A permissions plugin for Minecraft servers. Contribute to LuckPerms/LuckPerms development by creating an account on GitHub.
Just checking that one
https://github.com/LuckPerms/LuckPerms/blob/master/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java
when the editor command is ran
GitHub
LuckPerms/common/src/main/java/me/lucko/luckperms/common/commands/m...
A permissions plugin for Minecraft servers. Contribute to LuckPerms/LuckPerms development by creating an account on GitHub.
honestly think that should be enough idea to get how this works
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