diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index fbb9c9731..89b95e821 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -2,6 +2,7 @@ package mineplex.core.shop; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; import org.bukkit.entity.LivingEntity; @@ -36,6 +37,8 @@ public abstract class ShopBase implements Listene protected String Name; protected NautHashMap>> PlayerPageMap; + private HashSet _openingShop = new HashSet(); + public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes) { Plugin = plugin; @@ -66,7 +69,10 @@ public abstract class ShopBase implements Listene if (event.getDamager() instanceof Player) { if (AttemptShopOpen((Player)event.getDamager(), (LivingEntity)event.getEntity())) + { + System.out.println("Cancelling dmg event for shop."); event.setCancelled(true); + } } } } @@ -85,6 +91,8 @@ public abstract class ShopBase implements Listene { if (entity.isCustomNameVisible() && entity.getCustomName() != null && ChatColor.stripColor(entity.getCustomName()).equalsIgnoreCase(ChatColor.stripColor(Name))) { + _openingShop.add(player.getName()); + OpenShopForPlayer(player); if (!PlayerPageMap.containsKey(player.getName())) { @@ -93,6 +101,8 @@ public abstract class ShopBase implements Listene OpenPageForPlayer(player, GetOpeningPageForPlayer(player)); + _openingShop.remove(player.getName()); + return true; } @@ -117,7 +127,7 @@ public abstract class ShopBase implements Listene @EventHandler public void OnInventoryClose(InventoryCloseEvent event) { - if (PlayerPageMap.containsKey(event.getPlayer().getName()) && PlayerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle())) + if (!_openingShop.contains(event.getPlayer().getName()) && PlayerPageMap.containsKey(event.getPlayer().getName()) && PlayerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle())) { PlayerPageMap.get(event.getPlayer().getName()).PlayerClosed(); PlayerPageMap.get(event.getPlayer().getName()).Dispose();