From 0b0fa383f6248e312827addcfc040d16ddd058f6 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 26 Oct 2013 10:45:41 -0500 Subject: [PATCH] Finished up Gadget shop. --- .../src/mineplex/core/pet/PetManager.java | 8 - .../core/shop/item/SalesPackageBase.java | 9 +- .../src/mineplex/hub/HubManager.java | 3 +- .../mineplex/hub/gadget/GadgetManager.java | 32 ++- .../gadget/gadgets/Halloween2013_BatGun.java | 7 +- .../gadget/gadgets/Halloween2013_Helmet.java | 3 +- .../hub/gadget/gadgets/PaintballGun.java | 5 +- .../hub/gadget/types/ArmorGadget.java | 36 +-- .../src/mineplex/hub/gadget/types/Gadget.java | 39 +-- .../mineplex/hub/gadget/types/ItemGadget.java | 14 +- .../hub/gadget/ui/ActivateGadgetButton.java | 24 ++ .../hub/gadget/ui/ActivateMountButton.java | 24 ++ .../mineplex/hub/gadget/ui/CloseButton.java | 14 - .../hub/gadget/ui/DeactivateGadgetButton.java | 24 ++ .../hub/gadget/ui/DeactivateMountButton.java | 24 ++ .../hub/gadget/ui/DeactivatePetButton.java | 24 -- .../mineplex/hub/gadget/ui/GadgetButton.java | 24 ++ .../mineplex/hub/gadget/ui/GadgetPage.java | 248 +++++++++++------- ...ctivatePetButton.java => MountButton.java} | 12 +- .../src/mineplex/hub/gadget/ui/PetButton.java | 24 -- .../src/mineplex/hub/gadget/ui/PetSorter.java | 16 -- .../mineplex/hub/gadget/ui/PetTagPage.java | 107 -------- .../hub/gadget/ui/RenamePetButton.java | 21 -- .../hub/gadget/ui/SelectTagButton.java | 21 -- .../src/mineplex/hub/mount/Mount.java | 44 ++-- .../src/mineplex/hub/mount/MountManager.java | 5 + .../src/mineplex/hub/mount/types/Mule.java | 6 +- .../src/mineplex/hub/mount/types/Undead.java | 11 +- 28 files changed, 406 insertions(+), 423 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java rename Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/{ActivatePetButton.java => MountButton.java} (51%) delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java delete mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 4a990bac0..33d178d01 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -177,14 +177,6 @@ public class PetManager extends MiniClientPlugin } } - /* not necessary for hub - @EventHandler(priority = EventPriority.HIGHEST) - public void onPlayerInventoryClick(InventoryClickEvent event) - { - UtilInv.DisallowMovementOf(event, "Pet Menu", Material.BONE, (byte)0, true, true); - } - */ - @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java index 6054e3b5e..50edf2afe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/shop/item/SalesPackageBase.java @@ -28,7 +28,12 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack this(name, material, (byte)0, description); } - public SalesPackageBase(String name, Material material, byte displayData, String...description) + public SalesPackageBase(String name, Material material, byte displayData, String[] description) + { + this(name, material, (byte)0, description, -1); + } + + public SalesPackageBase(String name, Material material, byte displayData, String[] description, int gems) { CurrencyCostMap = new NautHashMap(); @@ -37,6 +42,8 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack _description = description; _displayMaterial = material; _displayData = displayData; + + CurrencyCostMap.put(CurrencyType.Gems, gems); } public abstract void Sold(Player player, CurrencyType currencyType); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index c85738ffd..5b2db80c7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -107,8 +107,7 @@ public class HubManager extends MiniClientPlugin new JumpManager(this); new NewsManager(this); - new GadgetManager(this); - new MountManager(this); + new GadgetManager(this, new MountManager(this), clientManager, donationManager); _partyManager = partyManager; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java index 375380fb0..6ff2d67dd 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/GadgetManager.java @@ -2,9 +2,18 @@ package mineplex.hub.gadget; import java.util.HashSet; +import org.bukkit.ChatColor; +import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; import mineplex.hub.HubManager; import mineplex.hub.gadget.gadgets.Halloween2013_BatGun; import mineplex.hub.gadget.gadgets.Halloween2013_Helmet; @@ -13,20 +22,25 @@ import mineplex.hub.gadget.types.ArmorGadget; import mineplex.hub.gadget.types.ArmorGadget.ArmorSlot; import mineplex.hub.gadget.types.Gadget; import mineplex.hub.gadget.types.ItemGadget; +import mineplex.hub.gadget.ui.GadgetShop; +import mineplex.hub.mount.MountManager; public class GadgetManager extends MiniPlugin { public HubManager Manager; + private GadgetShop _gadgetShop; private HashSet _gadgets; - public GadgetManager(HubManager manager) + public GadgetManager(HubManager manager, MountManager mountManager, CoreClientManager clientManager, DonationManager donationManager) { super("Gadget Manager", manager.GetPlugin()); Manager = manager; CreateGadgets(); + + _gadgetShop = new GadgetShop(this, mountManager, clientManager, donationManager); } private void CreateGadgets() @@ -41,6 +55,22 @@ public class GadgetManager extends MiniPlugin _gadgets.add(new Halloween2013_Helmet(this)); } + @EventHandler + public void onPlayerJoin(PlayerJoinEvent event) + { + event.getPlayer().getInventory().setItem(5, ItemStackFactory.Instance.CreateStack(Material.CHEST, (byte)0, 1, ChatColor.RESET + C.cGreen + "Gadget Menu")); + } + + @EventHandler + public void openShop(PlayerInteractEvent event) + { + if (event.hasItem() && event.getItem().getType() == Material.CHEST) + { + _gadgetShop.attemptShopOpen(event.getPlayer()); + event.setCancelled(true); + } + } + public HashSet getGadgets() { return _gadgets; diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java index f1a86d325..5fffd95ec 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_BatGun.java @@ -39,11 +39,12 @@ public class Halloween2013_BatGun extends ItemGadget public Halloween2013_BatGun(GadgetManager manager) { - super(manager, "Gadget_Halloween2013_BatGun", "Bat Blaster", 10000, new String[] + super(manager, "Bat Blaster", new String[] { - C.cWhite + "Launch waves of annoying bats", - C.cWhite + "at people you don't like!", + C.cWhite + "Launch waves of annoying bats", + C.cWhite + "at people you don't like!", }, + 7500, Material.IRON_BARDING, (byte)0); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java index b565f9fd0..8cfbd7a1a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/Halloween2013_Helmet.java @@ -14,7 +14,7 @@ public class Halloween2013_Helmet extends ArmorGadget { public Halloween2013_Helmet(GadgetManager manager) { - super(manager, "Gadget_Halloween2013_Helmet", "Pumpkin Kings Head", new String[] + super(manager, "Pumpkin Kings Head", new String[] { C.cWhite + "Transforms the wearer into", C.cWhite + "the dreaded Pumpkin King!", @@ -22,6 +22,7 @@ public class Halloween2013_Helmet extends ArmorGadget C.cYellow + "Earned by defeating the Pumpkin King", C.cYellow + "in the 2013 Halloween Horror Event.", }, + -1, ArmorSlot.Helmet, Material.PUMPKIN, (byte)0); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/PaintballGun.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/PaintballGun.java index 34aa6dd5e..2b8696758 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/PaintballGun.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/gadgets/PaintballGun.java @@ -29,10 +29,11 @@ public class PaintballGun extends ItemGadget public PaintballGun(GadgetManager manager) { - super(manager, "Gadget_PaintballGun", "Paintball Gun", new String[] + super(manager, "Paintball Gun", new String[] { C.cWhite + "PEW PEW PEW PEW!", - }, + }, + 5000, Material.GOLD_BARDING, (byte)0); } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java index 706117fae..e921be88f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ArmorGadget.java @@ -19,19 +19,13 @@ public abstract class ArmorGadget extends Gadget } private ArmorSlot _slot; - private Material _material; - private byte _data; - public ArmorGadget(GadgetManager manager, String code, String name, String[] desc, ArmorSlot slot, Material mat, byte data) + public ArmorGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data) { - super(manager, code, name, desc); + super(manager, name, desc, cost, mat, data); _slot = slot; - _material = mat; - _data = data; - } - - + } public ArmorSlot GetSlot() { @@ -42,10 +36,14 @@ public abstract class ArmorGadget extends Gadget { Manager.RemoveArmor(player, _slot); - if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName()))); - else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName()))); - else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName()))); - else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName()))); + if (_slot == ArmorSlot.Helmet) + player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); + else if (_slot == ArmorSlot.Chest) + player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); + else if (_slot == ArmorSlot.Legs) + player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); + else if (_slot == ArmorSlot.Boots) + player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); _active.add(player); @@ -54,10 +52,14 @@ public abstract class ArmorGadget extends Gadget public void RemoveArmor(Player player) { - if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null); - else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null); - else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null); - else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null); + if (_slot == ArmorSlot.Helmet) + player.getInventory().setHelmet(null); + else if (_slot == ArmorSlot.Chest) + player.getInventory().setChestplate(null); + else if (_slot == ArmorSlot.Legs) + player.getInventory().setLeggings(null); + else if (_slot == ArmorSlot.Boots) + player.getInventory().setBoots(null); _active.remove(player); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java index a32b271a3..238764fa6 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/Gadget.java @@ -2,51 +2,34 @@ package mineplex.hub.gadget.types; import java.util.HashSet; +import mineplex.core.common.CurrencyType; +import mineplex.core.shop.item.SalesPackageBase; import mineplex.hub.gadget.GadgetManager; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -public abstract class Gadget implements Listener +public abstract class Gadget extends SalesPackageBase implements Listener { public GadgetManager Manager; private HashSet _owners = new HashSet(); protected HashSet _active = new HashSet(); - private String _code; - private String _name; - private String[] _desc; - - public Gadget(GadgetManager manager, String code, String name, String[] desc) + public Gadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data) { + super(name, mat, data, desc, cost); + KnownPackage = false; + Manager = manager; - _code = code; - _name = name; - _desc = desc; - Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); } - public String GetName() - { - return _name; - } - - public String[] GetDesc() - { - return _desc; - } - - public String GetCode() - { - return _code; - } - public HashSet GetOwners() { return _owners; @@ -85,4 +68,10 @@ public abstract class Gadget implements Listener public abstract void Enable(Player player); public abstract void Disable(Player player); + + @Override + public void Sold(Player player, CurrencyType currencyType) + { + + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java index 6180a1a45..c8bd263ad 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/types/ItemGadget.java @@ -13,15 +13,9 @@ import mineplex.hub.gadget.GadgetManager; public abstract class ItemGadget extends Gadget { - private Material _material; - private byte _data; - - public ItemGadget(GadgetManager manager, String code, String name, String[] desc, Material mat, byte data) + public ItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data) { - super(manager, code, name, desc); - - _material = mat; - _data = data; + super(manager, name, desc, cost, mat, data); } public HashSet GetActive() @@ -38,7 +32,7 @@ public abstract class ItemGadget extends Gadget { Manager.RemoveItem(player); - player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName()))); + player.getInventory().setItem(2, ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 1, F.item(GetName()))); _active.add(player); @@ -56,6 +50,6 @@ public abstract class ItemGadget extends Gadget public boolean IsItem(Player player) { - return UtilInv.IsItem(player.getItemInHand(), _material, _data); + return UtilInv.IsItem(player.getItemInHand(), GetDisplayMaterial(), GetDisplayData()); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java new file mode 100644 index 000000000..7d4b346c7 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateGadgetButton.java @@ -0,0 +1,24 @@ +package mineplex.hub.gadget.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.gadget.types.Gadget; + +public class ActivateGadgetButton implements IButton +{ + private Gadget _gadget; + private GadgetPage _page; + + public ActivateGadgetButton(Gadget gadget, GadgetPage page) + { + _gadget = gadget; + _page = page; + } + + @Override + public void Clicked(Player player) + { + _page.ActivateGadget(player, _gadget); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java new file mode 100644 index 000000000..6aac6db6e --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivateMountButton.java @@ -0,0 +1,24 @@ +package mineplex.hub.gadget.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.mount.Mount; + +public class ActivateMountButton implements IButton +{ + private Mount _mount; + private GadgetPage _page; + + public ActivateMountButton(Mount mount, GadgetPage page) + { + _mount = mount; + _page = page; + } + + @Override + public void Clicked(Player player) + { + _page.ActivateMount(player, _mount); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java deleted file mode 100644 index 1f0692b63..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/CloseButton.java +++ /dev/null @@ -1,14 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; - -public class CloseButton implements IButton -{ - @Override - public void Clicked(Player player) - { - player.closeInventory(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java new file mode 100644 index 000000000..7d1040300 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateGadgetButton.java @@ -0,0 +1,24 @@ +package mineplex.hub.gadget.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.gadget.types.Gadget; + +public class DeactivateGadgetButton implements IButton +{ + private Gadget _gadget; + private GadgetPage _page; + + public DeactivateGadgetButton(Gadget gadget, GadgetPage page) + { + _gadget = gadget; + _page = page; + } + + @Override + public void Clicked(Player player) + { + _page.DeactivateGadget(player, _gadget); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java new file mode 100644 index 000000000..f9eeb8ecf --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivateMountButton.java @@ -0,0 +1,24 @@ +package mineplex.hub.gadget.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.mount.Mount; + +public class DeactivateMountButton implements IButton +{ + private Mount _mount; + private GadgetPage _page; + + public DeactivateMountButton(Mount mount, GadgetPage page) + { + _mount = mount; + _page = page; + } + + @Override + public void Clicked(Player player) + { + _page.DeactivateMount(player, _mount); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java deleted file mode 100644 index eea196bec..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/DeactivatePetButton.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.hub.gadget.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 GadgetPage _page; - - public DeactivatePetButton(Pet pet, GadgetPage page) - { - _pet = pet; - _page = page; - } - - @Override - public void Clicked(Player player) - { - _page.DeactivatePet(player); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java new file mode 100644 index 000000000..9b74317b0 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetButton.java @@ -0,0 +1,24 @@ +package mineplex.hub.gadget.ui; + +import org.bukkit.entity.Player; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.gadget.types.Gadget; + +public class GadgetButton implements IButton +{ + private Gadget _gadget; + private GadgetPage _page; + + public GadgetButton(Gadget gadget, GadgetPage page) + { + _gadget = gadget; + _page = page; + } + + @Override + public void Clicked(Player player) + { + _page.PurchaseGadget(player, _gadget); + } +} 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 1ff7c96ed..c4611ebab 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/GadgetPage.java @@ -1,32 +1,26 @@ package mineplex.hub.gadget.ui; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.List; -import net.minecraft.server.v1_6_R3.EntityPlayer; -import net.minecraft.server.v1_6_R3.Item; -import net.minecraft.server.v1_6_R3.Packet100OpenWindow; -import net.minecraft.server.v1_6_R3.Packet103SetSlot; - +import org.bukkit.Color; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_6_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.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.ConfirmationPage; import mineplex.core.shop.page.ShopPageBase; import mineplex.hub.gadget.GadgetManager; +import mineplex.hub.gadget.types.ArmorGadget; import mineplex.hub.gadget.types.Gadget; +import mineplex.hub.gadget.types.ItemGadget; +import mineplex.hub.mount.Mount; import mineplex.hub.mount.MountManager; public class GadgetPage extends ShopPageBase @@ -35,7 +29,7 @@ public class GadgetPage extends ShopPageBase public GadgetPage(GadgetManager plugin, GadgetShop shop, MountManager mountPlugin, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { - super(plugin, shop, clientManager, donationManager, name, player, 45); + super(plugin, shop, clientManager, donationManager, name, player, 54); _mountPlugin = mountPlugin; @@ -44,122 +38,198 @@ public class GadgetPage extends ShopPageBase protected void BuildPage() { - int slot = 1; - + int activeSlot = 2; + int headSlot = 11; + int chestSlot = 20; + int legSlot = 29; + int bootSlot = 38; + int mountSlot = 47; + + 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, true, 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, true, false)); + for (Gadget gadget : Plugin.getGadgets()) { - List itemLore = new ArrayList(); + int slot = 0; - itemLore.add(C.cYellow + gadget.getCost() + " Gems"); - itemLore.add(C.cBlack); - - if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName())) + if (gadget instanceof ArmorGadget) { - if (Plugin.hasActivePet(Player.getName()) && Plugin.getActivePet(Player.getName()).getType() == pet.GetPetType()) + switch (((ArmorGadget)gadget).GetSlot()) { - 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)); + 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; } } - else + else if (gadget instanceof ItemGadget) { - 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 = activeSlot; + activeSlot++; + } - slot++; + addGadget(gadget, slot); } - slot = 22; - for (PetExtra petExtra : Plugin.GetFactory().GetPetExtras()) + for (Mount mount : _mountPlugin.getMounts()) { - 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++; + int slot = mountSlot; + mountSlot++; + + addMount(mount, slot); } } - protected void addGadget(Gadget gadget) + protected void addGadget(Gadget gadget, int slot) { List itemLore = new ArrayList(); - itemLore.add(C.cYellow + gadget.getCost() + " Gems"); - itemLore.add(C.cBlack); - - if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetCode())) + if (gadget.GetCost(CurrencyType.Gems) == -1) { - if (Plugin.hasActivePet(Player.getName()) && Plugin.getActivePet(Player.getName()).getType() == pet.GetPetType()) + itemLore.add(C.cYellow + "You can only earn this!"); + } + else + { + itemLore.add(C.cYellow + gadget.GetCost(CurrencyType.Gems) + " Gems"); + } + + itemLore.add(C.cBlack); + itemLore.addAll(Arrays.asList(gadget.GetDescription())); + + if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName())) + { + if (gadget.GetOwners().contains(Player)) { - 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)); + AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Deactivate " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateGadgetButton(gadget, 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)); + AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Activate " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateGadgetButton(gadget, 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)); + if (gadget.GetCost(CurrencyType.Gems) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= gadget.GetCost(CurrencyType.Gems)) + AddButton(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new GadgetButton(gadget, 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)); + setItem(slot, new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), "Purchase " + gadget.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); + } + } + + protected void addMount(Mount mount, int slot) + { + List itemLore = new ArrayList(); + + if (mount.GetCost(CurrencyType.Gems) != -1) + { + itemLore.add(C.cYellow + mount.GetCost(CurrencyType.Gems) + " Gems"); + } + + itemLore.add(C.cBlack); + itemLore.addAll(Arrays.asList(mount.GetDescription())); + + if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(mount.GetName())) + { + if (mount.GetOwners().contains(Player)) + { + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Deactivate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateMountButton(mount, this)); + } + else + { + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Activate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateMountButton(mount, this)); + } + } + else + { + if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= mount.GetCost(CurrencyType.Gems)) + AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new MountButton(mount, this)); + else + setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } } - public void PurchasePet(final Player player, final Pet pet) + public void PurchaseGadget(final Player player, final Gadget gadget) { - renamePet(player, pet, true); + Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() + { + public void run() + { + Player.closeInventory(); + } + }, null, gadget, CurrencyType.Gems, Player)); } - public void renameCurrentPet(Player player) + public void ActivateGadget(Player player, Gadget gadget) { 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 Packet100OpenWindow(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 Packet103SetSlot(containerCounter, 0, new net.minecraft.server.v1_6_R3.ItemStack(Item.NAME_TAG))); - - Shop.SetCurrentPageForPlayer(Player, petTagPage); - } - - public void ActivatePet(Player player, Pet pet) - { - PlayAcceptSound(player); - Plugin.AddPetOwner(player, pet.GetPetType(), player.getLocation()); + gadget.Enable(player); Player.closeInventory(); } - public void DeactivatePet(Player player) + public void DeactivateGadget(Player player, Gadget gadget) { PlayAcceptSound(player); - Plugin.RemovePet(player, true); + gadget.Disable(player); + Player.closeInventory(); + } + + public void PurchaseMount(final Player player, final Mount mount) + { + Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() + { + public void run() + { + Player.closeInventory(); + } + }, null, mount, CurrencyType.Gems, Player)); + } + + public void ActivateMount(Player player, Mount mount) + { + PlayAcceptSound(player); + mount.Enable(player); + Player.closeInventory(); + } + + public void DeactivateMount(Player player, Mount mount) + { + PlayAcceptSound(player); + mount.Disable(player); Player.closeInventory(); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java similarity index 51% rename from Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java rename to Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java index dcc0228e4..1f29b7387 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/ActivatePetButton.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/MountButton.java @@ -2,23 +2,23 @@ package mineplex.hub.gadget.ui; import org.bukkit.entity.Player; -import mineplex.core.pet.Pet; import mineplex.core.shop.item.IButton; +import mineplex.hub.mount.Mount; -public class ActivatePetButton implements IButton +public class MountButton implements IButton { - private Pet _pet; + private Mount _mount; private GadgetPage _page; - public ActivatePetButton(Pet pet, GadgetPage page) + public MountButton(Mount mount, GadgetPage page) { - _pet = pet; + _mount = mount; _page = page; } @Override public void Clicked(Player player) { - _page.ActivatePet(player, _pet); + _page.PurchaseMount(player, _mount); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java deleted file mode 100644 index 0615b1dc4..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetButton.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.hub.gadget.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 GadgetPage _page; - - public PetButton(Pet pet, GadgetPage page) - { - _pet = pet; - _page = page; - } - - @Override - public void Clicked(Player player) - { - _page.PurchasePet(player, _pet); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java deleted file mode 100644 index 4e8b2d9f6..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetSorter.java +++ /dev/null @@ -1,16 +0,0 @@ -package mineplex.hub.gadget.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.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java deleted file mode 100644 index d0bc059e4..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/PetTagPage.java +++ /dev/null @@ -1,107 +0,0 @@ -package mineplex.hub.gadget.ui; - -import mineplex.core.account.CoreClientManager; -import mineplex.core.common.CurrencyType; -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.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_6_R3.Item; -import net.minecraft.server.v1_6_R3.ItemStack; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -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) - { - super(plugin, shop, clientManager, donationManager, name, player, 3); - - _pet = pet; - _petPurchase = petPurchase; - - BuildPage(); - - Player.setLevel(5); - } - - @Override - protected void BuildPage() - { - inventory.setItem(0, new ItemStack(Item.NAME_TAG)); - - ButtonMap.put(0, new CloseButton()); - ButtonMap.put(1, new CloseButton()); - ButtonMap.put(2, new SelectTagButton(this)); - } - - @Override - public void PlayerClosed() - { - super.PlayerClosed(); - - Player.setLevel(0); - } - - public void SelectTag() - { - if (ChatColor.stripColor(_tagName).length() > 16) - { - UtilPlayer.message(Player, F.main(Plugin.GetName(), ChatColor.RED + "Pet name cannot be longer than 16 characters.")); - PlayDenySound(Player); - - return; - } - - PetExtra tag = new PetExtra("Rename " + _pet.GetName() + " to " + _tagName, Material.NAME_TAG, 1000); - - _pet.setDisplayName(C.cGreen + "Purchase " + _tagName); - - Shop.OpenPageForPlayer(Player, new ConfirmationPage(Plugin, Shop, ClientManager, DonationManager, new Runnable() - { - public void run() - { - PetChangeToken token = new PetChangeToken(); - token.Name = Player.getName(); - token.PetType = _pet.GetPetType().toString(); - token.PetName = _tagName; - - PetToken petToken = new PetToken(); - petToken.PetType = token.PetType; - - if (_petPurchase) - { - Plugin.GetRepository().AddPet(token); - Plugin.addPetOwnerToQueue(Player.getName(), _pet.GetPetType()); - } - else - { - Plugin.GetRepository().UpdatePet(token); - } - - Plugin.Get(Player).GetPets().put(_pet.GetPetType(), token.PetName); - - Player.closeInventory(); - } - }, null, _petPurchase ? _pet : tag, CurrencyType.Gems, Player)); - } - - public void SetTagName(String tagName) - { - _tagName = tagName; - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java deleted file mode 100644 index 1d5c2dbe3..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/RenamePetButton.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.hub.gadget.ui; - -import org.bukkit.entity.Player; - -import mineplex.core.shop.item.IButton; - -public class RenamePetButton implements IButton -{ - private GadgetPage _page; - - public RenamePetButton(GadgetPage page) - { - _page = page; - } - - @Override - public void Clicked(Player player) - { - _page.renameCurrentPet(player); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java deleted file mode 100644 index 9eaa88db7..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/gadget/ui/SelectTagButton.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.hub.gadget.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 Clicked(Player player) - { - _page.SelectTag(); - } -} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java index d1b3d2b1f..bf6c8f5b4 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/Mount.java @@ -5,10 +5,12 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import mineplex.core.common.CurrencyType; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_6_R3.EntityCreature; @@ -28,31 +30,26 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.ItemStack; -public class Mount implements Listener +public class Mount extends SalesPackageBase implements Listener { private HashSet _owners = new HashSet(); private HashMap _active = new HashMap(); public MountManager Manager; - private String _code; - - private String _name; - private String[] _desc; - private Color _color; private Style _style; private Variant _variant; private double _jump; private Material _armor; - public Mount(MountManager manager, String code, String name, String[] desc, Color color, Style style, Variant variant, double jump, Material armor) + public Mount(MountManager manager, String name, String[] desc, Material displayMaterial, byte displayData, int cost, Color color, Style style, Variant variant, double jump, Material armor) { + super (name, displayMaterial, displayData, desc, cost); + KnownPackage = false; + Manager = manager; - _code = code; - _name = name; - _desc = desc; _color = color; _style = style; _variant = variant; @@ -62,21 +59,6 @@ public class Mount implements Listener Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin()); } - public String GetName() - { - return _name; - } - - public String[] GetDesc() - { - return _desc; - } - - public String GetCode() - { - return _code; - } - public HashSet GetOwners() { return _owners; @@ -185,11 +167,11 @@ public class Mount implements Listener if (_armor != null) horse.getInventory().setArmor(new ItemStack(_armor)); - horse.setCustomName(player.getName() + "'s " + _name); + horse.setCustomName(player.getName() + "'s " + GetName()); horse.setCustomNameVisible(true); //Inform - UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(_name) + ".")); + UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store _active.put(player, horse); @@ -203,7 +185,13 @@ public class Mount implements Listener horse.remove(); //Inform - UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(_name) + ".")); + UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); } } + + @Override + public void Sold(Player player, CurrencyType currencyType) + { + + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java index 9d0e93eba..9e3a96c6a 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/MountManager.java @@ -38,6 +38,11 @@ public class MountManager extends MiniPlugin _types.add(new Mule(this)); } + public HashSet getMounts() + { + return _types; + } + //Disallows two mounts active public void DeregisterAll(Player player) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java index baae64a44..4d1b66f89 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Mule.java @@ -1,5 +1,6 @@ package mineplex.hub.mount.types; +import org.bukkit.Material; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; @@ -11,10 +12,13 @@ public class Mule extends Mount { public Mule(MountManager manager) { - super(manager, "Mount_Mule", "Horse of Horror", new String[] + super(manager, "Horse of Horror", new String[] { "Muley muley!" }, + Material.HAY_BLOCK, + (byte)0, + 15000, Color.BLACK, Style.BLACK_DOTS, Variant.MULE, 1.0, null); } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java index 9783e2703..aa129c1d5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/mount/types/Undead.java @@ -1,5 +1,6 @@ package mineplex.hub.mount.types; +import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; @@ -21,12 +22,18 @@ public class Undead extends Mount { public Undead(MountManager manager) { - super(manager, "Mount_Halloween2013", "Infernal Horror", new String[] + super(manager, "Infernal Horror", new String[] { C.cWhite + "The most ghastly horse in", C.cWhite + "existance, from the pits of", - C.cWhite + "the Nether." + C.cWhite + "the Nether.", + "", + C.cYellow + "Only available on website.", + C.cYellow + "www.mineplex.com/Shop", }, + Material.BONE, + (byte)0, + -1, Color.BLACK, Style.BLACK_DOTS, Variant.SKELETON_HORSE, 0.8, null); }