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