The primary group is not updated in the database
Sceri opened this issue ยท 3 comments
Description
After setting the group permission using API to a user, the primary group is not updated in the database.
Reproduction steps
- Add a group to the user using the API
- Look in the database
Expected behaviour
The database must contain the correct primary group
Environment details
- BungeeCord/1.16-R0.5-SNAPSHOT (build 1559)
- LuckPerms version:
v5.3.33
https://gist.github.com/Sceri/978eca438086011245d3f2a18ded6d4f (used code)
Before giving:
After giving
Database row after giving:
Apparently, the primary group is not updated in internal PrimaryGroupHolder when using the API. Therefore, a wrong value is written to the database when saving. But at the same time everything is fine in the cache.
See https://luckperms.net/wiki/Configuration#primary-group-calculation
(although the wiki is actually a bit out of date, the default is parents-by-weight
everywhere now)
Just tested this and the primary group only updates in the metadata cache when using the API, and not in the underlying PrimaryGroupHolder
. Using the parent set|add
commands actually work as expected.
User#setPrimaryGroup(String)
returns FAIL_ALREADY_HAS
because it checks against the cached metadata before applying it, even though it differs.