Finished up Gadget shop.
This commit is contained in:
parent
9bc9cc2bb8
commit
0b0fa383f6
@ -177,14 +177,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,12 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
|||||||
this(name, material, (byte)0, description);
|
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<CurrencyType, Integer>();
|
CurrencyCostMap = new NautHashMap<CurrencyType, Integer>();
|
||||||
|
|
||||||
@ -37,6 +42,8 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
|
|||||||
_description = description;
|
_description = description;
|
||||||
_displayMaterial = material;
|
_displayMaterial = material;
|
||||||
_displayData = displayData;
|
_displayData = displayData;
|
||||||
|
|
||||||
|
CurrencyCostMap.put(CurrencyType.Gems, gems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void Sold(Player player, CurrencyType currencyType);
|
public abstract void Sold(Player player, CurrencyType currencyType);
|
||||||
|
@ -107,8 +107,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
|||||||
new JumpManager(this);
|
new JumpManager(this);
|
||||||
new NewsManager(this);
|
new NewsManager(this);
|
||||||
|
|
||||||
new GadgetManager(this);
|
new GadgetManager(this, new MountManager(this), clientManager, donationManager);
|
||||||
new MountManager(this);
|
|
||||||
|
|
||||||
_partyManager = partyManager;
|
_partyManager = partyManager;
|
||||||
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
|
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
|
||||||
|
@ -2,9 +2,18 @@ package mineplex.hub.gadget;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
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.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.HubManager;
|
||||||
import mineplex.hub.gadget.gadgets.Halloween2013_BatGun;
|
import mineplex.hub.gadget.gadgets.Halloween2013_BatGun;
|
||||||
import mineplex.hub.gadget.gadgets.Halloween2013_Helmet;
|
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.ArmorGadget.ArmorSlot;
|
||||||
import mineplex.hub.gadget.types.Gadget;
|
import mineplex.hub.gadget.types.Gadget;
|
||||||
import mineplex.hub.gadget.types.ItemGadget;
|
import mineplex.hub.gadget.types.ItemGadget;
|
||||||
|
import mineplex.hub.gadget.ui.GadgetShop;
|
||||||
|
import mineplex.hub.mount.MountManager;
|
||||||
|
|
||||||
public class GadgetManager extends MiniPlugin
|
public class GadgetManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
public HubManager Manager;
|
public HubManager Manager;
|
||||||
|
private GadgetShop _gadgetShop;
|
||||||
|
|
||||||
private HashSet<Gadget> _gadgets;
|
private HashSet<Gadget> _gadgets;
|
||||||
|
|
||||||
public GadgetManager(HubManager manager)
|
public GadgetManager(HubManager manager, MountManager mountManager, CoreClientManager clientManager, DonationManager donationManager)
|
||||||
{
|
{
|
||||||
super("Gadget Manager", manager.GetPlugin());
|
super("Gadget Manager", manager.GetPlugin());
|
||||||
|
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
|
|
||||||
CreateGadgets();
|
CreateGadgets();
|
||||||
|
|
||||||
|
_gadgetShop = new GadgetShop(this, mountManager, clientManager, donationManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateGadgets()
|
private void CreateGadgets()
|
||||||
@ -41,6 +55,22 @@ public class GadgetManager extends MiniPlugin
|
|||||||
_gadgets.add(new Halloween2013_Helmet(this));
|
_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<Gadget> getGadgets()
|
public HashSet<Gadget> getGadgets()
|
||||||
{
|
{
|
||||||
return _gadgets;
|
return _gadgets;
|
||||||
|
@ -39,11 +39,12 @@ public class Halloween2013_BatGun extends ItemGadget
|
|||||||
|
|
||||||
public Halloween2013_BatGun(GadgetManager manager)
|
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 + "Launch waves of annoying bats",
|
||||||
C.cWhite + "at people you don't like!",
|
C.cWhite + "at people you don't like!",
|
||||||
},
|
},
|
||||||
|
7500,
|
||||||
Material.IRON_BARDING, (byte)0);
|
Material.IRON_BARDING, (byte)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public class Halloween2013_Helmet extends ArmorGadget
|
|||||||
{
|
{
|
||||||
public Halloween2013_Helmet(GadgetManager manager)
|
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 + "Transforms the wearer into",
|
||||||
C.cWhite + "the dreaded Pumpkin King!",
|
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 + "Earned by defeating the Pumpkin King",
|
||||||
C.cYellow + "in the 2013 Halloween Horror Event.",
|
C.cYellow + "in the 2013 Halloween Horror Event.",
|
||||||
},
|
},
|
||||||
|
-1,
|
||||||
ArmorSlot.Helmet, Material.PUMPKIN, (byte)0);
|
ArmorSlot.Helmet, Material.PUMPKIN, (byte)0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,11 @@ public class PaintballGun extends ItemGadget
|
|||||||
|
|
||||||
public PaintballGun(GadgetManager manager)
|
public PaintballGun(GadgetManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Gadget_PaintballGun", "Paintball Gun", new String[]
|
super(manager, "Paintball Gun", new String[]
|
||||||
{
|
{
|
||||||
C.cWhite + "PEW PEW PEW PEW!",
|
C.cWhite + "PEW PEW PEW PEW!",
|
||||||
},
|
},
|
||||||
|
5000,
|
||||||
Material.GOLD_BARDING, (byte)0);
|
Material.GOLD_BARDING, (byte)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,20 +19,14 @@ public abstract class ArmorGadget extends Gadget
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ArmorSlot _slot;
|
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;
|
_slot = slot;
|
||||||
_material = mat;
|
|
||||||
_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ArmorSlot GetSlot()
|
public ArmorSlot GetSlot()
|
||||||
{
|
{
|
||||||
return _slot;
|
return _slot;
|
||||||
@ -42,10 +36,14 @@ public abstract class ArmorGadget extends Gadget
|
|||||||
{
|
{
|
||||||
Manager.RemoveArmor(player, _slot);
|
Manager.RemoveArmor(player, _slot);
|
||||||
|
|
||||||
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
if (_slot == ArmorSlot.Helmet)
|
||||||
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(GetDisplayMaterial(), GetDisplayData(), 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.Chest)
|
||||||
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(_material, _data, 1, F.item(GetName())));
|
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);
|
_active.add(player);
|
||||||
|
|
||||||
@ -54,10 +52,14 @@ public abstract class ArmorGadget extends Gadget
|
|||||||
|
|
||||||
public void RemoveArmor(Player player)
|
public void RemoveArmor(Player player)
|
||||||
{
|
{
|
||||||
if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet(null);
|
if (_slot == ArmorSlot.Helmet)
|
||||||
else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate(null);
|
player.getInventory().setHelmet(null);
|
||||||
else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings(null);
|
else if (_slot == ArmorSlot.Chest)
|
||||||
else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots(null);
|
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);
|
_active.remove(player);
|
||||||
|
|
||||||
|
@ -2,51 +2,34 @@ package mineplex.hub.gadget.types;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import mineplex.core.common.CurrencyType;
|
||||||
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public abstract class Gadget implements Listener
|
public abstract class Gadget extends SalesPackageBase implements Listener
|
||||||
{
|
{
|
||||||
public GadgetManager Manager;
|
public GadgetManager Manager;
|
||||||
|
|
||||||
private HashSet<Player> _owners = new HashSet<Player>();
|
private HashSet<Player> _owners = new HashSet<Player>();
|
||||||
protected HashSet<Player> _active = new HashSet<Player>();
|
protected HashSet<Player> _active = new HashSet<Player>();
|
||||||
|
|
||||||
private String _code;
|
public Gadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
||||||
private String _name;
|
|
||||||
private String[] _desc;
|
|
||||||
|
|
||||||
public Gadget(GadgetManager manager, String code, String name, String[] desc)
|
|
||||||
{
|
{
|
||||||
|
super(name, mat, data, desc, cost);
|
||||||
|
KnownPackage = false;
|
||||||
|
|
||||||
Manager = manager;
|
Manager = manager;
|
||||||
|
|
||||||
_code = code;
|
|
||||||
_name = name;
|
|
||||||
_desc = desc;
|
|
||||||
|
|
||||||
Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin());
|
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<Player> GetOwners()
|
public HashSet<Player> GetOwners()
|
||||||
{
|
{
|
||||||
return _owners;
|
return _owners;
|
||||||
@ -85,4 +68,10 @@ public abstract class Gadget implements Listener
|
|||||||
|
|
||||||
public abstract void Enable(Player player);
|
public abstract void Enable(Player player);
|
||||||
public abstract void Disable(Player player);
|
public abstract void Disable(Player player);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void Sold(Player player, CurrencyType currencyType)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,15 +13,9 @@ import mineplex.hub.gadget.GadgetManager;
|
|||||||
|
|
||||||
public abstract class ItemGadget extends Gadget
|
public abstract class ItemGadget extends Gadget
|
||||||
{
|
{
|
||||||
private Material _material;
|
public ItemGadget(GadgetManager manager, String name, String[] desc, int cost, Material mat, byte data)
|
||||||
private byte _data;
|
|
||||||
|
|
||||||
public ItemGadget(GadgetManager manager, String code, String name, String[] desc, Material mat, byte data)
|
|
||||||
{
|
{
|
||||||
super(manager, code, name, desc);
|
super(manager, name, desc, cost, mat, data);
|
||||||
|
|
||||||
_material = mat;
|
|
||||||
_data = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashSet<Player> GetActive()
|
public HashSet<Player> GetActive()
|
||||||
@ -38,7 +32,7 @@ public abstract class ItemGadget extends Gadget
|
|||||||
{
|
{
|
||||||
Manager.RemoveItem(player);
|
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);
|
_active.add(player);
|
||||||
|
|
||||||
@ -56,6 +50,6 @@ public abstract class ItemGadget extends Gadget
|
|||||||
|
|
||||||
public boolean IsItem(Player player)
|
public boolean IsItem(Player player)
|
||||||
{
|
{
|
||||||
return UtilInv.IsItem(player.getItemInHand(), _material, _data);
|
return UtilInv.IsItem(player.getItemInHand(), GetDisplayMaterial(), GetDisplayData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -1,32 +1,26 @@
|
|||||||
package mineplex.hub.gadget.ui;
|
package mineplex.hub.gadget.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.server.v1_6_R3.EntityPlayer;
|
import org.bukkit.Color;
|
||||||
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.Material;
|
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.entity.Player;
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.common.CurrencyType;
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.donation.DonationManager;
|
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.item.ShopItem;
|
||||||
import mineplex.core.shop.page.AnvilContainer;
|
import mineplex.core.shop.page.ConfirmationPage;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
import mineplex.hub.gadget.GadgetManager;
|
import mineplex.hub.gadget.GadgetManager;
|
||||||
|
import mineplex.hub.gadget.types.ArmorGadget;
|
||||||
import mineplex.hub.gadget.types.Gadget;
|
import mineplex.hub.gadget.types.Gadget;
|
||||||
|
import mineplex.hub.gadget.types.ItemGadget;
|
||||||
|
import mineplex.hub.mount.Mount;
|
||||||
import mineplex.hub.mount.MountManager;
|
import mineplex.hub.mount.MountManager;
|
||||||
|
|
||||||
public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
||||||
@ -35,7 +29,7 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
|||||||
|
|
||||||
public GadgetPage(GadgetManager plugin, GadgetShop shop, MountManager mountPlugin, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
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;
|
_mountPlugin = mountPlugin;
|
||||||
|
|
||||||
@ -44,122 +38,198 @@ public class GadgetPage extends ShopPageBase<GadgetManager, GadgetShop>
|
|||||||
|
|
||||||
protected void BuildPage()
|
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())
|
for (Gadget gadget : Plugin.getGadgets())
|
||||||
|
{
|
||||||
|
int slot = 0;
|
||||||
|
|
||||||
|
if (gadget instanceof ArmorGadget)
|
||||||
|
{
|
||||||
|
switch (((ArmorGadget)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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (gadget instanceof ItemGadget)
|
||||||
|
{
|
||||||
|
slot = activeSlot;
|
||||||
|
activeSlot++;
|
||||||
|
}
|
||||||
|
|
||||||
|
addGadget(gadget, slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Mount mount : _mountPlugin.getMounts())
|
||||||
|
{
|
||||||
|
int slot = mountSlot;
|
||||||
|
mountSlot++;
|
||||||
|
|
||||||
|
addMount(mount, slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addGadget(Gadget gadget, int slot)
|
||||||
{
|
{
|
||||||
List<String> itemLore = new ArrayList<String>();
|
List<String> itemLore = new ArrayList<String>();
|
||||||
|
|
||||||
itemLore.add(C.cYellow + gadget.getCost() + " Gems");
|
if (gadget.GetCost(CurrencyType.Gems) == -1)
|
||||||
|
{
|
||||||
|
itemLore.add(C.cYellow + "You can only earn this!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itemLore.add(C.cYellow + gadget.GetCost(CurrencyType.Gems) + " Gems");
|
||||||
|
}
|
||||||
|
|
||||||
itemLore.add(C.cBlack);
|
itemLore.add(C.cBlack);
|
||||||
|
itemLore.addAll(Arrays.asList(gadget.GetDescription()));
|
||||||
|
|
||||||
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName()))
|
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetName()))
|
||||||
{
|
{
|
||||||
if (Plugin.hasActivePet(Player.getName()) && Plugin.getActivePet(Player.getName()).getType() == pet.GetPetType())
|
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
|
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
|
else
|
||||||
{
|
{
|
||||||
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems))
|
if (gadget.GetCost(CurrencyType.Gems) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= gadget.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));
|
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
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
slot++;
|
protected void addMount(Mount mount, int slot)
|
||||||
}
|
|
||||||
|
|
||||||
slot = 22;
|
|
||||||
for (PetExtra petExtra : Plugin.GetFactory().GetPetExtras())
|
|
||||||
{
|
{
|
||||||
List<String> itemLore = new ArrayList<String>();
|
List<String> itemLore = new ArrayList<String>();
|
||||||
|
|
||||||
if (!Plugin.hasActivePet(Player.getName()))
|
if (mount.GetCost(CurrencyType.Gems) != -1)
|
||||||
{
|
{
|
||||||
itemLore.add(C.cWhite + "You must have an active pet to use this!");
|
itemLore.add(C.cYellow + mount.GetCost(CurrencyType.Gems) + " Gems");
|
||||||
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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addGadget(Gadget gadget)
|
|
||||||
{
|
|
||||||
List<String> itemLore = new ArrayList<String>();
|
|
||||||
|
|
||||||
itemLore.add(C.cYellow + gadget.getCost() + " Gems");
|
|
||||||
itemLore.add(C.cBlack);
|
itemLore.add(C.cBlack);
|
||||||
|
itemLore.addAll(Arrays.asList(mount.GetDescription()));
|
||||||
|
|
||||||
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(gadget.GetCode()))
|
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(mount.GetName()))
|
||||||
{
|
{
|
||||||
if (Plugin.hasActivePet(Player.getName()) && Plugin.getActivePet(Player.getName()).getType() == pet.GetPetType())
|
if (mount.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(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Deactivate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new DeactivateMountButton(mount, this));
|
||||||
}
|
}
|
||||||
else
|
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(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Activate " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new ActivateMountButton(mount, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= pet.GetCost(CurrencyType.Gems))
|
if (DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= mount.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));
|
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
|
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(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<GadgetManager, GadgetShop>(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);
|
PlayAcceptSound(player);
|
||||||
Creature currentPet = Plugin.getActivePet(player.getName());
|
gadget.Enable(player);
|
||||||
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());
|
|
||||||
Player.closeInventory();
|
Player.closeInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeactivatePet(Player player)
|
public void DeactivateGadget(Player player, Gadget gadget)
|
||||||
{
|
{
|
||||||
PlayAcceptSound(player);
|
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<GadgetManager, GadgetShop>(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();
|
Player.closeInventory();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,23 +2,23 @@ package mineplex.hub.gadget.ui;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import mineplex.core.pet.Pet;
|
|
||||||
import mineplex.core.shop.item.IButton;
|
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;
|
private GadgetPage _page;
|
||||||
|
|
||||||
public ActivatePetButton(Pet pet, GadgetPage page)
|
public MountButton(Mount mount, GadgetPage page)
|
||||||
{
|
{
|
||||||
_pet = pet;
|
_mount = mount;
|
||||||
_page = page;
|
_page = page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void Clicked(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.ActivatePet(player, _pet);
|
_page.PurchaseMount(player, _mount);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package mineplex.hub.gadget.ui;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import mineplex.core.pet.Pet;
|
|
||||||
|
|
||||||
public class PetSorter implements Comparator<Pet>
|
|
||||||
{
|
|
||||||
public int compare(Pet a, Pet b)
|
|
||||||
{
|
|
||||||
if (a.GetPetType().getTypeId() < b.GetPetType().getTypeId())
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<PetManager, PetShop>
|
|
||||||
{
|
|
||||||
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<PetManager, PetShop>(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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,10 +5,12 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import mineplex.core.common.CurrencyType;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilAlg;
|
import mineplex.core.common.util.UtilAlg;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.shop.item.SalesPackageBase;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import net.minecraft.server.v1_6_R3.EntityCreature;
|
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.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Mount implements Listener
|
public class Mount extends SalesPackageBase implements Listener
|
||||||
{
|
{
|
||||||
private HashSet<Player> _owners = new HashSet<Player>();
|
private HashSet<Player> _owners = new HashSet<Player>();
|
||||||
private HashMap<Player, Horse> _active = new HashMap<Player, Horse>();
|
private HashMap<Player, Horse> _active = new HashMap<Player, Horse>();
|
||||||
|
|
||||||
public MountManager Manager;
|
public MountManager Manager;
|
||||||
|
|
||||||
private String _code;
|
|
||||||
|
|
||||||
private String _name;
|
|
||||||
private String[] _desc;
|
|
||||||
|
|
||||||
private Color _color;
|
private Color _color;
|
||||||
private Style _style;
|
private Style _style;
|
||||||
private Variant _variant;
|
private Variant _variant;
|
||||||
private double _jump;
|
private double _jump;
|
||||||
private Material _armor;
|
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;
|
Manager = manager;
|
||||||
|
|
||||||
_code = code;
|
|
||||||
_name = name;
|
|
||||||
_desc = desc;
|
|
||||||
_color = color;
|
_color = color;
|
||||||
_style = style;
|
_style = style;
|
||||||
_variant = variant;
|
_variant = variant;
|
||||||
@ -62,21 +59,6 @@ public class Mount implements Listener
|
|||||||
Manager.GetPlugin().getServer().getPluginManager().registerEvents(this, Manager.GetPlugin());
|
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<Player> GetOwners()
|
public HashSet<Player> GetOwners()
|
||||||
{
|
{
|
||||||
return _owners;
|
return _owners;
|
||||||
@ -185,11 +167,11 @@ public class Mount implements Listener
|
|||||||
if (_armor != null)
|
if (_armor != null)
|
||||||
horse.getInventory().setArmor(new ItemStack(_armor));
|
horse.getInventory().setArmor(new ItemStack(_armor));
|
||||||
|
|
||||||
horse.setCustomName(player.getName() + "'s " + _name);
|
horse.setCustomName(player.getName() + "'s " + GetName());
|
||||||
horse.setCustomNameVisible(true);
|
horse.setCustomNameVisible(true);
|
||||||
|
|
||||||
//Inform
|
//Inform
|
||||||
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(_name) + "."));
|
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
|
||||||
|
|
||||||
//Store
|
//Store
|
||||||
_active.put(player, horse);
|
_active.put(player, horse);
|
||||||
@ -203,7 +185,13 @@ public class Mount implements Listener
|
|||||||
horse.remove();
|
horse.remove();
|
||||||
|
|
||||||
//Inform
|
//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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,11 @@ public class MountManager extends MiniPlugin
|
|||||||
_types.add(new Mule(this));
|
_types.add(new Mule(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashSet<Mount> getMounts()
|
||||||
|
{
|
||||||
|
return _types;
|
||||||
|
}
|
||||||
|
|
||||||
//Disallows two mounts active
|
//Disallows two mounts active
|
||||||
public void DeregisterAll(Player player)
|
public void DeregisterAll(Player player)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.hub.mount.types;
|
package mineplex.hub.mount.types;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Horse.Color;
|
import org.bukkit.entity.Horse.Color;
|
||||||
import org.bukkit.entity.Horse.Style;
|
import org.bukkit.entity.Horse.Style;
|
||||||
import org.bukkit.entity.Horse.Variant;
|
import org.bukkit.entity.Horse.Variant;
|
||||||
@ -11,10 +12,13 @@ public class Mule extends Mount
|
|||||||
{
|
{
|
||||||
public Mule(MountManager manager)
|
public Mule(MountManager manager)
|
||||||
{
|
{
|
||||||
super(manager, "Mount_Mule", "Horse of Horror", new String[]
|
super(manager, "Horse of Horror", new String[]
|
||||||
{
|
{
|
||||||
"Muley muley!"
|
"Muley muley!"
|
||||||
},
|
},
|
||||||
|
Material.HAY_BLOCK,
|
||||||
|
(byte)0,
|
||||||
|
15000,
|
||||||
Color.BLACK, Style.BLACK_DOTS, Variant.MULE, 1.0, null);
|
Color.BLACK, Style.BLACK_DOTS, Variant.MULE, 1.0, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package mineplex.hub.mount.types;
|
package mineplex.hub.mount.types;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Horse.Color;
|
import org.bukkit.entity.Horse.Color;
|
||||||
import org.bukkit.entity.Horse.Style;
|
import org.bukkit.entity.Horse.Style;
|
||||||
@ -21,12 +22,18 @@ public class Undead extends Mount
|
|||||||
{
|
{
|
||||||
public Undead(MountManager manager)
|
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 + "The most ghastly horse in",
|
||||||
C.cWhite + "existance, from the pits of",
|
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);
|
Color.BLACK, Style.BLACK_DOTS, Variant.SKELETON_HORSE, 0.8, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user