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.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "UnnecessaryLocalVariable"})
|
@SuppressWarnings({"ResultOfMethodCallIgnored", "UnnecessaryLocalVariable"})
|
||||||
public class FlatfileDatastore extends Datastore {
|
public class FlatfileDatastore extends Datastore {
|
||||||
@ -40,6 +41,7 @@ public class FlatfileDatastore extends Datastore {
|
|||||||
jsonWriter = new JsonWriter(bufferedWriter);
|
jsonWriter = new JsonWriter(bufferedWriter);
|
||||||
jsonWriter.setIndent(" ");
|
jsonWriter.setIndent(" ");
|
||||||
success = writeOperation.onRun(jsonWriter);
|
success = writeOperation.onRun(jsonWriter);
|
||||||
|
jsonWriter.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@ -315,7 +317,11 @@ public class FlatfileDatastore extends Datastore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean loadAllGroups() {
|
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);
|
groups.forEach(this::loadGroup);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -231,8 +231,11 @@ public abstract class SQLDatastore extends Datastore {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
GroupManager gm = plugin.getGroupManager();
|
if (success) {
|
||||||
if (success) groups.forEach(gm::setGroup);
|
GroupManager gm = plugin.getGroupManager();
|
||||||
|
gm.unloadAll();
|
||||||
|
groups.forEach(gm::setGroup);
|
||||||
|
}
|
||||||
return success;
|
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
|
* Load all groups from the datastore
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user