Added extra cleanup for FriendsGUI and AddFriendPage

This commit is contained in:
Jonathan Williams 2015-11-01 17:42:23 -06:00
parent 5c2ade8270
commit cb96124feb
2 changed files with 20 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
public class AddFriendPage implements Listener
@ -91,6 +92,15 @@ public class AddFriendPage implements Listener
_currentInventory.clear();
HandlerList.unregisterAll(this);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
if (event.getPlayer() == _player)
{
unregisterListener();
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event)

View File

@ -18,6 +18,7 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.EntityPlayer;
@ -573,6 +574,15 @@ public class FriendsGUI implements Listener
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
if (event.getPlayer() == _player)
{
unregisterListener();
}
}
@EventHandler
public void OnInventoryClose(InventoryCloseEvent event)
{