mirror of
https://github.com/Zrips/Jobs.git
synced 2025-02-06 23:41:21 +01:00
Removing Jobs metadata from all entities on chunk unload to avoid memory
leaks This will potentially introduce small issue with entities spawned from spawner paying out after player returns to that area. Future update might be needed to mitigate this.
This commit is contained in:
parent
a0dd4c2925
commit
9df5287555
@ -134,7 +134,6 @@ import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMC;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Locale.LC;
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
import net.Zrips.CMILib.Version.Schedulers.CMIScheduler;
|
||||
@ -1306,7 +1305,7 @@ public final class JobsPaymentListener implements Listener {
|
||||
|
||||
if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) {
|
||||
killer = entityLastDamager.getIfPresent(event.getEntity().getUniqueId());
|
||||
} else if(event.getEntity().getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
|
||||
} else if (event.getEntity().getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
|
||||
killer = event.getEntity().getLastDamageCause().getDamageSource().getCausingEntity();
|
||||
} else {
|
||||
killer = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
|
||||
@ -1929,9 +1928,6 @@ public final class JobsPaymentListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
for (Entity entity : event.getChunk().getEntities()) {
|
||||
if (Version.isCurrentEqualOrHigher(Version.v1_13_R1) && entity.isPersistent())
|
||||
break;
|
||||
|
||||
entity.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user