use of me.lucko.luckperms.common.managers.group.GroupManager in project LuckPerms by lucko.
the class SqlDao method loadAllGroups.
@Override
public void loadAllGroups() throws SQLException {
List<String> groups = new ArrayList<>();
try (Connection c = this.provider.getConnection()) {
try (PreparedStatement ps = c.prepareStatement(this.prefix.apply(GROUP_SELECT_ALL))) {
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
groups.add(rs.getString("name").toLowerCase());
}
}
}
}
boolean success = true;
for (String g : groups) {
try {
loadGroup(g);
} catch (Exception e) {
e.printStackTrace();
success = false;
}
}
if (!success) {
throw new RuntimeException("Exception occurred whilst loading a group");
}
GroupManager<?> gm = this.plugin.getGroupManager();
gm.getAll().values().stream().filter(g -> !groups.contains(g.getName())).forEach(gm::unload);
}
Aggregations