Fix issue with nodes never being removed on sync with flatfile storage types

This commit is contained in:
Luck 2016-11-17 19:01:58 +00:00
parent db9d84ed76
commit a047695a84
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
4 changed files with 12 additions and 26 deletions

View File

@ -469,7 +469,6 @@ public abstract class PermissionHolder {
invalidateCache(false);
}
@Deprecated
public void setNodes(Map<String, Boolean> nodes) {
Set<Node> set = nodes.entrySet().stream()
.map(e -> makeNode(e.getKey(), e.getValue()))
@ -478,15 +477,6 @@ public abstract class PermissionHolder {
setNodes(set);
}
public void addNodeUnchecked(Node node) {
synchronized (nodes) {
if (!nodes.add(node)) {
return;
}
}
invalidateCache(true);
}
/**
* Check if the holder has a permission node
* @param node the node to check

View File

@ -26,7 +26,6 @@ import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import lombok.Cleanup;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.groups.Group;
import me.lucko.luckperms.common.groups.GroupManager;
import me.lucko.luckperms.common.tracks.Track;
@ -93,11 +92,13 @@ public class JSONBacking extends FlatfileBacking {
user.setPrimaryGroup(reader.nextString()); // primaryGroup
reader.nextName(); // perms
reader.beginObject();
Map<String, Boolean> map = new HashMap<>();
while (reader.hasNext()) {
String node = reader.nextName();
boolean b = reader.nextBoolean();
user.addNodeUnchecked(NodeFactory.fromSerialisedNode(node, b));
map.put(node, b);
}
user.setNodes(map);
reader.endObject();
reader.endObject();
@ -255,11 +256,13 @@ public class JSONBacking extends FlatfileBacking {
reader.nextString(); // name
reader.nextName(); //perms
reader.beginObject();
Map<String, Boolean> map = new HashMap<>();
while (reader.hasNext()) {
String node = reader.nextName();
boolean b = reader.nextBoolean();
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(node, b));
map.put(node, b);
}
group.setNodes(map);
reader.endObject();
reader.endObject();
@ -305,11 +308,13 @@ public class JSONBacking extends FlatfileBacking {
reader.nextString(); // name
reader.nextName(); // perms
reader.beginObject();
Map<String, Boolean> map = new HashMap<>();
while (reader.hasNext()) {
String node = reader.nextName();
boolean b = reader.nextBoolean();
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(node, b));
map.put(node, b);
}
group.setNodes(map);
reader.endObject();
reader.endObject();
return true;

View File

@ -24,7 +24,6 @@ package me.lucko.luckperms.common.storage.backing;
import lombok.Cleanup;
import me.lucko.luckperms.common.LuckPermsPlugin;
import me.lucko.luckperms.common.core.NodeFactory;
import me.lucko.luckperms.common.groups.Group;
import me.lucko.luckperms.common.groups.GroupManager;
import me.lucko.luckperms.common.tracks.Track;
@ -91,9 +90,7 @@ public class YAMLBacking extends FlatfileBacking {
String name = (String) values.get("name");
user.setPrimaryGroup((String) values.get("primary-group"));
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
user.addNodeUnchecked(NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()));
}
user.setNodes(perms);
boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false);
@ -214,9 +211,7 @@ public class YAMLBacking extends FlatfileBacking {
if (groupFile.exists()) {
return doRead(groupFile, values -> {
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()));
}
group.setNodes(perms);
return true;
});
} else {
@ -247,9 +242,7 @@ public class YAMLBacking extends FlatfileBacking {
File groupFile = new File(groupsDir, name + ".yml");
return groupFile.exists() && doRead(groupFile, values -> {
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()));
}
group.setNodes(perms);
return true;
});

View File

@ -134,8 +134,6 @@ public class UserManager extends AbstractManager<UserIdentifier, User> {
for (UUID uuid : players) {
UUID internal = plugin.getUuidCache().getUUID(uuid);
plugin.getStorage().loadUser(internal, "null").join();
User user = get(internal);
user.getRefreshBuffer().request();
}
});
});