From 5aec6509cacf6c872ec050824853f0fb9d193e0b Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 2 Sep 2013 16:20:14 -0700 Subject: [PATCH] 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. --- .../src/mineplex/core/shop/ShopBase.java | 19 +++++++++++-------- .../mineplex/core/updater/FileUpdater.java | 8 ++++++-- .../Mineplex.Hub/src/mineplex/hub/Dragon.java | 2 +- .../classcombat/shop/ClassCombatShop.java | 13 ++++++++----- .../game/classcombat/shop/page/SkillPage.java | 7 +++++-- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java index 89b95e821..16971a97a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/ShopBase.java @@ -37,7 +37,7 @@ public abstract class ShopBase implements Listene protected String Name; protected NautHashMap>> PlayerPageMap; - private HashSet _openingShop = new HashSet(); + private HashSet _openedShop = new HashSet(); public ShopBase(PluginType plugin, CoreClientManager clientManager, DonationManager donationManager, String name, CurrencyType...currencyTypes) { @@ -70,7 +70,6 @@ public abstract class ShopBase 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 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 implements Listene OpenPageForPlayer(player, GetOpeningPageForPlayer(player)); - _openingShop.remove(player.getName()); - return true; } @@ -127,13 +125,16 @@ public abstract class ShopBase 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 implements Listene CloseShopForPlayer(event.getPlayer()); PlayerPageMap.remove(event.getPlayer().getName()); + + _openedShop.remove(event.getPlayer().getName()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java index eb726c064..fc7d2db2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/FileUpdater.java @@ -24,6 +24,7 @@ public class FileUpdater extends MiniPlugin private NautHashMap _jarMd5Map = new NautHashMap(); 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"); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java index acfe197c7..837ec2cf6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Dragon.java @@ -83,7 +83,7 @@ public class Dragon extends MiniPlugin if (Dragon == null || !Dragon.isValid()) { - Spawn(); + //Spawn(); return; } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java index bf018fac9..190c49ae1 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/ClassCombatShop.java @@ -63,12 +63,15 @@ public class ClassCombatShop extends ShopBase 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); } } diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java index 68471016f..90b2f026b 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/shop/page/SkillPage.java @@ -44,9 +44,12 @@ public class SkillPage extends ShopPageBase { 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); + } } }