diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetShop.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetShop.java deleted file mode 100644 index 975239f77..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetShop.java +++ /dev/null @@ -1,45 +0,0 @@ -package mineplex.core.pet; - -import org.bukkit.entity.Player; -import org.bukkit.plugin.messaging.PluginMessageListener; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.ui.PetPage; -import mineplex.core.pet.ui.PetTagPage; -import mineplex.core.shop.ShopBase; -import mineplex.core.shop.page.ShopPageBase; - -public class PetShop extends ShopBase implements PluginMessageListener -{ - public PetShop(PetManager plugin, CoreClientManager manager, DonationManager donationManager) - { - super(plugin, manager, donationManager, "Pet Shop", CurrencyType.Gems); - - plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this); - } - - @Override - protected ShopPageBase> BuildPagesFor(Player player) - { - return new PetPage(Plugin, this, ClientManager, DonationManager, " Pets", player); - } - - @Override - public void onPluginMessageReceived(String channel, Player player, byte[] message) - { - if (!channel.equalsIgnoreCase("MC|ItemName")) - return; - - if (PlayerPageMap.containsKey(player.getName()) && PlayerPageMap.get(player.getName()) instanceof PetTagPage) - { - if (message != null && message.length >= 1) - { - String tagName = new String(message); - - ((PetTagPage)PlayerPageMap.get(player.getName())).SetTagName(tagName); - } - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/CloseButton.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/CloseButton.java deleted file mode 100644 index ab1b20519..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/CloseButton.java +++ /dev/null @@ -1,20 +0,0 @@ -package mineplex.core.pet.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; - -public class CloseButton implements IButton -{ - @Override - public void ClickedLeft(Player player) - { - player.closeInventory(); - } - - @Override - public void ClickedRight(Player player) - { - player.closeInventory(); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/DeactivatePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/DeactivatePetButton.java deleted file mode 100644 index f4a1743cf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/DeactivatePetButton.java +++ /dev/null @@ -1,30 +0,0 @@ -package mineplex.core.pet.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.pet.Pet; -import mineplex.core.shop.item.IButton; - -public class DeactivatePetButton implements IButton -{ - private Pet _pet; - private PetPage _page; - - public DeactivatePetButton(Pet pet, PetPage page) - { - _pet = pet; - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.DeactivatePet(player); - } - - @Override - public void ClickedRight(Player player) - { - _page.DeactivatePet(player); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetButton.java deleted file mode 100644 index 99485243c..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetButton.java +++ /dev/null @@ -1,30 +0,0 @@ -package mineplex.core.pet.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.pet.Pet; -import mineplex.core.shop.item.IButton; - -public class PetButton implements IButton -{ - private Pet _pet; - private PetPage _page; - - public PetButton(Pet pet, PetPage page) - { - _pet = pet; - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.PurchasePet(player, _pet); - } - - @Override - public void ClickedRight(Player player) - { - _page.PurchasePet(player, _pet); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetPage.java deleted file mode 100644 index a3b61fe1d..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetPage.java +++ /dev/null @@ -1,137 +0,0 @@ -package mineplex.core.pet.ui; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.server.v1_7_R3.Block; -import net.minecraft.server.v1_7_R3.EntityPlayer; -import net.minecraft.server.v1_7_R3.Item; -import net.minecraft.server.v1_7_R3.Items; -import net.minecraft.server.v1_7_R3.PacketPlayOutOpenWindow; -import net.minecraft.server.v1_7_R3.PacketPlayOutSetSlot; - -import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Player; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -import mineplex.core.common.util.C; -import mineplex.core.donation.DonationManager; -import mineplex.core.pet.Pet; -import mineplex.core.pet.PetExtra; -import mineplex.core.pet.PetManager; -import mineplex.core.pet.PetShop; -import mineplex.core.shop.item.ShopItem; -import mineplex.core.shop.page.AnvilContainer; -import mineplex.core.shop.page.ShopPageBase; - -public class PetPage extends ShopPageBase -{ - public PetPage(PetManager plugin, PetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) - { - super(plugin, shop, clientManager, donationManager, name, player, 27); - - BuildPage(); - } - - protected void BuildPage() - { - int slot = 1; - - List pets = new ArrayList(Plugin.GetFactory().GetPets()); - - Collections.sort(pets, new PetSorter()); - - for (Pet pet : pets) - { - List itemLore = new ArrayList(); - - itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Gems"); - itemLore.add(C.cBlack); - - if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName())) - { - if (Plugin.hasActivePet(Player.getName()) && Plugin.getActivePet(Player.getName()).getType() == pet.GetPetType()) - { - AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Deactivate " + Plugin.Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new DeactivatePetButton(pet, this)); - } - else - { - AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Activate " + Plugin.Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new ActivatePetButton(pet, this)); - } - } - else - { - if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems)) - AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new PetButton(pet, this)); - else - setItem(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); - } - - slot++; - } - - slot = 22; - for (PetExtra petExtra : Plugin.GetFactory().GetPetExtras()) - { - List itemLore = new ArrayList(); - - if (!Plugin.hasActivePet(Player.getName())) - { - itemLore.add(C.cWhite + "You must have an active pet to use this!"); - getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); - } - else - { - AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Gems) + C.cGreen + " Gems", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); - } - - slot++; - } - } - - public void PurchasePet(final Player player, final Pet pet) - { - renamePet(player, pet, true); - } - - public void renameCurrentPet(Player player) - { - PlayAcceptSound(player); - Creature currentPet = Plugin.getActivePet(player.getName()); - renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false); - } - - public void renamePet(Player player, Pet pet, boolean petPurchase) - { - PlayAcceptSound(player); - - PetTagPage petTagPage = new PetTagPage(Plugin, Shop, ClientManager, DonationManager, "Repairing", Player, pet, petPurchase); - EntityPlayer entityPlayer = ((CraftPlayer)Player).getHandle(); - int containerCounter = entityPlayer.nextContainerCounter(); - entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 9, true)); - entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory()); - entityPlayer.activeContainer.windowId = containerCounter; - entityPlayer.activeContainer.addSlotListener(entityPlayer); - entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R3.ItemStack(Items.NAME_TAG))); - - Shop.SetCurrentPageForPlayer(Player, petTagPage); - } - - public void ActivatePet(Player player, Pet pet) - { - PlayAcceptSound(player); - Plugin.AddPetOwner(player, pet.GetPetType(), player.getLocation()); - Player.closeInventory(); - } - - public void DeactivatePet(Player player) - { - PlayAcceptSound(player); - Plugin.RemovePet(player, true); - Player.closeInventory(); - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetSorter.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetSorter.java deleted file mode 100644 index 491c5a93a..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetSorter.java +++ /dev/null @@ -1,16 +0,0 @@ -package mineplex.core.pet.ui; - -import java.util.Comparator; - -import mineplex.core.pet.Pet; - -public class PetSorter implements Comparator -{ - public int compare(Pet a, Pet b) - { - if (a.GetPetType().getTypeId() < b.GetPetType().getTypeId()) - return -1; - - return 1; - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/RenamePetButton.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/RenamePetButton.java deleted file mode 100644 index bee10c5c6..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/RenamePetButton.java +++ /dev/null @@ -1,27 +0,0 @@ -package mineplex.core.pet.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; - -public class RenamePetButton implements IButton -{ - private PetPage _page; - - public RenamePetButton(PetPage page) - { - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.renameCurrentPet(player); - } - - @Override - public void ClickedRight(Player player) - { - _page.renameCurrentPet(player); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/SelectTagButton.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/SelectTagButton.java deleted file mode 100644 index 21b2f4f66..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/SelectTagButton.java +++ /dev/null @@ -1,27 +0,0 @@ -package mineplex.core.pet.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; - -public class SelectTagButton implements IButton -{ - private PetTagPage _page; - - public SelectTagButton(PetTagPage page) - { - _page = page; - } - - @Override - public void ClickedLeft(Player player) - { - _page.SelectTag(); - } - - @Override - public void ClickedRight(Player player) - { - _page.SelectTag(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 645311de6..5e2befab4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -19,7 +19,6 @@ import mineplex.core.monitor.LagMeter; import mineplex.core.movement.Movement; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; -import mineplex.core.pet.PetManager; import mineplex.core.portal.Portal; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -33,6 +32,7 @@ import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; import mineplex.hub.modules.StackerManager; import mineplex.hub.party.PartyManager; +import mineplex.hub.pet.PetManager; import mineplex.hub.queue.QueueManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -85,12 +85,12 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation new MessageManager(this, clientManager, preferenceManager); Creature creature = new Creature(this); NpcManager npcManager = new NpcManager(this, creature); - new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress()); + PetManager petManager = new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress()); //Main Modules PacketHandler packetHandler = new PacketHandler(this); PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager); - HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager, preferenceManager); + HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager, preferenceManager, petManager); ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager)); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index a494ad939..1e054ac7f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -67,6 +67,7 @@ import mineplex.hub.modules.*; import mineplex.hub.mount.MountManager; import mineplex.hub.party.Party; import mineplex.hub.party.PartyManager; +import mineplex.hub.pet.PetManager; import mineplex.hub.tutorial.TutorialManager; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent; @@ -106,7 +107,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) + public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager) { super("Hub Manager", plugin); @@ -115,7 +116,7 @@ public class HubManager extends MiniClientPlugin _conditionManager = conditionManager; _donationManager = donationManager; _disguiseManager = disguiseManager; - + _portal = portal; _spawn = new Location(UtilWorld.getWorld("world"), 0.5, 74, 0.5); @@ -129,7 +130,7 @@ public class HubManager extends MiniClientPlugin new NewsManager(this); _mountManager = new MountManager(this); - _gadgetManager = new GadgetManager(this, _mountManager); + _gadgetManager = new GadgetManager(this, _mountManager, petManager); _partyManager = partyManager; _preferences = preferences; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java index b7c8bfe18..b4b9688c4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java @@ -25,7 +25,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; import mineplex.hub.HubManager; -import mineplex.hub.commands.GadgetToggle; import mineplex.hub.gadget.gadgets.*; import mineplex.hub.gadget.types.MorphGadget; import mineplex.hub.gadget.types.MorphGadget.ArmorSlot; @@ -33,22 +32,23 @@ import mineplex.hub.gadget.types.Gadget; import mineplex.hub.gadget.types.ItemGadget; import mineplex.hub.gadget.ui.GadgetShop; import mineplex.hub.mount.MountManager; +import mineplex.hub.pet.PetManager; import mineplex.minecraft.game.core.damage.CustomDamageEvent; public class GadgetManager extends MiniPlugin { public HubManager Manager; private GadgetShop _gadgetShop; + private PetManager _petManager; private HashSet _gadgets; - - - public GadgetManager(HubManager manager, MountManager mountManager) + public GadgetManager(HubManager manager, MountManager mountManager, PetManager petManager) { super("Gadget Manager", manager.GetPlugin()); Manager = manager; + _petManager = petManager; CreateGadgets(); @@ -207,4 +207,9 @@ public class GadgetManager extends MiniPlugin for (Player player : UtilServer.getPlayers()) gadget.Disable(player); } + + public PetManager getPetManager() + { + return _petManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/ActivatePetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java similarity index 72% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/ui/ActivatePetButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java index bc09d09ee..d96b6f529 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/ActivatePetButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java @@ -1,16 +1,16 @@ -package mineplex.core.pet.ui; +package mineplex.hub.gadget.ui; import org.bukkit.entity.Player; -import mineplex.core.pet.Pet; +import mineplex.hub.pet.Pet; import mineplex.core.shop.item.IButton; public class ActivatePetButton implements IButton { private Pet _pet; - private PetPage _page; + private GadgetPage _page; - public ActivatePetButton(Pet pet, PetPage page) + public ActivatePetButton(Pet pet, GadgetPage page) { _pet = pet; _page = page; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java index 7a655190c..82dd22bcc 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java @@ -2,27 +2,39 @@ package mineplex.hub.gadget.ui; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; -import org.bukkit.Color; +import net.minecraft.server.v1_7_R3.EntityPlayer; +import net.minecraft.server.v1_7_R3.Items; +import net.minecraft.server.v1_7_R3.PacketPlayOutOpenWindow; +import net.minecraft.server.v1_7_R3.PacketPlayOutSetSlot; + import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer; +import org.bukkit.entity.Creature; import org.bukkit.entity.Player; -import org.bukkit.inventory.meta.LeatherArmorMeta; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; import mineplex.core.common.util.C; import mineplex.core.donation.DonationManager; import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.AnvilContainer; import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.gadget.GadgetManager; import mineplex.hub.gadget.types.MorphGadget; import mineplex.hub.gadget.types.Gadget; import mineplex.hub.gadget.types.ItemGadget; -import mineplex.hub.mount.HorseMount; import mineplex.hub.mount.Mount; import mineplex.hub.mount.MountManager; +import mineplex.hub.pet.Pet; +import mineplex.hub.pet.PetExtra; +import mineplex.hub.gadget.ui.DeactivatePetButton; +import mineplex.hub.gadget.ui.PetButton; +import mineplex.hub.gadget.ui.PetSorter; +import mineplex.hub.gadget.ui.RenamePetButton; public class GadgetPage extends ShopPageBase { @@ -41,34 +53,11 @@ public class GadgetPage extends ShopPageBase { int activeSlot = 2; int headSlot = 11; - int chestSlot = 20; - int legSlot = 29; - int bootSlot = 38; - int mountSlot = 47; + int mountSlot = 20; - setItem(0, new ShopItem(Material.IRON_SWORD, (byte)0, "Active Gadget", new String[] {}, 1, false, false)); - - setItem(9, new ShopItem(Material.LEATHER_HELMET, (byte)0, "Hub Helmet", new String[] {}, 1, false, false)); - LeatherArmorMeta meta = (LeatherArmorMeta)getItem(9).getItemMeta(); - meta.setColor(Color.BLACK); - getItem(9).setItemMeta(meta); - - setItem(18, new ShopItem(Material.LEATHER_CHESTPLATE, (byte)0, "Hub Chestplate", new String[] {}, 1, false, false)); - meta = (LeatherArmorMeta)getItem(18).getItemMeta(); - meta.setColor(Color.BLACK); - getItem(18).setItemMeta(meta); - - setItem(27, new ShopItem(Material.LEATHER_LEGGINGS, (byte)0, "Hub Leggings", new String[] {}, 1, false, false)); - meta = (LeatherArmorMeta)getItem(27).getItemMeta(); - meta.setColor(Color.BLACK); - getItem(27).setItemMeta(meta); - - setItem(36, new ShopItem(Material.LEATHER_BOOTS, (byte)0, "Hub Boots", new String[] {}, 1, false, false)); - meta = (LeatherArmorMeta)getItem(36).getItemMeta(); - meta.setColor(Color.BLACK); - getItem(36).setItemMeta(meta); - - setItem(45, new ShopItem(Material.SADDLE, (byte)0, "Hub Mount", new String[] {}, 1, false, false)); + setItem(0, new ShopItem(Material.IRON_SWORD, (byte)0, "Gadgets", new String[] {}, 1, false, false)); + setItem(9, new ShopItem(Material.SKULL_ITEM, (byte)0, "Hub Morphs", new String[] {}, 1, false, false)); + setItem(18, new ShopItem(Material.DIAMOND_BARDING, (byte)0, "Hub Mounts", new String[] {}, 1, false, false)); for (Gadget gadget : Plugin.getGadgets()) { @@ -78,22 +67,10 @@ public class GadgetPage extends ShopPageBase { switch (((MorphGadget)gadget).GetSlot()) { - case Boots: - slot = bootSlot; - bootSlot++; - break; - case Chest: - slot = chestSlot; - chestSlot++; - break; case Helmet: slot = headSlot; headSlot++; break; - case Legs: - slot = legSlot; - legSlot++; - break; default: break; } @@ -114,6 +91,59 @@ public class GadgetPage extends ShopPageBase addMount(mount, slot); } + + int slot = 38; + + List pets = new ArrayList(Plugin.getPetManager().GetFactory().GetPets()); + + Collections.sort(pets, new PetSorter()); + + for (Pet pet : pets) + { + List itemLore = new ArrayList(); + + itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Gems"); + itemLore.add(C.cBlack); + + if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName())) + { + 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 " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new DeactivatePetButton(pet, this)); + } + else + { + AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Activate " + Plugin.getPetManager().Get(Player).GetPets().get(pet.GetPetType()), new String[] {}, 1, false, false), new ActivatePetButton(pet, this)); + } + } + else + { + if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems)) + AddButton(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new PetButton(pet, this)); + else + setItem(slot, new ShopItem(Material.MONSTER_EGG, (byte)pet.GetPetType().getTypeId(), "Purchase " + pet.GetPetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + } + + slot++; + } + + slot = 36; + for (PetExtra petExtra : Plugin.getPetManager().GetFactory().GetPetExtras()) + { + List itemLore = new ArrayList(); + + if (!Plugin.getPetManager().hasActivePet(Player.getName())) + { + itemLore.add(C.cWhite + "You must have an active pet to use this!"); + getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); + } + else + { + AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Gems) + C.cGreen + " Gems", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); + } + + slot++; + } } protected void addGadget(Gadget gadget, int slot) @@ -229,4 +259,46 @@ public class GadgetPage extends ShopPageBase _mount.Disable(player); Player.closeInventory(); } + + public void PurchasePet(final Player player, final Pet pet) + { + renamePet(player, pet, true); + } + + public void renameCurrentPet(Player player) + { + PlayAcceptSound(player); + Creature currentPet = Plugin.getPetManager().getActivePet(player.getName()); + renamePet(player, new Pet(currentPet.getCustomName(), currentPet.getType(), 1), false); + } + + public void renamePet(Player player, Pet pet, boolean petPurchase) + { + PlayAcceptSound(player); + + PetTagPage petTagPage = new PetTagPage(Plugin, Shop, ClientManager, DonationManager, "Repairing", Player, pet, petPurchase); + EntityPlayer entityPlayer = ((CraftPlayer)Player).getHandle(); + int containerCounter = entityPlayer.nextContainerCounter(); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(containerCounter, 8, "Repairing", 9, true)); + entityPlayer.activeContainer = new AnvilContainer(entityPlayer.inventory, petTagPage.getInventory()); + entityPlayer.activeContainer.windowId = containerCounter; + entityPlayer.activeContainer.addSlotListener(entityPlayer); + entityPlayer.playerConnection.sendPacket(new PacketPlayOutSetSlot(containerCounter, 0, new net.minecraft.server.v1_7_R3.ItemStack(Items.NAME_TAG))); + + Shop.SetCurrentPageForPlayer(Player, petTagPage); + } + + public void ActivatePet(Player player, Pet pet) + { + PlayAcceptSound(player); + Plugin.getPetManager().AddPetOwner(player, pet.GetPetType(), player.getLocation()); + Player.closeInventory(); + } + + public void DeactivatePet(Player player) + { + PlayAcceptSound(player); + Plugin.getPetManager().RemovePet(player, true); + Player.closeInventory(); + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java index f8db6ea11..356971e70 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetShop.java @@ -1,6 +1,7 @@ package mineplex.hub.gadget.ui; import org.bukkit.entity.Player; +import org.bukkit.plugin.messaging.PluginMessageListener; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; @@ -10,7 +11,7 @@ import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.gadget.GadgetManager; import mineplex.hub.mount.MountManager; -public class GadgetShop extends ShopBase +public class GadgetShop extends ShopBase implements PluginMessageListener { private MountManager _mountManager; @@ -19,6 +20,8 @@ public class GadgetShop extends ShopBase super(plugin, manager, donationManager, "Gadget Shop", CurrencyType.Gems); _mountManager = mountManager; + + plugin.GetPlugin().getServer().getMessenger().registerIncomingPluginChannel(plugin.GetPlugin(), "MC|ItemName", this); } @Override @@ -26,4 +29,21 @@ public class GadgetShop extends ShopBase { return new GadgetPage(Plugin, this, _mountManager, ClientManager, DonationManager, " Gadgets", player); } + + @Override + public void onPluginMessageReceived(String channel, Player player, byte[] message) + { + if (!channel.equalsIgnoreCase("MC|ItemName")) + return; + + if (PlayerPageMap.containsKey(player.getName()) && PlayerPageMap.get(player.getName()) instanceof PetTagPage) + { + if (message != null && message.length >= 1) + { + String tagName = new String(message); + + ((PetTagPage)PlayerPageMap.get(player.getName())).SetTagName(tagName); + } + } + } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetTagPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java similarity index 70% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetTagPage.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java index dbae332c8..34b645016 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/ui/PetTagPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java @@ -1,4 +1,4 @@ -package mineplex.core.pet.ui; +package mineplex.hub.gadget.ui; import mineplex.core.account.CoreClientManager; import mineplex.core.common.CurrencyType; @@ -6,15 +6,13 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.donation.DonationManager; -import mineplex.core.pet.Pet; -import mineplex.core.pet.PetExtra; -import mineplex.core.pet.PetManager; -import mineplex.core.pet.PetShop; +import mineplex.hub.gadget.GadgetManager; +import mineplex.hub.pet.Pet; +import mineplex.hub.pet.PetExtra; import mineplex.core.pet.repository.token.PetChangeToken; import mineplex.core.pet.repository.token.PetToken; import mineplex.core.shop.page.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; -import net.minecraft.server.v1_7_R3.Item; import net.minecraft.server.v1_7_R3.ItemStack; import net.minecraft.server.v1_7_R3.Items; @@ -22,13 +20,13 @@ import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; -public class PetTagPage extends ShopPageBase +public class PetTagPage extends ShopPageBase { private String _tagName = "Pet Tag"; private Pet _pet; private boolean _petPurchase; - public PetTagPage(PetManager plugin, PetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase) + public PetTagPage(GadgetManager plugin, GadgetShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, Pet pet, boolean petPurchase) { super(plugin, shop, clientManager, donationManager, name, player, 3); @@ -72,7 +70,7 @@ public class PetTagPage extends ShopPageBase _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); - Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() + Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() { public void run() { @@ -86,16 +84,16 @@ public class PetTagPage extends ShopPageBase if (_petPurchase) { - Plugin.GetRepository().AddPet(token); - Plugin.addPetOwnerToQueue(Player.getName(), _pet.GetPetType()); + Plugin.getPetManager().GetRepository().AddPet(token); + Plugin.getPetManager().addPetOwnerToQueue(Player.getName(), _pet.GetPetType()); } else { - Plugin.GetRepository().UpdatePet(token); - Plugin.addRenamePetToQueue(Player.getName(), token.PetName); + Plugin.getPetManager().GetRepository().UpdatePet(token); + Plugin.getPetManager().addRenamePetToQueue(Player.getName(), token.PetName); } - Plugin.Get(Player).GetPets().put(_pet.GetPetType(), token.PetName); + Plugin.getPetManager().Get(Player).GetPets().put(_pet.GetPetType(), token.PetName); Player.closeInventory(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/Pet.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/Pet.java index f29805f4b..68c085ec0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/Pet.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/Pet.java @@ -1,4 +1,4 @@ -package mineplex.core.pet; +package mineplex.hub.pet; import mineplex.core.common.CurrencyType; import mineplex.core.pet.repository.token.PetSalesToken; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetClient.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetClient.java index 5aa25843a..cd092c2ca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetClient.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetClient.java @@ -1,4 +1,4 @@ -package mineplex.core.pet; +package mineplex.hub.pet; import org.bukkit.entity.EntityType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetExtra.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetExtra.java index 416c54c1a..1d115a348 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetExtra.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetExtra.java @@ -1,4 +1,4 @@ -package mineplex.core.pet; +package mineplex.hub.pet; import mineplex.core.common.CurrencyType; import mineplex.core.itemstack.ItemStackFactory; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetFactory.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetFactory.java index 416629ba0..93691a9e6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetFactory.java @@ -1,13 +1,13 @@ -package mineplex.core.pet; +package mineplex.hub.pet; import java.util.ArrayList; import java.util.Collection; import java.util.List; import mineplex.core.common.util.NautHashMap; -import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.token.PetExtraToken; import mineplex.core.pet.repository.token.PetSalesToken; +import mineplex.hub.pet.repository.PetRepository; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetManager.java similarity index 89% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetManager.java index 7a739e36a..d4efdf7c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/PetManager.java @@ -1,11 +1,10 @@ -package mineplex.core.pet; +package mineplex.hub.pet; import java.lang.reflect.Field; import java.util.Iterator; import java.util.Map.Entry; import mineplex.core.MiniClientPlugin; -import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; @@ -17,6 +16,7 @@ import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilInv; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.pet.repository.PetRepository; import net.minecraft.server.v1_7_R3.EntityCreature; import net.minecraft.server.v1_7_R3.EntityHuman; import net.minecraft.server.v1_7_R3.EntityInsentient; @@ -29,6 +29,7 @@ import net.minecraft.server.v1_7_R3.PathfinderGoalSelector; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -66,8 +67,6 @@ public class PetManager extends MiniClientPlugin private NautHashMap _activePetOwners; private NautHashMap _failedAttempts; - private PetShop _petShop; - private Field _goalSelector; private Field _targetSelector; @@ -81,7 +80,6 @@ public class PetManager extends MiniClientPlugin _creatureModule = creatureModule; _repository = new PetRepository(webAddress); _petFactory = new PetFactory(_repository); - _petShop = new PetShop(this, clientManager, donationManager); _activePetOwners = new NautHashMap(); _failedAttempts = new NautHashMap(); @@ -187,17 +185,7 @@ public class PetManager extends MiniClientPlugin } } } - - @EventHandler - public void TryToAddPetOwner(PlayerInteractEvent event) - { - if (event.hasItem() && event.getItem().getType() == Material.BONE) - { - _petShop.attemptShopOpen(event.getPlayer()); - event.setCancelled(true); - } - } - + @EventHandler public void preventWolfBone(PlayerInteractEntityEvent event) { @@ -207,33 +195,7 @@ public class PetManager extends MiniClientPlugin event.getPlayer().updateInventory(); } } - - @EventHandler - public void orderThatBone(final PlayerDropItemEvent event) - { - if (event.getItemDrop().getItemStack().getType() == Material.BONE) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable() - { - public void run() - { - if (event.getPlayer().isOnline()) - { - event.getPlayer().getInventory().remove(Material.BONE); - event.getPlayer().getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 1, ChatColor.RESET + C.cGreen + "Pet Menu")); - event.getPlayer().updateInventory(); - } - } - }); - } - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent event) - { - event.getPlayer().getInventory().setItem(3, ItemStackFactory.Instance.CreateStack(Material.BONE, (byte)0, 1, ChatColor.RESET + C.cGreen + "Pet Menu")); - } - + @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/event/PetSpawnEvent.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/event/PetSpawnEvent.java index cbd0d2c32..bca89bf8e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/event/PetSpawnEvent.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/event/PetSpawnEvent.java @@ -1,4 +1,4 @@ -package mineplex.core.pet.event; +package mineplex.hub.pet.event; import org.bukkit.Location; import org.bukkit.entity.EntityType; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/PetRepository.java similarity index 97% rename from Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/PetRepository.java index 344f4f165..d27b90691 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/repository/PetRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/pet/repository/PetRepository.java @@ -1,4 +1,4 @@ -package mineplex.core.pet.repository; +package mineplex.hub.pet.repository; import java.util.List; diff --git a/Website/LOCWebsite.suo b/Website/LOCWebsite.suo index 267195680..ba1321b06 100644 Binary files a/Website/LOCWebsite.suo and b/Website/LOCWebsite.suo differ