mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-24 08:05:26 +02:00
@@ -38,5 +38,14 @@ public class PersistentDataConfig extends BukkitConfig {
|
||||
return config.getBoolean("mcMMO_Region_System.Enabled", true);
|
||||
}
|
||||
|
||||
public boolean cleanupMobDataOnChunkUnload() {
|
||||
return config.getBoolean("Persistent_Data.Advanced.Transient_Memory_Cleanup.On_Chunk_Unload", true);
|
||||
}
|
||||
|
||||
public boolean cleanupMobDataOnWorldUnload() {
|
||||
return config.getBoolean("Persistent_Data.Advanced.Transient_Memory_Cleanup.On_World_Unload", true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -664,7 +664,7 @@ public class EntityListener implements Listener {
|
||||
* @param event
|
||||
* The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onEntityDeathLowest(EntityDeathEvent event) {
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(event.getEntity());
|
||||
}
|
||||
|
@@ -1,9 +1,12 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import com.gmail.nossr50.config.PersistentDataConfig;
|
||||
import com.gmail.nossr50.config.WorldBlacklist;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -39,13 +42,23 @@ public class WorldListener implements Listener {
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
/* WORLD BLACKLIST CHECK */
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getWorld()))
|
||||
return;
|
||||
|
||||
mcMMO.getPlaceStore().unloadWorld(event.getWorld());
|
||||
|
||||
if(PersistentDataConfig.getInstance().cleanupMobDataOnWorldUnload())
|
||||
{
|
||||
for(Entity entity : event.getWorld().getEntities()) {
|
||||
if(entity instanceof LivingEntity livingEntity) {
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,5 +75,14 @@ public class WorldListener implements Listener {
|
||||
Chunk chunk = event.getChunk();
|
||||
|
||||
mcMMO.getPlaceStore().chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
|
||||
|
||||
if(PersistentDataConfig.getInstance().cleanupMobDataOnChunkUnload()) {
|
||||
for(Entity entity : event.getWorld().getEntities()) {
|
||||
if(entity instanceof LivingEntity livingEntity) {
|
||||
mcMMO.getTransientMetadataTools().cleanLivingEntityMetadata(livingEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user