Added new gadget type

This commit is contained in:
LCastr0 2017-04-26 13:58:30 -03:00
parent 87b829b411
commit 1855cfc4ed
4 changed files with 88 additions and 7 deletions

View File

@ -0,0 +1,21 @@
package mineplex.core.cosmetic.ui.button.open;
import org.bukkit.entity.Player;
import mineplex.core.cosmetic.ui.page.Menu;
import mineplex.core.cosmetic.ui.page.RankSelectorPage;
import mineplex.core.gadget.types.Gadget;
public class OpenRankSelector extends OpenPageButton
{
public OpenRankSelector(Menu menu, Gadget active)
{
super(menu, active);
}
@Override
protected void leftClick(Player player)
{
getMenu().getShop().openPageForPlayer(player, new RankSelectorPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Rank Selector Particles", player));
}
}

View File

@ -30,6 +30,7 @@ import mineplex.core.cosmetic.ui.button.open.OpenMounts;
import mineplex.core.cosmetic.ui.button.open.OpenMusic;
import mineplex.core.cosmetic.ui.button.open.OpenParticles;
import mineplex.core.cosmetic.ui.button.open.OpenPets;
import mineplex.core.cosmetic.ui.button.open.OpenRankSelector;
import mineplex.core.cosmetic.ui.button.open.OpenTaunts;
import mineplex.core.cosmetic.ui.button.open.OpenWinEffect;
import mineplex.core.donation.DonationManager;
@ -46,6 +47,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
private static final String VISIBILITY_HUB = "Usable in Lobbies";
private static final String VISIBILITY_EVERYWHERE = "Visible Everywhere";
private static final String VISIBILITY_GAMES = "Visible in Games";
private static final String VISIBILITY_GAME_HUB = "Visible in Game Lobbies";
public Menu(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player)
{
@ -66,10 +68,9 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
shardLore.add(C.cGray + "handy. Maybe I can collect more!");
ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false);
addItem(4, shards);
// Cosmetic Items
int[] slots = UtilUI.getIndicesFor(15, 1, 5, 1);
int[] slots = UtilUI.getIndicesFor(15, 0, 5, 1);
/*int particleSlot = 9;//slots[0];
int arrowSlot = 11;//slots[1];
int jumpSlot = 13;//slots[2];
@ -88,11 +89,14 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
deathSlot = slots[3], gadgetSlot = slots[4], morphSlot = slots[5],
mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8],
costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11],
winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14];
winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14],
rankSelectorSlot = balloonsSlot + 4;
EnumMap<GadgetType, Integer> ownedCount = new EnumMap<GadgetType, Integer>(GadgetType.class);
EnumMap<GadgetType, Integer> maxCount = new EnumMap<GadgetType, Integer>(GadgetType.class);
EnumMap<GadgetType, Gadget> enabled = new EnumMap<GadgetType, Gadget>(GadgetType.class);
addItem(rankSelectorSlot + 2, shards);
EnumMap<GadgetType, Integer> ownedCount = new EnumMap<>(GadgetType.class);
EnumMap<GadgetType, Integer> maxCount = new EnumMap<>(GadgetType.class);
EnumMap<GadgetType, Gadget> enabled = new EnumMap<>(GadgetType.class);
for(GadgetType type : GadgetType.values())
{
@ -218,6 +222,11 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
lore = getLore(ownedCount.get(type), maxCount.get(type), "Balloons are collectibles that you can float above your head as you wander the lobby. You can have up to 10 balloons in your hand at one time.", VISIBILITY_HUB, enabled.get(type));
addButton(balloonsSlot, new ShopItem(Material.LEASH, "Balloons", lore, 1, false), new OpenBalloons(this, enabled.get(type)));
if (enabled.containsKey(type)) addGlow(balloonsSlot);
type = GadgetType.RANK_SELECTOR;
lore = getLore(ownedCount.get(type), maxCount.get(type), "Placeholder", VISIBILITY_GAME_HUB, enabled.get(type));
addButton(rankSelectorSlot, new ShopItem(Material.LEVER, "Rank Selector Particles", lore, 1, false), new OpenRankSelector(this, enabled.get(type)));
if (enabled.containsKey(type)) addGlow(rankSelectorSlot);
}
private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled)

View File

@ -0,0 +1,50 @@
package mineplex.core.cosmetic.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
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.IButton;
import mineplex.core.shop.item.ShopItem;
public class RankSelectorPage extends GadgetPage
{
public RankSelectorPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
{
super(plugin, shop, clientManager, donationManager, name, player);
}
@Override
protected void buildPage()
{
int slot = 10;
for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.RANK_SELECTOR))
{
addGadget(gadget, slot);
if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.RANK_SELECTOR) == gadget)
addGlow(slot);
slot++;
if (slot == 17 || slot == 26 || slot == 35)
slot += 2;
}
addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton()
{
public void onClick(Player player, ClickType clickType)
{
getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player));
}
});
}
}

View File

@ -17,7 +17,8 @@ public enum GadgetType
TAUNT("Taunts", "activeTaunt"),
WIN_EFFECT("Win Effects", "activeWinEffect"),
GAME_MODIFIER("Game Modifiers", ""),
BALLOON("Balloons", "");
BALLOON("Balloons", ""),
RANK_SELECTOR("Rank Selectors", "activeRankSelector");
private String _name;
private String _databaseKey;