LuckPerms

LuckPerms

41.4k Downloads

The primary group is not updated in the database

Sceri opened this issue ยท 3 comments

commented

Description

After setting the group permission using API to a user, the primary group is not updated in the database.

Reproduction steps

  1. Add a group to the user using the API
  2. 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:

before

After giving

after

Database row after giving:

database_after

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.

commented

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)

commented

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.

commented

Fixed by the above commit, thanks