From adc57698909671012ab737c4ca592ccb3b27e896 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 24 Dec 2014 04:07:28 +1300 Subject: [PATCH] Fix wither not accessible for ranks, fix wither having weird naming in inventories --- .../mineplex/core/cosmetic/ui/page/Menu.java | 6 +++++- .../mineplex/core/cosmetic/ui/page/PetPage.java | 10 ++++++++-- .../src/mineplex/core/pet/PetManager.java | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 3a479d02d..b012cc6ac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.entity.Creature; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -185,7 +187,9 @@ public class Menu extends ShopPageBase if (Plugin.getPetManager().hasActivePet(Player.getName())) { - AddButton(26 + 9, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false), + Creature activePet = Plugin.getPetManager().getActivePet(Player.getName()); + String petName = activePet.getType() == EntityType.WITHER ? "Widder" : activePet.getCustomName(); + AddButton(26 + 9, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + petName, new String[] {}, 1, false, false), new IButton() { public void onClick(Player player, ClickType clickType) 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 5a0dad0d8..866550a8d 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 @@ -79,10 +79,16 @@ public class PetPage extends ShopPageBase //Owned if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName())) { + String petName = Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()); + if (petName == null) + { + petName = pet.GetName(); + } + if (Plugin.getPetManager().hasActivePet(Player.getName()) && Plugin.getPetManager().getActivePet(Player.getName()).getType() == pet.GetPetType()) { AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), - "Deactivate " + pet.GetPetName() + " (" + C.cWhite + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()) + C.cGreen + ")", + "Deactivate " + pet.GetPetName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivatePetButton(this, Plugin.getPetManager())); addGlow(slot); @@ -90,7 +96,7 @@ public class PetPage extends ShopPageBase else { AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), - "Activate " + pet.GetPetName() + " (" + C.cWhite + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()) + C.cGreen + ")", + "Activate " + pet.GetPetName() + " (" + C.cWhite + petName + C.cGreen + ")", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivatePetButton(pet, this)); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index c95ec8712..bb9d4c7f7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -13,6 +13,7 @@ import mineplex.core.updater.UpdateType; import mineplex.core.account.CoreClientManager; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.common.Rank; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilServer; @@ -44,6 +45,7 @@ import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -66,6 +68,8 @@ public class PetManager extends MiniClientPlugin private NautHashMap _petOwnerQueue = new NautHashMap(); private NautHashMap _petRenameQueue = new NautHashMap(); + private DonationManager _donationManager; + private CoreClientManager _clientManager; public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, String webAddress) { @@ -76,6 +80,8 @@ public class PetManager extends MiniClientPlugin _repository = new PetRepository(webAddress); _petFactory = new PetFactory(_repository); _blockRestore = restore; + _donationManager = donationManager; + _clientManager = clientManager; _activePetOwners = new NautHashMap(); _failedAttempts = new NautHashMap(); @@ -135,6 +141,17 @@ public class PetManager extends MiniClientPlugin } } + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + Player p = event.getPlayer(); + Rank rank = _clientManager.Get(p).GetRank(); + if (rank == Rank.LEGEND || rank == Rank.ADMIN || rank == Rank.DEVELOPER || rank == Rank.OWNER) + { + _donationManager.Get(p.getName()).AddUnknownSalesPackagesOwned("Widder"); + } + } + public void AddPetOwner(Player player, EntityType entityType, Location location) { if (_activePetOwners.containsKey(player.getName()))