Fix default assignments never being applied on Bungee

This commit is contained in:
Luck 2016-11-21 18:26:37 +00:00
parent 384fbf5464
commit d13eb1a55d
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -26,6 +26,7 @@ import me.lucko.luckperms.api.Contexts;
import me.lucko.luckperms.api.event.events.UserFirstLoginEvent; import me.lucko.luckperms.api.event.events.UserFirstLoginEvent;
import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Message;
import me.lucko.luckperms.common.core.UuidCache; import me.lucko.luckperms.common.core.UuidCache;
import me.lucko.luckperms.common.defaults.Rule;
import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.users.User;
import me.lucko.luckperms.common.utils.AbstractListener; import me.lucko.luckperms.common.utils.AbstractListener;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -122,6 +123,19 @@ public class BungeeListener extends AbstractListener implements Listener {
if (user == null) { if (user == null) {
plugin.getLog().warn("Failed to load user: " + c.getName()); plugin.getLog().warn("Failed to load user: " + c.getName());
} else { } else {
// Setup defaults for the user
boolean save = false;
for (Rule rule : plugin.getConfiguration().getDefaultAssignments()) {
if (rule.apply(user)) {
save = true;
}
}
// If they were given a default, persist the new assignments back to the storage.
if (save) {
plugin.getStorage().force().saveUser(user).join();
}
user.setupData(false); // Pretty nasty calculation call. Sets up the caching system so data is ready when the user joins. user.setupData(false); // Pretty nasty calculation call. Sets up the caching system so data is ready when the user joins.
} }