From d00fa856f3cc4bb8bb9c31d25fedeedc47838b32 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 16 Oct 2015 01:57:19 -0500 Subject: [PATCH] Fixed Pets so they work correctly. Also fixed legend benefits. Fixed chest pet rewards. --- .../core/cosmetic/ui/page/GadgetPage.java | 2 +- .../core/cosmetic/ui/page/PetPage.java | 2 +- .../core/gadget/gadgets/MorphWither.java | 7 +++++-- .../core/gadget/gadgets/ParticleLegend.java | 7 +++++-- .../src/mineplex/core/pet/PetManager.java | 18 +++++++++++++----- .../src/mineplex/core/pet/types/Pumpkin.java | 1 - .../core/reward/rewards/PetReward.java | 16 +++++++++++++--- .../reward/rewards/UnknownPackageReward.java | 14 +++++--------- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 6 ++++-- .../src/mineplex/hub/HubManager.java | 4 ++-- .../src/nautilus/game/arcade/Arcade.java | 2 +- 11 files changed, 50 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index ff4df34ed..6a75916e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -109,7 +109,7 @@ public class GadgetPage extends ShopPageBase itemLore.add(C.cWhite + "Your Ammo : " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetName())); } - if (gadget.IsFree() || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(gadget.GetName())) + if (gadget.IsFree() || getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(gadget.GetName()) || getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetName()) > 0) { if (gadget.GetActive().contains(getPlayer())) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index c9a544b93..3262033c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -80,7 +80,7 @@ public class PetPage extends ShopPageBase } //Owned - if (getDonationManager().Get(getPlayer().getName()).OwnsUnknownPackage(pet.GetPetName())) + if (getPlugin().getPetManager().Get(getPlayer()).GetPets().containsKey(pet.GetPetType())) { String petName = getPlugin().getPetManager().Get(getPlayer()).GetPets().get(pet.GetPetType()); if (petName == null) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java index f5007eba2..602868005 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/MorphWither.java @@ -20,6 +20,8 @@ import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.inventory.ClientItem; +import mineplex.core.inventory.data.Item; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -179,10 +181,11 @@ public class MorphWither extends MorphGadget @EventHandler public void legendOwner(PlayerJoinEvent event) { + // TODO HARDCODED Wither Morph Database Item Id - 550 if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); - } + Manager.getInventoryManager().Get(event.getPlayer().getName()).addItem(new ClientItem(new Item(550, GetName()), 1)); + } } public void setWitherData(String text, double healthPercent) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java index 7be1a9609..ac5c3aaa8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/ParticleLegend.java @@ -9,6 +9,8 @@ import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.gadget.types.ParticleGadget; +import mineplex.core.inventory.ClientItem; +import mineplex.core.inventory.data.Item; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.gadget.GadgetManager; @@ -46,9 +48,10 @@ public class ParticleLegend extends ParticleGadget @EventHandler public void legendOwner(PlayerJoinEvent event) { + // TODO HARDCODED Legendary Aura Database Item Id - 552 if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) { - Manager.getDonationManager().Get(event.getPlayer().getName()).AddUnknownSalesPackagesOwned(GetName()); - } + Manager.getInventoryManager().Get(event.getPlayer().getName()).addItem(new ClientItem(new Item(552, GetName()), 1)); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 46488298a..bd746ab78 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -19,6 +19,9 @@ import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; +import mineplex.core.inventory.ClientItem; +import mineplex.core.inventory.InventoryManager; +import mineplex.core.inventory.data.Item; import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_7_R4.EntityWither; import net.minecraft.server.v1_7_R4.Navigation; @@ -70,8 +73,10 @@ public class PetManager extends MiniClientPlugin private NautHashMap _petRenameQueue = new NautHashMap(); private DonationManager _donationManager; private CoreClientManager _clientManager; + private InventoryManager _inventoryManager; - public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, String webAddress) + public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager + , InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, String webAddress) { super("Pet Manager", plugin); @@ -82,6 +87,7 @@ public class PetManager extends MiniClientPlugin _blockRestore = restore; _donationManager = donationManager; _clientManager = clientManager; + _inventoryManager = inventoryManager; _activePetOwners = new NautHashMap(); _failedAttempts = new NautHashMap(); @@ -146,10 +152,12 @@ public class PetManager extends MiniClientPlugin { Player p = event.getPlayer(); Rank rank = _clientManager.Get(p).GetRank(); - if (rank.has(Rank.LEGEND)) - { - _donationManager.Get(p.getName()).AddUnknownSalesPackagesOwned("Widder"); - } + + if (rank.has(Rank.LEGEND)) + { + if (!Get(p).GetPets().containsKey(EntityType.WITHER)) + Get(p).GetPets().put(EntityType.WITHER, "Widder"); + } } public void AddPetOwner(Player player, EntityType entityType, Location location) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java index ae646cb75..71b561f2c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/types/Pumpkin.java @@ -10,5 +10,4 @@ public class Pumpkin extends Pet { super("Pumpling", EntityType.ZOMBIE, -1); } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java index 30de68f6a..a8329f895 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/PetReward.java @@ -51,12 +51,22 @@ public class PetReward extends UnknownPackageReward petToken.PetType = token.PetType; _petManager.GetRepository().AddPet(token); -// _petManager.addPetOwnerToQueue(player.getName(), _petEntity); - _petManager.Get(player).GetPets().put(_petEntity, token.PetName); _inventoryManager.addItemToInventory(player, _petEntity.toString(), 1); - return super.giveRewardCustom(player); + return getFakeRewardData(player); + } + + @Override + public boolean canGiveReward(Player player) + { + if (DonationManager.Get(player.getName()) == null) + { + System.out.println("Could not give reward " + getPackageName() + " to Offline Player: " + player.getName()); + return false; + } + + return !_petManager.Get(player).GetPets().containsKey(_petEntity); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index af27a817e..cc2a2e41e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -6,15 +6,11 @@ import org.bukkit.inventory.ItemStack; import mineplex.core.donation.DonationManager; import mineplex.core.reward.Reward; import mineplex.core.reward.RewardData; -import mineplex.core.reward.RewardManager; import mineplex.core.reward.RewardRarity; -/** - * Created by shaun on 14-09-12. - */ public class UnknownPackageReward extends Reward { - private DonationManager _donationManager; + protected DonationManager DonationManager; private ItemStack _itemStack; private String _name; private String _packageName; @@ -22,7 +18,7 @@ public class UnknownPackageReward extends Reward public UnknownPackageReward(DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight) { super(rarity, weight); - _donationManager = donationManager; + DonationManager = donationManager; _name = name; _packageName = packageName; _itemStack = itemStack; @@ -31,7 +27,7 @@ public class UnknownPackageReward extends Reward @Override protected RewardData giveRewardCustom(Player player) { - _donationManager.PurchaseUnknownSalesPackage(null, player.getName(), _donationManager.getClientManager().Get(player).getAccountId(), _packageName, true, 0, true); + DonationManager.PurchaseUnknownSalesPackage(null, player.getName(), DonationManager.getClientManager().Get(player).getAccountId(), _packageName, true, 0, true); return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity()); } @@ -39,13 +35,13 @@ public class UnknownPackageReward extends Reward @Override public boolean canGiveReward(Player player) { - if (_donationManager.Get(player.getName()) == null) + if (DonationManager.Get(player.getName()) == null) { System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName()); return false; } - return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); + return !DonationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); } @Override diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 169aedbf4..b0074e49b 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -21,6 +21,7 @@ import mineplex.core.friend.FriendManager; import mineplex.core.give.Give; import mineplex.core.hologram.HologramManager; import mineplex.core.ignore.IgnoreManager; +import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.memory.MemoryFix; import mineplex.core.message.MessageManager; @@ -103,7 +104,8 @@ public class Hub extends JavaPlugin implements IRelation preferenceManager.GiveItem = true; Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); - PetManager petManager = new PetManager(this, clientManager, donationManager, disguiseManager, creature, blockRestore, webServerAddress); + InventoryManager inventoryManager = new InventoryManager(this, clientManager); + PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); PollManager pollManager = new PollManager(this, clientManager, donationManager); //Main Modules @@ -124,7 +126,7 @@ public class Hub extends JavaPlugin implements IRelation PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, donationManager, inventoryManager, new ConditionManager(this), disguiseManager, new TaskManager(this, clientManager, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this), npcManager, personalServerManager, packetHandler, punish); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index b2839d5af..3275fac65 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -158,7 +158,7 @@ public class HubManager extends MiniClientPlugin //Admin private boolean _gadgetsEnabled = true; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish) { super("Hub Manager", plugin); @@ -187,7 +187,7 @@ public class HubManager extends MiniClientPlugin _news = new NewsManager(this); _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); - _inventoryManager = new InventoryManager(plugin, clientManager); + _inventoryManager = inventoryManager; new BenefitManager(plugin, clientManager, _inventoryManager); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 71fa876f8..85889628c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -141,7 +141,7 @@ public class Arcade extends JavaPlugin //Inventory InventoryManager inventoryManager = new InventoryManager(this, _clientManager); - PetManager petManager = new PetManager(this, _clientManager, _donationManager, disguiseManager, creature, blockRestore, webServerAddress); + PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, webServerAddress); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);