Permission error fix when plugin added new permission

This commit is contained in:
ArpyAge 2022-10-13 19:45:58 +02:00
parent 50f0dc7fb8
commit 8ee87fcdd9

View File

@ -40,25 +40,23 @@ public class PermissionsManager {
private void loadPermissions() { private void loadPermissions() {
this.badges.clear(); this.badges.clear();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permissions ORDER BY id ASC")) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); Statement statement = connection.createStatement(); ResultSet set = statement.executeQuery("SELECT * FROM permissions ORDER BY id ASC")) {
try (ResultSet set = statement.executeQuery()) { while (set.next()) {
while (set.next()) { Rank rank = null;
Rank rank = null; if (!this.ranks.containsKey(set.getInt("id"))) {
if (!this.ranks.containsKey(set.getInt("id"))) { rank = new Rank(set);
rank = new Rank(set); this.ranks.put(set.getInt("id"), rank);
this.ranks.put(set.getInt("id"), rank); } else {
} else { rank = this.ranks.get(set.getInt("id"));
rank = this.ranks.get(set.getInt("id")); rank.load(set);
rank.load(set); }
if (rank != null && !rank.getBadge().isEmpty()) {
if (!this.badges.containsKey(rank.getBadge())) {
this.badges.put(rank.getBadge(), new ArrayList<Rank>());
} }
if (rank != null && !rank.getBadge().isEmpty()) { this.badges.get(rank.getBadge()).add(rank);
if (!this.badges.containsKey(rank.getBadge())) {
this.badges.put(rank.getBadge(), new ArrayList<Rank>());
}
this.badges.get(rank.getBadge()).add(rank);
}
} }
} }
} catch (SQLException e) { } catch (SQLException e) {