From 0cbd4a9de2b6725ca2052b8b81442ad56b5f3707 Mon Sep 17 00:00:00 2001 From: samczsun Date: Fri, 30 Sep 2016 19:28:21 -0400 Subject: [PATCH] Fix memory leak in Teleport --- .../Mineplex.Core/src/mineplex/core/teleport/Teleport.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java index 0b7ba2cfa..d93abe6e9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/teleport/Teleport.java @@ -25,6 +25,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.world.WorldUnloadEvent; import org.bukkit.plugin.java.JavaPlugin; import java.util.HashMap; @@ -117,6 +118,12 @@ public class Teleport extends MiniPlugin _tpHistory.remove(event.GetName()); } + @EventHandler + public void on(WorldUnloadEvent event) + { + _tpHistory.values().forEach(list -> list.removeIf(location -> location.getWorld() == event.getWorld())); + } + @EventHandler public void update(UpdateEvent event) {