Add Music and Costume pages to cosmetic menu
This commit is contained in:
parent
50fa8b02f1
commit
cc5db5939d
@ -0,0 +1,25 @@
|
||||
package mineplex.core.cosmetic.ui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.cosmetic.ui.page.Menu;
|
||||
import mineplex.core.shop.item.SingleButton;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-15.
|
||||
*/
|
||||
public class OpenCostumes extends SingleButton
|
||||
{
|
||||
private Menu _menu;
|
||||
|
||||
public OpenCostumes(Menu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
_menu.openCostumes(player);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.cosmetic.ui.button;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.cosmetic.ui.page.Menu;
|
||||
import mineplex.core.shop.item.SingleButton;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-15.
|
||||
*/
|
||||
public class OpenMusic extends SingleButton
|
||||
{
|
||||
private Menu _menu;
|
||||
|
||||
public OpenMusic(Menu menu)
|
||||
{
|
||||
_menu = menu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
_menu.openMusic(player);
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.gadget.types.OutfitGadget;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.item.SingleButton;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-15.
|
||||
*/
|
||||
public class CostumePage extends GadgetPage
|
||||
{
|
||||
public CostumePage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player);
|
||||
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
protected void BuildPage()
|
||||
{
|
||||
int slot;
|
||||
|
||||
List<Class> costumeClasses = new ArrayList<Class>();
|
||||
|
||||
for (Gadget gadget : Plugin.getGadgetManager().getGadgets(GadgetType.Costume))
|
||||
{
|
||||
OutfitGadget outfitGadget = ((OutfitGadget) gadget);
|
||||
Class clazz = gadget.getClass();
|
||||
|
||||
if (!costumeClasses.contains(clazz))
|
||||
{
|
||||
costumeClasses.add(clazz);
|
||||
}
|
||||
|
||||
slot = (costumeClasses.indexOf(clazz) * 2) + 3 + 18;
|
||||
|
||||
if (outfitGadget.GetSlot() == OutfitGadget.ArmorSlot.Chest)
|
||||
slot += 9;
|
||||
else if (outfitGadget.GetSlot() == OutfitGadget.ArmorSlot.Legs)
|
||||
slot += 18;
|
||||
else if (outfitGadget.GetSlot() == OutfitGadget.ArmorSlot.Boots)
|
||||
slot += 27;
|
||||
|
||||
addGadget(gadget, slot);
|
||||
|
||||
if (gadget.IsActive(Player))
|
||||
addGlow(slot);
|
||||
}
|
||||
|
||||
AddButton(8, new ShopItem(Material.TNT, C.cRed + C.Bold + "Remove all Clothing", new String[] { }, 1, false), new SingleButton()
|
||||
{
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
boolean gadgetDisabled = false;
|
||||
for (Gadget gadget : Plugin.getGadgetManager().getGadgets(GadgetType.Costume))
|
||||
{
|
||||
if (gadget.IsActive(player))
|
||||
{
|
||||
gadgetDisabled = true;
|
||||
gadget.Disable(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (gadgetDisabled)
|
||||
{
|
||||
BuildPage();
|
||||
player.playSound(player.getEyeLocation(), Sound.SPLASH, 1, 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
|
||||
{
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void activateGadget(Player player, Gadget gadget)
|
||||
{
|
||||
if (gadget instanceof ItemGadget)
|
||||
{
|
||||
if (Plugin.getInventoryManager().Get(player).getItemCount(gadget.GetName()) <= 0)
|
||||
{
|
||||
purchaseGadget(player, gadget);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PlayAcceptSound(player);
|
||||
gadget.Enable(player);
|
||||
|
||||
BuildPage();
|
||||
}
|
||||
}
|
@ -3,22 +3,21 @@ package mineplex.core.cosmetic.ui.page;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.event.ActivateGemBoosterEvent;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.cosmetic.ui.button.OpenCostumes;
|
||||
import mineplex.core.cosmetic.ui.button.OpenGadgets;
|
||||
import mineplex.core.cosmetic.ui.button.OpenMorphs;
|
||||
import mineplex.core.cosmetic.ui.button.OpenMounts;
|
||||
import mineplex.core.cosmetic.ui.button.OpenMusic;
|
||||
import mineplex.core.cosmetic.ui.button.OpenParticles;
|
||||
import mineplex.core.cosmetic.ui.button.OpenPets;
|
||||
import mineplex.core.cosmetic.ui.button.TreasureButton;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
@ -42,7 +41,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
@Override
|
||||
protected void BuildPage()
|
||||
{
|
||||
AddItem(11, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
|
||||
AddItem(11 - 9, new ShopItem(175, DonationManager.Get(Player.getName()).getCoins() + " Coins", 1, false));
|
||||
|
||||
int treasureChestCount = Plugin.getInventoryManager().Get(Player).getItemCount("Treasure Chest");
|
||||
|
||||
@ -58,13 +57,13 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
AddItem(13, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGold + treasureChestCount + " Treasure Chests" + ChatColor.RESET, new String[] { ChatColor.RESET + "Coming soon..." }, 1, false));
|
||||
AddItem(13 - 9, new ShopItem(Material.CHEST, ChatColor.RESET + C.cGold + treasureChestCount + " Treasure Chests" + ChatColor.RESET, new String[] { ChatColor.RESET + "Coming soon..." }, 1, false));
|
||||
//}
|
||||
|
||||
final GemBooster gemBoosterItem = new GemBooster(Shop.getBoosterEnabled(), Plugin.getInventoryManager().Get(Player).getItemCount("Gem Booster"));
|
||||
|
||||
|
||||
AddButton(15, new ShopItem(
|
||||
AddButton(15 - 9, new ShopItem(
|
||||
gemBoosterItem.GetDisplayMaterial(),
|
||||
gemBoosterItem.GetDisplayName(),
|
||||
gemBoosterItem.GetDescription(),
|
||||
@ -111,17 +110,20 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
false));
|
||||
}
|
||||
|
||||
AddButton(27, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
||||
AddButton(29, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
||||
AddButton(31, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
||||
AddButton(33, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this));
|
||||
AddButton(35, new ShopItem(Material.BONE, "Pets", 1, false), new OpenPets(this));
|
||||
AddButton(18, new ShopItem(Material.NETHER_STAR, "Particle Effects", 1, false), new OpenParticles(this));
|
||||
AddButton(20, new ShopItem(Material.BOW, "Gadgets", 1, false), new OpenGadgets(this));
|
||||
AddButton(22, new ShopItem(Material.LEATHER, "Morphs", 1, false), new OpenMorphs(this));
|
||||
AddButton(24, new ShopItem(Material.IRON_BARDING, "Mounts", 1, false), new OpenMounts(this));
|
||||
AddButton(26, new ShopItem(Material.BONE, "Pets", 1, false), new OpenPets(this));
|
||||
//
|
||||
AddButton(48, new ShopItem(Material.GOLD_CHESTPLATE, "Costumes", 1, false), new OpenCostumes(this));
|
||||
AddButton(50, new ShopItem(Material.GREEN_RECORD, "Music", 1, false), new OpenMusic(this));
|
||||
|
||||
if (Plugin.getGadgetManager().getActive(Player, GadgetType.Particle) != null)
|
||||
{
|
||||
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Particle);
|
||||
|
||||
AddButton(36,
|
||||
AddButton(18 + 9,
|
||||
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
||||
new SingleButton()
|
||||
{
|
||||
@ -139,7 +141,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Item);
|
||||
|
||||
AddButton(38,
|
||||
AddButton(20 + 9,
|
||||
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
||||
new SingleButton()
|
||||
{
|
||||
@ -157,7 +159,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
final Gadget gadget = Plugin.getGadgetManager().getActive(Player, GadgetType.Morph);
|
||||
|
||||
AddButton(40,
|
||||
AddButton(22 + 9,
|
||||
new ShopItem(gadget.GetDisplayMaterial(), gadget.GetDisplayData(), ChatColor.RESET + C.mItem + gadget.GetName(), new String[] {}, 1, false, false),
|
||||
new SingleButton()
|
||||
{
|
||||
@ -175,7 +177,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
final Mount<?> mount = Plugin.getMountManager().getActive(Player);
|
||||
|
||||
AddButton(42,
|
||||
AddButton(24 + 9,
|
||||
new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), ChatColor.RESET + C.mItem + mount.GetName(), new String[] {}, 1, false, false),
|
||||
new SingleButton()
|
||||
{
|
||||
@ -191,7 +193,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
|
||||
if (Plugin.getPetManager().hasActivePet(Player.getName()))
|
||||
{
|
||||
AddButton(44, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false),
|
||||
AddButton(26 + 9, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), ChatColor.RESET + C.mItem + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false),
|
||||
new SingleButton()
|
||||
{
|
||||
@Override
|
||||
@ -246,4 +248,14 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
|
||||
{
|
||||
Shop.OpenPageForPlayer(player, new PetPage(Plugin, Shop, ClientManager, DonationManager, "Pets", player));
|
||||
}
|
||||
|
||||
public void openCostumes(Player player)
|
||||
{
|
||||
Shop.OpenPageForPlayer(player, new CostumePage(Plugin, Shop, ClientManager, DonationManager, "Costumes", player));
|
||||
}
|
||||
|
||||
public void openMusic(Player player)
|
||||
{
|
||||
Shop.OpenPageForPlayer(player, new MusicPage(Plugin, Shop, ClientManager, DonationManager, "Music", player));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package mineplex.core.cosmetic.ui.page;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.cosmetic.ui.CosmeticShop;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.item.SingleButton;
|
||||
|
||||
/**
|
||||
* Created by shaun on 14-09-15.
|
||||
*/
|
||||
public class MusicPage extends GadgetPage
|
||||
{
|
||||
public MusicPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
||||
{
|
||||
super(plugin, shop, clientManager, donationManager, name, player);
|
||||
}
|
||||
|
||||
protected void BuildPage()
|
||||
{
|
||||
int slot = 19;
|
||||
|
||||
for (Gadget gadget : Plugin.getGadgetManager().getGadgets(GadgetType.MusicDisc))
|
||||
{
|
||||
addGadget(gadget, slot);
|
||||
|
||||
slot++;
|
||||
|
||||
if (slot == 26)
|
||||
slot = 28;
|
||||
}
|
||||
|
||||
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
|
||||
{
|
||||
@Override
|
||||
public void Clicked(Player player)
|
||||
{
|
||||
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activateGadget(Player player, Gadget gadget)
|
||||
{
|
||||
super.activateGadget(player, gadget);
|
||||
player.closeInventory();
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
@ -26,13 +25,13 @@ import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||
import mineplex.core.gadget.gadgets.*;
|
||||
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
|
||||
import mineplex.core.gadget.types.Gadget;
|
||||
import mineplex.core.gadget.types.GadgetType;
|
||||
import mineplex.core.gadget.types.ItemGadget;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.gadget.types.OutfitGadget;
|
||||
import mineplex.core.gadget.types.MusicGadget;
|
||||
import mineplex.core.gadget.types.OutfitGadget;
|
||||
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.mount.MountManager;
|
||||
@ -178,7 +177,7 @@ public class GadgetManager extends MiniPlugin
|
||||
{
|
||||
for (Gadget gadget : _gadgets.get(gadgetType))
|
||||
{
|
||||
if (gadget instanceof MorphGadget)
|
||||
if (gadget instanceof OutfitGadget)
|
||||
{
|
||||
OutfitGadget armor = (OutfitGadget) gadget;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user