Fix memory leak in ItemSnowball

This commit is contained in:
samczsun 2016-10-10 00:21:43 -04:00 committed by Shaun Bennett
parent 2ed03147b0
commit 38ef65c32e

View File

@ -16,6 +16,8 @@ import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class ItemSnowball extends ItemGadget
{
@ -59,4 +61,12 @@ public class ItemSnowball extends ItemGadget
event.getDamager().getWorld().playSound(event.getDamager().getLocation(), Sound.STEP_SNOW, 1, 0.5f);
}
@EventHandler
public void cleanup(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
_snowballs.entrySet().removeIf(ent -> !ent.getKey().isValid());
}
}