mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-26 10:44:43 +02:00
@ -15,9 +15,18 @@ public class ChunkListener implements Listener {
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
final Chunk unloadingChunk = event.getChunk();
|
||||
|
||||
Arrays.stream(unloadingChunk.getEntities())
|
||||
.filter(entity -> entity instanceof LivingEntity)
|
||||
.map(entity -> (LivingEntity) entity)
|
||||
.forEach(livingEntity -> mcMMO.getTransientEntityTracker().removeTrackedEntity(livingEntity));
|
||||
// Avoid processing if chunk is null or unloaded
|
||||
if (unloadingChunk == null || !unloadingChunk.isLoaded() || unloadingChunk.getEntities() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Arrays.stream(unloadingChunk.getEntities())
|
||||
.filter(entity -> entity instanceof LivingEntity)
|
||||
.map(entity -> (LivingEntity) entity)
|
||||
.forEach(livingEntity -> mcMMO.getTransientEntityTracker().removeTrackedEntity(livingEntity));
|
||||
} catch (Exception ex) {
|
||||
mcMMO.p.getLogger().warning("Caught exception during chunk unload event processing: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user