diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index d912758e2..9c4b27a94 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -5,24 +5,22 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; +import org.bukkit.ChatColor; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryCloseEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.ChatColor; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.NautHashMap; import mineplex.core.donation.DonationManager; -import mineplex.core.npc.NpcManager; import mineplex.core.npc.event.NpcDamageByEntityEvent; import mineplex.core.npc.event.NpcInteractEntityEvent; import mineplex.core.shop.page.ShopPageBase; @@ -159,6 +157,25 @@ public abstract class ShopBase implements Listene OpenedShop.remove(event.getPlayer().getName()); } } + + @EventHandler(priority = EventPriority.MONITOR) + public void onInventoryOpen(InventoryOpenEvent event) + { + if (!event.isCancelled()) + return; + + if (PlayerPageMap.containsKey(event.getPlayer().getName()) && PlayerPageMap.get(event.getPlayer().getName()).getTitle() != null && PlayerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle())) + { + PlayerPageMap.get(event.getPlayer().getName()).PlayerClosed(); + PlayerPageMap.get(event.getPlayer().getName()).Dispose(); + + PlayerPageMap.remove(event.getPlayer().getName()); + + CloseShopForPlayer((Player)event.getPlayer()); + + OpenedShop.remove(event.getPlayer().getName()); + } + } protected boolean CanOpenShop(Player player) {