Add KitEvolve inventory

This commit is contained in:
libraryaddict 2014-11-29 07:22:18 +13:00
parent e6fac6de39
commit 5544bbb440
4 changed files with 204 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package nautilus.game.arcade.game.games.searchanddestroy;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import mineplex.core.shop.item.SingleButton;
import nautilus.game.arcade.kit.Kit;
public class EvolveButton extends SingleButton
{
private SearchAndDestroy _arcadeManager;
private Kit _kit;
public EvolveButton(SearchAndDestroy arcadeManager, Kit kit)
{
_arcadeManager = arcadeManager;
_kit = kit;
}
@Override
public void Clicked(Player player)
{
// Make sure this player isn't a spectator
if (((CraftPlayer) player).getHandle().spectating)
return;
_arcadeManager.SetKit(player, _kit, true);
player.closeInventory();
}
}

View File

@ -0,0 +1,40 @@
package nautilus.game.arcade.game.games.searchanddestroy;
import java.util.ArrayList;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.searchanddestroy.KitManager.UpgradeKit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
public class KitEvolve extends MiniPlugin
{
private SearchAndDestroy arcadeManager;
private KitEvolveShop kitEvolve;
public KitEvolve(JavaPlugin plugin, SearchAndDestroy manager, ArrayList<UpgradeKit> kits)
{
super("SnD Kit Evolving", plugin);
arcadeManager = manager;
kitEvolve = new KitEvolveShop(this, manager, manager.getArcadeManager().GetClients(), manager.getArcadeManager()
.GetDonation(), kits);
// TODO Auto-generated constructor stub
}
@EventHandler
public void onInteract(PlayerChatEvent event)
{
if (arcadeManager.GetState() == GameState.Live)
{
kitEvolve.attemptShopOpen(event.getPlayer());
}
}
}

View File

@ -0,0 +1,93 @@
package nautilus.game.arcade.game.games.searchanddestroy;
import java.util.ArrayList;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.game.games.searchanddestroy.KitManager.UpgradeKit;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class KitEvolvePage extends ShopPageBase<KitEvolve, KitEvolveShop>
{
private SearchAndDestroy _search;
private ArrayList<UpgradeKit> _kits;
public KitEvolvePage(KitEvolve plugin, SearchAndDestroy arcadeManager, KitEvolveShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player, ArrayList<UpgradeKit> kits)
{
super(plugin, shop, clientManager, donationManager, "Kit Evolve Menu", player);
_search = arcadeManager;
_kits = kits;
BuildPage();
}
@Override
protected void BuildPage()
{
Kit hisKit = _search.GetKit(Player);
UpgradeKit kit = null;
for (UpgradeKit k : _kits)
{
if (k._kit == hisKit)
{
kit = k;
break;
}
}
boolean canEvolve = true;
AddItem(kit._kitSlot, makeItem(kit._kit));
for (int slot : kit._path)
{
AddItem(slot, makeItem(new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 15).setTitle(" ").build()));
}
if (kit._daddy != null)
{
AddItem(kit._daddy._kitSlot, makeItem(kit._daddy._kit));
for (int slot : kit._daddy._path)
{
AddItem(slot, makeItem(new ItemBuilder(Material.STAINED_GLASS_PANE, 1, (short) 15).setTitle(" ").build()));
}
if (kit._daddy._daddy != null)
{
AddItem(kit._daddy._daddy._kitSlot, makeItem(kit._daddy._daddy._kit));
}
}
if (canEvolve)
{
for (UpgradeKit child : kit._children)
{
for (int slot : child._path)
AddItem(slot, makeItem(new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(" ").build()));
AddButton(child._kitSlot, makeItem(child._kit), new EvolveButton(_search, child._kit));
}
}
for (UpgradeKit k : _kits)
{
if (getItem(k._kitSlot) == null)
{
AddItem(k._kitSlot, makeItem(new ItemBuilder(Material.STONE).setTitle(C.cRed + "Locked").build()));
}
}
}
private ShopItem makeItem(Kit kit)
{
return new ShopItem(new ItemBuilder(kit.GetItemInHand()).setTitle(kit.GetName()).build(), kit.GetName(), kit.GetName(),
1, false, false);
}
private ShopItem makeItem(ItemStack item)
{
System.out.print("Making shop item " + item);
return new ShopItem(item, "", "", 1, false, false);
}
}

View File

@ -0,0 +1,41 @@
package nautilus.game.arcade.game.games.searchanddestroy;
import java.util.ArrayList;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.CurrencyType;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.game.games.searchanddestroy.KitManager.UpgradeKit;
import org.bukkit.entity.Player;
public class KitEvolveShop extends ShopBase<KitEvolve>
{
private SearchAndDestroy _arcadeManager;
private ArrayList<UpgradeKit> _kits;
public KitEvolveShop(KitEvolve plugin, SearchAndDestroy arcadeManager, CoreClientManager clientManager,
DonationManager donationManager, ArrayList<UpgradeKit> kits, CurrencyType... currencyTypes)
{
super(plugin, clientManager, donationManager, "Kit Evolve Menu", currencyTypes);
_arcadeManager = arcadeManager;
_kits = kits;
}
@Override
protected ShopPageBase<KitEvolve, ? extends ShopBase<KitEvolve>> BuildPagesFor(Player player)
{
return new KitEvolvePage(Plugin, _arcadeManager, this, ClientManager, DonationManager, player, _kits);
}
public void update()
{
for (ShopPageBase<KitEvolve, ? extends ShopBase<KitEvolve>> shopPage : PlayerPageMap.values())
{
shopPage.Refresh();
}
}
}