Fixed shop inventory loss bug.

Added IgnoreUpdate.dat file check for testing with FileUPdater.
Fixed bug in SkillPage
Fixed bug in ClassCombatShop
Disabled dragon spawning in hub.
This commit is contained in:
Jonathan Williams 2013-09-02 16:20:14 -07:00
parent 59f2b9ebc8
commit 5aec6509ca
5 changed files with 31 additions and 18 deletions

View File

@ -37,7 +37,7 @@ 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>();
private HashSet<String> _openedShop = new HashSet<String>();
public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes)
{
@ -70,7 +70,6 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
{
if (AttemptShopOpen((Player)event.getDamager(), (LivingEntity)event.getEntity()))
{
System.out.println("Cancelling dmg event for shop.");
event.setCancelled(true);
}
}
@ -89,9 +88,10 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
private boolean AttemptShopOpen(Player player, LivingEntity entity)
{
if (entity.isCustomNameVisible() && entity.getCustomName() != null && ChatColor.stripColor(entity.getCustomName()).equalsIgnoreCase(ChatColor.stripColor(Name)))
if (!_openedShop.contains(player.getName()) && entity.isCustomNameVisible() && entity.getCustomName() != null && ChatColor.stripColor(entity.getCustomName()).equalsIgnoreCase(ChatColor.stripColor(Name)))
{
_openingShop.add(player.getName());
_openedShop.add(player.getName());
OpenShopForPlayer(player);
if (!PlayerPageMap.containsKey(player.getName()))
@ -101,8 +101,6 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
OpenPageForPlayer(player, GetOpeningPageForPlayer(player));
_openingShop.remove(player.getName());
return true;
}
@ -127,13 +125,16 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
@EventHandler
public void OnInventoryClose(InventoryCloseEvent event)
{
if (!_openingShop.contains(event.getPlayer().getName()) && PlayerPageMap.containsKey(event.getPlayer().getName()) && PlayerPageMap.get(event.getPlayer().getName()).getTitle().equalsIgnoreCase(event.getInventory().getTitle()))
if (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();
CloseShopForPlayer((Player)event.getPlayer());
PlayerPageMap.remove(event.getPlayer().getName());
CloseShopForPlayer((Player)event.getPlayer());
_openedShop.remove(event.getPlayer().getName());
}
}
@ -158,6 +159,8 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
CloseShopForPlayer(event.getPlayer());
PlayerPageMap.remove(event.getPlayer().getName());
_openedShop.remove(event.getPlayer().getName());
}
}

View File

@ -24,6 +24,7 @@ public class FileUpdater extends MiniPlugin
private NautHashMap<String, String> _jarMd5Map = new NautHashMap<String, String>();
private boolean _needUpdate;
private boolean _enabled;
public FileUpdater(JavaPlugin plugin, Portal portal)
{
@ -32,6 +33,9 @@ public class FileUpdater extends MiniPlugin
_portal = portal;
GetPluginMd5s();
if (new File("IgnoreUpdates.dat").exists())
_enabled = false;
}
@EventHandler
@ -40,7 +44,7 @@ public class FileUpdater extends MiniPlugin
if (event.getType() != UpdateType.SLOWER)
return;
if (!_needUpdate)
if (!_needUpdate || !_enabled)
return;
RestartServerEvent restartEvent = new RestartServerEvent();
@ -82,7 +86,7 @@ public class FileUpdater extends MiniPlugin
if (event.getType() != UpdateType.MIN_01)
return;
if (_needUpdate)
if (_needUpdate || !_enabled)
return;
boolean windows = System.getProperty("os.name").startsWith("Windows");

View File

@ -83,7 +83,7 @@ public class Dragon extends MiniPlugin
if (Dragon == null || !Dragon.isValid())
{
Spawn();
//Spawn();
return;
}

View File

@ -63,12 +63,15 @@ public class ClassCombatShop extends ShopBase<ClassShopManager>
clientClass.SaveActiveCustomBuild();
}
if (player.isOnline() && (Purchasing || Customizing))
if (player.isOnline())
{
player.getInventory().setContents(_inventoryStorage.get(player.getName()));
player.getInventory().setArmorContents(_armorStorage.get(player.getName()));
if (Purchasing || Customizing)
{
player.getInventory().setContents(_inventoryStorage.get(player.getName()));
player.getInventory().setArmorContents(_armorStorage.get(player.getName()));
}
((CraftPlayer)player).getHandle().updateInventory(((CraftPlayer)player).getHandle().defaultContainer);
}
((CraftPlayer)player).getHandle().updateInventory(((CraftPlayer)player).getHandle().defaultContainer);
}
}

View File

@ -44,9 +44,12 @@ public class SkillPage extends ShopPageBase<ClassShopManager, ClassCombatShop>
{
super.PlayerClosed();
for (int i = 9; i < 36; i++)
if (Player.isOnline())
{
Player.getInventory().setItem(i, null);
for (int i = 9; i < 36; i++)
{
Player.getInventory().setItem(i, null);
}
}
}