Skip to content

Commit bafc17e

Browse files
committed
Fix auto-leave-on-end: true error.
The ConcurrentModificationException happens because the player leave procedure alters the `specPlayers` set, and this is the set we iterate during the automatic spectator kicking procedure. By making a copy of the set and iterating the copy, we circumvent this problem. Java 101, really, but when the code is stateful and complex, it's "fair enough" that it slipped through the cracks. It's also impossible to reproduce without at least two players, so go figure... Fixes #802
1 parent b4db449 commit bafc17e

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ These changes will (most likely) be included in the next version.
2424

2525
### Fixed
2626
- MobArena no longer throws errors when handling block explosions on Minecraft 1.21.
27+
- MobArena no longer throws errors during the automatic removal of spectators when using `auto-leave-on-end: true`.
2728
- The `shuffle-positions` ability now correctly shuffles the position of the boss as well if `monster-teleport` is set to `false`.
2829
- The `obsidian-bomb` ability no longer breaks boss waves.
2930
- Text on Arena Signs is no longer explicitly truncated. This fixes an issue where color codes would count towards the character limit, causing the text that would otherwise fit on the sign to be cut off.

src/main/java/com/garbagemule/MobArena/ArenaImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,8 @@ public boolean endArena() {
665665

666666
// Auto-leave
667667
if (settings.getBoolean("auto-leave-on-end", false)) {
668-
specPlayers.forEach(this::playerLeave);
668+
List<Player> spectators = new ArrayList<>(specPlayers);
669+
spectators.forEach(this::playerLeave);
669670
}
670671

671672
return true;

0 commit comments

Comments
 (0)