mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-09 12:30:15 +01:00
Fix issue with nodes never being removed on sync with flatfile storage types
This commit is contained in:
parent
db9d84ed76
commit
a047695a84
@ -469,7 +469,6 @@ public abstract class PermissionHolder {
|
|||||||
invalidateCache(false);
|
invalidateCache(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setNodes(Map<String, Boolean> nodes) {
|
public void setNodes(Map<String, Boolean> nodes) {
|
||||||
Set<Node> set = nodes.entrySet().stream()
|
Set<Node> set = nodes.entrySet().stream()
|
||||||
.map(e -> makeNode(e.getKey(), e.getValue()))
|
.map(e -> makeNode(e.getKey(), e.getValue()))
|
||||||
@ -478,15 +477,6 @@ public abstract class PermissionHolder {
|
|||||||
setNodes(set);
|
setNodes(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNodeUnchecked(Node node) {
|
|
||||||
synchronized (nodes) {
|
|
||||||
if (!nodes.add(node)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
invalidateCache(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the holder has a permission node
|
* Check if the holder has a permission node
|
||||||
* @param node the node to check
|
* @param node the node to check
|
||||||
|
@ -26,7 +26,6 @@ import com.google.gson.stream.JsonReader;
|
|||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
import lombok.Cleanup;
|
import lombok.Cleanup;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.Group;
|
||||||
import me.lucko.luckperms.common.groups.GroupManager;
|
import me.lucko.luckperms.common.groups.GroupManager;
|
||||||
import me.lucko.luckperms.common.tracks.Track;
|
import me.lucko.luckperms.common.tracks.Track;
|
||||||
@ -93,11 +92,13 @@ public class JSONBacking extends FlatfileBacking {
|
|||||||
user.setPrimaryGroup(reader.nextString()); // primaryGroup
|
user.setPrimaryGroup(reader.nextString()); // primaryGroup
|
||||||
reader.nextName(); // perms
|
reader.nextName(); // perms
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
|
Map<String, Boolean> map = new HashMap<>();
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
String node = reader.nextName();
|
String node = reader.nextName();
|
||||||
boolean b = reader.nextBoolean();
|
boolean b = reader.nextBoolean();
|
||||||
user.addNodeUnchecked(NodeFactory.fromSerialisedNode(node, b));
|
map.put(node, b);
|
||||||
}
|
}
|
||||||
|
user.setNodes(map);
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
|
|
||||||
@ -255,11 +256,13 @@ public class JSONBacking extends FlatfileBacking {
|
|||||||
reader.nextString(); // name
|
reader.nextString(); // name
|
||||||
reader.nextName(); //perms
|
reader.nextName(); //perms
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
|
Map<String, Boolean> map = new HashMap<>();
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
String node = reader.nextName();
|
String node = reader.nextName();
|
||||||
boolean b = reader.nextBoolean();
|
boolean b = reader.nextBoolean();
|
||||||
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(node, b));
|
map.put(node, b);
|
||||||
}
|
}
|
||||||
|
group.setNodes(map);
|
||||||
|
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
@ -305,11 +308,13 @@ public class JSONBacking extends FlatfileBacking {
|
|||||||
reader.nextString(); // name
|
reader.nextString(); // name
|
||||||
reader.nextName(); // perms
|
reader.nextName(); // perms
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
|
Map<String, Boolean> map = new HashMap<>();
|
||||||
while (reader.hasNext()) {
|
while (reader.hasNext()) {
|
||||||
String node = reader.nextName();
|
String node = reader.nextName();
|
||||||
boolean b = reader.nextBoolean();
|
boolean b = reader.nextBoolean();
|
||||||
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(node, b));
|
map.put(node, b);
|
||||||
}
|
}
|
||||||
|
group.setNodes(map);
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,7 +24,6 @@ package me.lucko.luckperms.common.storage.backing;
|
|||||||
|
|
||||||
import lombok.Cleanup;
|
import lombok.Cleanup;
|
||||||
import me.lucko.luckperms.common.LuckPermsPlugin;
|
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.Group;
|
||||||
import me.lucko.luckperms.common.groups.GroupManager;
|
import me.lucko.luckperms.common.groups.GroupManager;
|
||||||
import me.lucko.luckperms.common.tracks.Track;
|
import me.lucko.luckperms.common.tracks.Track;
|
||||||
@ -91,9 +90,7 @@ public class YAMLBacking extends FlatfileBacking {
|
|||||||
String name = (String) values.get("name");
|
String name = (String) values.get("name");
|
||||||
user.setPrimaryGroup((String) values.get("primary-group"));
|
user.setPrimaryGroup((String) values.get("primary-group"));
|
||||||
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
||||||
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
|
user.setNodes(perms);
|
||||||
user.addNodeUnchecked(NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()));
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false);
|
boolean save = plugin.getUserManager().giveDefaultIfNeeded(user, false);
|
||||||
|
|
||||||
@ -214,9 +211,7 @@ public class YAMLBacking extends FlatfileBacking {
|
|||||||
if (groupFile.exists()) {
|
if (groupFile.exists()) {
|
||||||
return doRead(groupFile, values -> {
|
return doRead(groupFile, values -> {
|
||||||
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
||||||
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
|
group.setNodes(perms);
|
||||||
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -247,9 +242,7 @@ public class YAMLBacking extends FlatfileBacking {
|
|||||||
File groupFile = new File(groupsDir, name + ".yml");
|
File groupFile = new File(groupsDir, name + ".yml");
|
||||||
return groupFile.exists() && doRead(groupFile, values -> {
|
return groupFile.exists() && doRead(groupFile, values -> {
|
||||||
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
Map<String, Boolean> perms = (Map<String, Boolean>) values.get("perms");
|
||||||
for (Map.Entry<String, Boolean> e : perms.entrySet()) {
|
group.setNodes(perms);
|
||||||
group.addNodeUnchecked(NodeFactory.fromSerialisedNode(e.getKey(), e.getValue()));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,8 +134,6 @@ public class UserManager extends AbstractManager<UserIdentifier, User> {
|
|||||||
for (UUID uuid : players) {
|
for (UUID uuid : players) {
|
||||||
UUID internal = plugin.getUuidCache().getUUID(uuid);
|
UUID internal = plugin.getUuidCache().getUUID(uuid);
|
||||||
plugin.getStorage().loadUser(internal, "null").join();
|
plugin.getStorage().loadUser(internal, "null").join();
|
||||||
User user = get(internal);
|
|
||||||
user.getRefreshBuffer().request();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user