refactor: track vanished players - #204
Conversation
left a comment
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| List<Player> players = new ArrayList<>(); | ||
| Iterator<UUID> iterator = VANISHED_PLAYERS.iterator(); | ||
| while (iterator.hasNext()) { | ||
| UUID uuid = iterator.next(); | ||
| Player vanished = plugin.getServer().getPlayer(uuid); | ||
| if (vanished == null || !isVanished(vanished)) { | ||
| iterator.remove(); |
There was a problem hiding this comment.
Removing from concurrent vanish cache via unsupported iterator
The vanish cache now uses ConcurrentHashMap.newKeySet(), but getVanishedPlayers tries to clean stale UUIDs using iterator.remove(). Iterators from ConcurrentHashMap’s key set do not support the optional remove operation and will throw UnsupportedOperationException. Once any vanished player disconnects (or loses the metadata) and another player calls this method—e.g. on the next join—the listener will crash before hiding vanished players for the newcomer. Remove stale entries by calling VANISHED_PLAYERS.remove(uuid) outside the iterator or by collecting them into a list rather than invoking iterator.remove().
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f6169269dc8321b7a463d1f2053fa6