Fix temporary permission expirations never persisting. Fixes #30

This commit is contained in:
Luck 2016-10-19 17:37:26 +01:00
parent d113a92ce5
commit c66a01c1a6
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 14 additions and 17 deletions

View File

@ -112,8 +112,6 @@ public abstract class PermissionHolder {
this.nodes.clear();
this.nodes.addAll(nodes);
}
auditTemporaryPermissions();
}
public void setTransientNodes(Set<Node> nodes) {
@ -125,8 +123,6 @@ public abstract class PermissionHolder {
this.transientNodes.clear();
this.transientNodes.addAll(nodes);
}
auditTemporaryPermissions();
}
@Deprecated
@ -141,8 +137,6 @@ public abstract class PermissionHolder {
.map(e -> me.lucko.luckperms.common.core.Node.fromSerialisedNode(e.getKey(), e.getValue()))
.collect(Collectors.toList()));
}
auditTemporaryPermissions();
}
public void addNodeUnchecked(Node node) {

View File

@ -24,7 +24,6 @@ package me.lucko.luckperms.common.runnables;
import lombok.AllArgsConstructor;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.PermissionHolder;
import me.lucko.luckperms.common.groups.Group;
import me.lucko.luckperms.common.users.User;
@ -34,20 +33,21 @@ public class ExpireTemporaryTask implements Runnable {
@Override
public void run() {
boolean changes = false;
boolean groupChanges = false;
for (Group group : plugin.getGroupManager().getAll().values()) {
if (group.auditTemporaryPermissions()) {
changes = true;
plugin.getDatastore().saveGroup(group);
groupChanges = true;
}
}
if (changes) {
plugin.runUpdateTask();
return;
for (User user : plugin.getUserManager().getAll().values()) {
if (user.auditTemporaryPermissions()) {
plugin.getDatastore().saveUser(user);
if (!groupChanges) {
user.refreshPermissions();
}
}
}
plugin.getUserManager().getAll().values().stream()
.filter(PermissionHolder::auditTemporaryPermissions)
.forEach(User::refreshPermissions);
}
}

View File

@ -134,7 +134,10 @@ public class UserManager extends AbstractManager<UserIdentifier, User> {
Set<UUID> players = plugin.getOnlinePlayers();
plugin.doAsync(() -> {
for (UUID uuid : players) {
plugin.getDatastore().loadUser(plugin.getUuidCache().getUUID(uuid), "null");
UUID internal = plugin.getUuidCache().getUUID(uuid);
plugin.getDatastore().loadUser(internal, "null");
User user = get(internal);
user.refreshPermissions();
}
});
});