mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Cleanup some bad code in SQLDatastore. Might help #32
This commit is contained in:
parent
daef01194e
commit
0d515abadb
@ -306,25 +306,31 @@ abstract class SQLDatastore extends Datastore {
|
||||
@Override
|
||||
public boolean loadAllGroups() {
|
||||
List<String> groups = new ArrayList<>();
|
||||
boolean success = runQuery(GROUP_SELECT_ALL, resultSet -> {
|
||||
boolean b = true;
|
||||
boolean b = runQuery(GROUP_SELECT_ALL, resultSet -> {
|
||||
while (resultSet.next()) {
|
||||
String name = resultSet.getString("name");
|
||||
if (!loadGroup(name)) {
|
||||
b = false;
|
||||
}
|
||||
groups.add(name);
|
||||
}
|
||||
return b;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
if (!b) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String g : groups) {
|
||||
if (!loadGroup(g)) {
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (b) {
|
||||
GroupManager gm = plugin.getGroupManager();
|
||||
gm.getAll().values().stream()
|
||||
.filter(g -> !groups.contains(g.getName()))
|
||||
.forEach(gm::unload);
|
||||
}
|
||||
return success;
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -404,25 +410,31 @@ abstract class SQLDatastore extends Datastore {
|
||||
@Override
|
||||
public boolean loadAllTracks() {
|
||||
List<String> tracks = new ArrayList<>();
|
||||
boolean success = runQuery(TRACK_SELECT_ALL, resultSet -> {
|
||||
boolean b = true;
|
||||
boolean b = runQuery(TRACK_SELECT_ALL, resultSet -> {
|
||||
while (resultSet.next()) {
|
||||
String name = resultSet.getString("name");
|
||||
if (!loadTrack(name)) {
|
||||
b = false;
|
||||
}
|
||||
tracks.add(name);
|
||||
}
|
||||
return b;
|
||||
return true;
|
||||
});
|
||||
|
||||
if (success) {
|
||||
if (!b) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (String t : tracks) {
|
||||
if (!loadTrack(t)) {
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (b) {
|
||||
TrackManager tm = plugin.getTrackManager();
|
||||
tm.getAll().values().stream()
|
||||
.filter(t -> !tracks.contains(t.getName()))
|
||||
.forEach(tm::unload);
|
||||
}
|
||||
return success;
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user