Fixed Pets so they work correctly.

Also fixed legend benefits.
Fixed chest pet rewards.
This commit is contained in:
Jonathan Williams 2015-10-16 01:57:19 -05:00
parent 1c52bd4f64
commit d00fa856f3
11 changed files with 50 additions and 29 deletions

View File

@ -109,7 +109,7 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cWhite + "Your Ammo : " + C.cGreen + getPlugin().getInventoryManager().Get(getPlayer()).getItemCount(gadget.GetName())); 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())) if (gadget.GetActive().contains(getPlayer()))
{ {

View File

@ -80,7 +80,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
} }
//Owned //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()); String petName = getPlugin().getPetManager().Get(getPlayer()).GetPets().get(pet.GetPetType());
if (petName == null) if (petName == null)

View File

@ -20,6 +20,8 @@ import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.MorphGadget; 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.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -179,10 +181,11 @@ public class MorphWither extends MorphGadget
@EventHandler @EventHandler
public void legendOwner(PlayerJoinEvent event) public void legendOwner(PlayerJoinEvent event)
{ {
// TODO HARDCODED Wither Morph Database Item Id - 550
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) 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) public void setWitherData(String text, double healthPercent)

View File

@ -9,6 +9,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.gadget.types.ParticleGadget; 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.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
@ -46,9 +48,10 @@ public class ParticleLegend extends ParticleGadget
@EventHandler @EventHandler
public void legendOwner(PlayerJoinEvent event) public void legendOwner(PlayerJoinEvent event)
{ {
// TODO HARDCODED Legendary Aura Database Item Id - 552
if (Manager.getClientManager().Get(event.getPlayer()).GetRank().has(Rank.LEGEND)) 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));
} }
} }
} }

View File

@ -19,6 +19,9 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager; 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.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityWither; import net.minecraft.server.v1_7_R4.EntityWither;
import net.minecraft.server.v1_7_R4.Navigation; import net.minecraft.server.v1_7_R4.Navigation;
@ -70,8 +73,10 @@ public class PetManager extends MiniClientPlugin<PetClient>
private NautHashMap<String, String> _petRenameQueue = new NautHashMap<String, String>(); private NautHashMap<String, String> _petRenameQueue = new NautHashMap<String, String>();
private DonationManager _donationManager; private DonationManager _donationManager;
private CoreClientManager _clientManager; 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); super("Pet Manager", plugin);
@ -82,6 +87,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
_blockRestore = restore; _blockRestore = restore;
_donationManager = donationManager; _donationManager = donationManager;
_clientManager = clientManager; _clientManager = clientManager;
_inventoryManager = inventoryManager;
_activePetOwners = new NautHashMap<String, Creature>(); _activePetOwners = new NautHashMap<String, Creature>();
_failedAttempts = new NautHashMap<String, Integer>(); _failedAttempts = new NautHashMap<String, Integer>();
@ -146,10 +152,12 @@ public class PetManager extends MiniClientPlugin<PetClient>
{ {
Player p = event.getPlayer(); Player p = event.getPlayer();
Rank rank = _clientManager.Get(p).GetRank(); Rank rank = _clientManager.Get(p).GetRank();
if (rank.has(Rank.LEGEND))
{ if (rank.has(Rank.LEGEND))
_donationManager.Get(p.getName()).AddUnknownSalesPackagesOwned("Widder"); {
} if (!Get(p).GetPets().containsKey(EntityType.WITHER))
Get(p).GetPets().put(EntityType.WITHER, "Widder");
}
} }
public void AddPetOwner(Player player, EntityType entityType, Location location) public void AddPetOwner(Player player, EntityType entityType, Location location)

View File

@ -10,5 +10,4 @@ public class Pumpkin extends Pet
{ {
super("Pumpling", EntityType.ZOMBIE, -1); super("Pumpling", EntityType.ZOMBIE, -1);
} }
} }

View File

@ -51,12 +51,22 @@ public class PetReward extends UnknownPackageReward
petToken.PetType = token.PetType; petToken.PetType = token.PetType;
_petManager.GetRepository().AddPet(token); _petManager.GetRepository().AddPet(token);
// _petManager.addPetOwnerToQueue(player.getName(), _petEntity);
_petManager.Get(player).GetPets().put(_petEntity, token.PetName); _petManager.Get(player).GetPets().put(_petEntity, token.PetName);
_inventoryManager.addItemToInventory(player, _petEntity.toString(), 1); _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);
} }
} }

View File

@ -6,15 +6,11 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.reward.Reward; import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData; import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardRarity; import mineplex.core.reward.RewardRarity;
/**
* Created by shaun on 14-09-12.
*/
public class UnknownPackageReward extends Reward public class UnknownPackageReward extends Reward
{ {
private DonationManager _donationManager; protected DonationManager DonationManager;
private ItemStack _itemStack; private ItemStack _itemStack;
private String _name; private String _name;
private String _packageName; 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) public UnknownPackageReward(DonationManager donationManager, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight)
{ {
super(rarity, weight); super(rarity, weight);
_donationManager = donationManager; DonationManager = donationManager;
_name = name; _name = name;
_packageName = packageName; _packageName = packageName;
_itemStack = itemStack; _itemStack = itemStack;
@ -31,7 +27,7 @@ public class UnknownPackageReward extends Reward
@Override @Override
protected RewardData giveRewardCustom(Player player) 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()); return new RewardData(getRarity().getColor() + _name, _itemStack, getRarity());
} }
@ -39,13 +35,13 @@ public class UnknownPackageReward extends Reward
@Override @Override
public boolean canGiveReward(Player player) 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()); System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName());
return false; return false;
} }
return !_donationManager.Get(player.getName()).OwnsUnknownPackage(_packageName); return !DonationManager.Get(player.getName()).OwnsUnknownPackage(_packageName);
} }
@Override @Override

View File

@ -21,6 +21,7 @@ import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give; import mineplex.core.give.Give;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager; import mineplex.core.ignore.IgnoreManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix; import mineplex.core.memory.MemoryFix;
import mineplex.core.message.MessageManager; import mineplex.core.message.MessageManager;
@ -103,7 +104,8 @@ public class Hub extends JavaPlugin implements IRelation
preferenceManager.GiveItem = true; preferenceManager.GiveItem = true;
Creature creature = new Creature(this); Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature); 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); PollManager pollManager = new PollManager(this, clientManager, donationManager);
//Main Modules //Main Modules
@ -124,7 +126,7 @@ public class Hub extends JavaPlugin implements IRelation
PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager); PartyManager partyManager = new PartyManager(this, portal, clientManager, preferenceManager);
PersonalServerManager personalServerManager = new PersonalServerManager(this, clientManager); 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); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this, clientManager), partyManager);

View File

@ -158,7 +158,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Admin //Admin
private boolean _gadgetsEnabled = true; 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); super("Hub Manager", plugin);
@ -187,7 +187,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_news = new NewsManager(this); _news = new NewsManager(this);
_mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager); _mountManager = new MountManager(_plugin, clientManager, donationManager, blockRestore, _disguiseManager);
_inventoryManager = new InventoryManager(plugin, clientManager); _inventoryManager = inventoryManager;
new BenefitManager(plugin, clientManager, _inventoryManager); new BenefitManager(plugin, clientManager, _inventoryManager);
_gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager); _gadgetManager = new GadgetManager(_plugin, clientManager, donationManager, _inventoryManager, _mountManager, petManager, preferences, disguiseManager, blockRestore, new ProjectileManager(plugin), achievementManager);

View File

@ -141,7 +141,7 @@ public class Arcade extends JavaPlugin
//Inventory //Inventory
InventoryManager inventoryManager = new InventoryManager(this, _clientManager); 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); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager); 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); CosmeticManager cosmeticManager = new CosmeticManager(this, _clientManager, _donationManager, inventoryManager, gadgetManager, mountManager, petManager, null);