Skip to content

Commit

Permalink
Merge pull request #49 from 16Depression16/feature
Browse files Browse the repository at this point in the history
fix: ConcurrentModificationException in viewers
  • Loading branch information
CatCoderr authored Jul 23, 2023
2 parents 40ed0a2 + 317fcc4 commit 363c8d9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/main/java/me/catcoder/sidebar/Sidebar.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,20 +446,20 @@ public List<SidebarLine<R>> getLines() {
private void broadcast(@NonNull ThrowingConsumer<Player, Throwable> consumer) {
synchronized (viewers) {
viewers.removeIf(uuid -> Bukkit.getPlayer(uuid) == null);
}

for (UUID id : viewers) {
// double check
Player player = Bukkit.getPlayer(id);
if (player == null) {
continue;
}
for (UUID id : viewers) {
// double check
Player player = Bukkit.getPlayer(id);
if (player == null) {
continue;
}

try {
consumer.accept(player);
} catch (Throwable e) {
throw new RuntimeException("An error occurred while updating sidebar for player: " + player.getName(),
e);
try {
consumer.accept(player);
} catch (Throwable e) {
throw new RuntimeException("An error occurred while updating sidebar for player: " + player.getName(),
e);
}
}
}
}
Expand Down

0 comments on commit 363c8d9

Please sign in to comment.