avoid concurrent exceptions on TransientEntityTracker

This commit is contained in:
nossr50 2020-12-31 16:26:37 -08:00
parent c05c8e1b1d
commit c408c7d057

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.skills.taming.TrackedTamingEntity;
import com.gmail.nossr50.util.player.NotificationManager; import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.text.StringUtils; import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableSet;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
@ -215,13 +216,17 @@ public class TransientEntityTracker {
for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) { for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
HashSet<TrackedTamingEntity> trackedEntities = getTrackedEntities(playerUUID, callOfTheWildType); HashSet<TrackedTamingEntity> trackedEntities = getTrackedEntities(playerUUID, callOfTheWildType);
if(trackedEntities == null) if(trackedEntities == null) {
continue; continue;
}
for(TrackedTamingEntity trackedTamingEntity : trackedEntities) { ImmutableSet<TrackedTamingEntity> immutableSet = ImmutableSet.copyOf(trackedEntities);
for(TrackedTamingEntity trackedTamingEntity : immutableSet) {
//Remove from existence //Remove from existence
removeSummon(trackedTamingEntity.getLivingEntity(), player, false); removeSummon(trackedTamingEntity.getLivingEntity(), player, false);
} }
} }
} }
} }