Merge branch 'master' of ssh://198.245.50.91:7999/min/master

This commit is contained in:
Chiss 2013-09-02 09:35:27 +10:00
commit 3384d8e057

View File

@ -2,6 +2,7 @@ package mineplex.core.shop;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.List; import java.util.List;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -36,6 +37,8 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
protected String Name; protected String Name;
protected NautHashMap<String, ShopPageBase<PluginType, ? extends ShopBase<PluginType>>> PlayerPageMap; 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) public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes)
{ {
Plugin = plugin; Plugin = plugin;
@ -66,7 +69,10 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
if (event.getDamager() instanceof Player) if (event.getDamager() instanceof Player)
{ {
if (AttemptShopOpen((Player)event.getDamager(), (LivingEntity)event.getEntity())) if (AttemptShopOpen((Player)event.getDamager(), (LivingEntity)event.getEntity()))
{
System.out.println("Cancelling dmg event for shop.");
event.setCancelled(true); 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))) if (entity.isCustomNameVisible() && entity.getCustomName() != null && ChatColor.stripColor(entity.getCustomName()).equalsIgnoreCase(ChatColor.stripColor(Name)))
{ {
_openingShop.add(player.getName());
OpenShopForPlayer(player); OpenShopForPlayer(player);
if (!PlayerPageMap.containsKey(player.getName())) if (!PlayerPageMap.containsKey(player.getName()))
{ {
@ -93,6 +101,8 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
OpenPageForPlayer(player, GetOpeningPageForPlayer(player)); OpenPageForPlayer(player, GetOpeningPageForPlayer(player));
_openingShop.remove(player.getName());
return true; return true;
} }
@ -117,7 +127,7 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
@EventHandler @EventHandler
public void OnInventoryClose(InventoryCloseEvent event) 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()).PlayerClosed();
PlayerPageMap.get(event.getPlayer().getName()).Dispose(); PlayerPageMap.get(event.getPlayer().getName()).Dispose();