Fixed shop bug affecting server menu and class setup in hub.

This commit is contained in:
Jonathan Williams 2013-09-01 16:17:44 -07:00
parent 5380899cfe
commit 148c288d4f

View File

@ -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<PluginType extends MiniPlugin> implements Listene
protected String Name;
protected NautHashMap<String, ShopPageBase<PluginType, ? extends ShopBase<PluginType>>> PlayerPageMap;
private HashSet<String> _openingShop = new HashSet<String>();
public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes)
{
Plugin = plugin;
@ -66,7 +69,10 @@ public abstract class ShopBase<PluginType extends MiniPlugin> 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<PluginType extends MiniPlugin> 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<PluginType extends MiniPlugin> implements Listene
OpenPageForPlayer(player, GetOpeningPageForPlayer(player));
_openingShop.remove(player.getName());
return true;
}
@ -117,7 +127,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> 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();