mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 13:45:20 +01:00
Properly invalidate user caches when defaults chance - fixes #118
This commit is contained in:
parent
148fe4c729
commit
ce42573f43
@ -117,10 +117,12 @@ public class SpongeGroup extends Group {
|
|||||||
this.subjectData = new LuckPermsSubjectData(true, plugin.getService(), parent, this);
|
this.subjectData = new LuckPermsSubjectData(true, plugin.getService(), parent, this);
|
||||||
this.transientSubjectData = new LuckPermsSubjectData(false, plugin.getService(), parent, this);
|
this.transientSubjectData = new LuckPermsSubjectData(false, plugin.getService(), parent, this);
|
||||||
|
|
||||||
parent.getStateListeners().add(() -> {
|
parent.getStateListeners().add(this::invalidateCaches);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void invalidateCaches() {
|
||||||
permissionCache.invalidateAll();
|
permissionCache.invalidateAll();
|
||||||
parentCache.invalidateAll();
|
parentCache.invalidateAll();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,11 +43,14 @@ import me.lucko.luckperms.api.Contexts;
|
|||||||
import me.lucko.luckperms.api.Tristate;
|
import me.lucko.luckperms.api.Tristate;
|
||||||
import me.lucko.luckperms.api.context.ContextSet;
|
import me.lucko.luckperms.api.context.ContextSet;
|
||||||
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
import me.lucko.luckperms.api.context.ImmutableContextSet;
|
||||||
|
import me.lucko.luckperms.common.caching.UserCache;
|
||||||
|
import me.lucko.luckperms.common.core.model.User;
|
||||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||||
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||||
import me.lucko.luckperms.sponge.contexts.SpongeCalculatorLink;
|
import me.lucko.luckperms.sponge.contexts.SpongeCalculatorLink;
|
||||||
import me.lucko.luckperms.sponge.managers.SpongeGroupManager;
|
import me.lucko.luckperms.sponge.managers.SpongeGroupManager;
|
||||||
import me.lucko.luckperms.sponge.managers.SpongeUserManager;
|
import me.lucko.luckperms.sponge.managers.SpongeUserManager;
|
||||||
|
import me.lucko.luckperms.sponge.model.SpongeGroup;
|
||||||
import me.lucko.luckperms.sponge.service.base.LPSubject;
|
import me.lucko.luckperms.sponge.service.base.LPSubject;
|
||||||
import me.lucko.luckperms.sponge.service.base.LPSubjectCollection;
|
import me.lucko.luckperms.sponge.service.base.LPSubjectCollection;
|
||||||
import me.lucko.luckperms.sponge.service.base.LPSubjectData;
|
import me.lucko.luckperms.sponge.service.base.LPSubjectData;
|
||||||
@ -225,6 +228,19 @@ public class LuckPermsService implements PermissionService {
|
|||||||
for (CalculatedSubjectData subjectData : localDataCaches) {
|
for (CalculatedSubjectData subjectData : localDataCaches) {
|
||||||
subjectData.invalidateLookupCache();
|
subjectData.invalidateLookupCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.getCalculatorFactory().invalidateAll();
|
||||||
|
|
||||||
|
for (User user : plugin.getUserManager().getAll().values()) {
|
||||||
|
UserCache userCache = user.getUserData();
|
||||||
|
if (userCache == null) continue;
|
||||||
|
|
||||||
|
userCache.invalidateCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SpongeGroup group : plugin.getGroupManager().getAll().values()) {
|
||||||
|
group.getSpongeData().invalidateCaches();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invalidateParentCaches() {
|
public void invalidateParentCaches() {
|
||||||
@ -239,6 +255,13 @@ public class LuckPermsService implements PermissionService {
|
|||||||
for (LoadingCache<OptionLookup, Optional<String>> c : localOptionCaches) {
|
for (LoadingCache<OptionLookup, Optional<String>> c : localOptionCaches) {
|
||||||
c.invalidateAll();
|
c.invalidateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (User user : plugin.getUserManager().getAll().values()) {
|
||||||
|
UserCache userCache = user.getUserData();
|
||||||
|
if (userCache == null) continue;
|
||||||
|
|
||||||
|
userCache.invalidateCache();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
Loading…
Reference in New Issue
Block a user