fix group deletion not syncing across multiple instances
This commit is contained in:
parent
4610b3db7e
commit
e07a346e16
@ -11,6 +11,7 @@ import me.lucko.luckperms.users.User;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "UnnecessaryLocalVariable"})
|
||||
public class FlatfileDatastore extends Datastore {
|
||||
@ -40,6 +41,7 @@ public class FlatfileDatastore extends Datastore {
|
||||
jsonWriter = new JsonWriter(bufferedWriter);
|
||||
jsonWriter.setIndent(" ");
|
||||
success = writeOperation.onRun(jsonWriter);
|
||||
jsonWriter.flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
@ -315,7 +317,11 @@ public class FlatfileDatastore extends Datastore {
|
||||
|
||||
@Override
|
||||
public boolean loadAllGroups() {
|
||||
List<String> groups = Arrays.asList(groupsDir.list((dir, name1) -> name1.endsWith(".json")));
|
||||
List<String> groups = Arrays.asList(groupsDir.list((dir, name1) -> name1.endsWith(".json")))
|
||||
.stream().map(s -> s.substring(0, s.length() - 5))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
plugin.getGroupManager().unloadAll();
|
||||
groups.forEach(this::loadGroup);
|
||||
return true;
|
||||
}
|
||||
|
@ -231,8 +231,11 @@ public abstract class SQLDatastore extends Datastore {
|
||||
return true;
|
||||
});
|
||||
|
||||
GroupManager gm = plugin.getGroupManager();
|
||||
if (success) groups.forEach(gm::setGroup);
|
||||
if (success) {
|
||||
GroupManager gm = plugin.getGroupManager();
|
||||
gm.unloadAll();
|
||||
groups.forEach(gm::setGroup);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,13 @@ public class GroupManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads all groups from the manager
|
||||
*/
|
||||
public void unloadAll() {
|
||||
groups.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all groups from the datastore
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user