Make sync command reload sponge data too - resolves #98

This commit is contained in:
Luck 2016-12-21 21:34:43 +00:00
parent fc4750706b
commit 8795383e7c
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 21 additions and 0 deletions

View File

@ -366,4 +366,11 @@ public interface LuckPermsPlugin {
*/
BufferedRequest<Void> getUpdateTaskBuffer();
/**
* Called at the end of the sync task.
*/
default void onPostUpdate() {
}
}

View File

@ -54,6 +54,8 @@ public class UpdateTask implements Runnable {
// Refresh all online users.
plugin.getUserManager().updateAllUsers();
plugin.onPostUpdate();
plugin.getApiProvider().fireEvent(new PostSyncEvent());
}
}

View File

@ -62,6 +62,8 @@ import me.lucko.luckperms.sponge.managers.SpongeGroupManager;
import me.lucko.luckperms.sponge.managers.SpongeUserManager;
import me.lucko.luckperms.sponge.service.LuckPermsService;
import me.lucko.luckperms.sponge.service.ServiceCacheHousekeepingTask;
import me.lucko.luckperms.sponge.service.base.LPSubjectCollection;
import me.lucko.luckperms.sponge.service.persisted.PersistedCollection;
import me.lucko.luckperms.sponge.timings.LPTimings;
import me.lucko.luckperms.sponge.utils.VersionData;
@ -305,6 +307,16 @@ public class LPSpongePlugin implements LuckPermsPlugin {
}
}
@Override
public void onPostUpdate() {
for (LPSubjectCollection collection : service.getCollections().values()) {
if (collection instanceof PersistedCollection) {
((PersistedCollection) collection).loadAll();
}
}
service.invalidateParentCaches();
}
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public File getMainDir() {