Merge pull request #2458 from BentoBoxWorld/2456_mysterious_exception

More code to clean up when an island is deleted. #2456
This commit is contained in:
tastybento 2024-08-05 17:06:21 -07:00 committed by GitHub
commit 220fc72a21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -171,8 +171,15 @@ public class IslandCache {
} }
private void removeFromIslandsByUUID(Island island) { private void removeFromIslandsByUUID(Island island) {
for (Set<String> set : islandsByUUID.values()) { Iterator<Map.Entry<UUID, Set<String>>> iterator = islandsByUUID.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<UUID, Set<String>> entry = iterator.next();
Set<String> set = entry.getValue();
set.removeIf(island.getUniqueId()::equals); set.removeIf(island.getUniqueId()::equals);
if (set.isEmpty()) {
// Removes the overall entry if there is nothing left in the set
iterator.remove();
}
} }
} }