Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.infinity.survival.story;
- import java.util.ArrayList;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.enchantments.Enchantment;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.event.inventory.InventoryCloseEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.inventory.meta.SkullMeta;
- import com.infinity.survival.Main;
- import com.rit.sucy.EnchantmentAPI;
- public class AlphaShopInventory implements Listener{
- List<Player> confirm_list = new ArrayList<Player>();
- List<Player> draco_confirm_list = new ArrayList<Player>();
- List<Player> triskull_confirm_list = new ArrayList<Player>();
- //Item Places
- public static Inventory shopInventory = Bukkit.createInventory(null, 54, "The Alpha's Shop");
- static{
- List<String> llore = new ArrayList<String>();
- llore.add(ChatColor.GREEN + "Lapis Lazuli is my 2nd favorite mineral.");
- llore.add(ChatColor.GREEN + "If you want, by some from me!");
- ItemStack lapisore = new ItemStack(Material.LAPIS_ORE, 5);
- ItemMeta lom = lapisore.getItemMeta();
- lom.setLore(llore);
- lom.setDisplayName(ChatColor.BLUE + "Lapis For XPCurrency");
- lapisore.setItemMeta(lom);
- shopInventory.setItem(2, lapisore);
- shopInventory.setItem(6, lapisore);
- List<String> kslore = new ArrayList<String>();
- kslore.add(ChatColor.GREEN + "A common sword used by Alpha Knights");
- ItemStack ksword = createItem(Material.IRON_SWORD, ChatColor.BLUE + "Alpha Knight Sword", true, kslore);
- EnchantmentAPI.getEnchantment("Sharpness+").addToItem(ksword, 5);
- shopInventory.setItem(11, ksword);
- List<String> khlore = new ArrayList<String>();
- khlore.add(ChatColor.GREEN + "A helmet used by Alpha Knights.");
- ItemStack khelm = createItem(Material.IRON_HELMET, ChatColor.BLUE + "Alpha Knight Helmet", true, khlore);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(khelm, 5);
- shopInventory.setItem(12, khelm);
- List<String> kclore = new ArrayList<String>();
- kclore.add(ChatColor.GREEN + "A chestplate used by Alpha Knights");
- ItemStack kchest = createItem(Material.IRON_CHESTPLATE, ChatColor.BLUE + "Alpha Knight Chestplate", true, kclore);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(kchest, 5);
- shopInventory.setItem(13, kchest);
- List<String> kllore = new ArrayList<String>();
- kllore.add(ChatColor.GREEN + "Leggings used by Alpha Knights");
- ItemStack klegs = createItem(Material.IRON_LEGGINGS, ChatColor.BLUE + "Alpha Knight Leggings", true, kllore);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(klegs, 5);
- shopInventory.setItem(14, klegs);
- List<String> kblore = new ArrayList<String>();
- kblore.add(ChatColor.GREEN + "A pair of boots used by Alpha Knights");
- ItemStack kboots = createItem(Material.IRON_BOOTS, ChatColor.BLUE + "Alpha Knight Boots", true, kblore);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(kboots, 5);
- shopInventory.setItem(15, kboots);
- List<String> alslore = new ArrayList<String>();
- alslore.add(ChatColor.GREEN + "The mighty sword that helped Alexander");
- alslore.add(ChatColor.GREEN + "overcome the World, that has slain");
- alslore.add(ChatColor.GREEN + "many men!");
- ItemStack alsword = createItem(Material.IRON_SWORD, ChatColor.GOLD + "Alexander's Sword", true, alslore);
- EnchantmentAPI.getEnchantment("Sharpness+").addToItem(alsword, 10);
- alsword.addEnchantment(Enchantment.DURABILITY, 3);
- shopInventory.setItem(20, alsword);
- List<String> alhlore = new ArrayList<String>();
- alhlore.add(ChatColor.GRAY + "The helmet of Alexander the Great!");
- ItemStack alhelm = createItem(Material.CHAINMAIL_HELMET, "Royal Helmet", true, alhlore);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(alhelm, 10);
- alhelm.addEnchantment(Enchantment.DURABILITY, 3);
- shopInventory.setItem(21, alhelm);
- List<String> alclore = new ArrayList<String>();
- alclore.add(ChatColor.GRAY + "The awesome chestplate of Alexander");
- alclore.add(ChatColor.GRAY + "the Great!");
- ItemStack alchest = createItem(Material.CHAINMAIL_CHESTPLATE, "Royal Chestplate", true, alclore);
- alchest.addEnchantment(Enchantment.DURABILITY, 3);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(alchest, 10);
- shopInventory.setItem(22, alchest);
- List<String> alllore = new ArrayList<String>();
- alllore.add(ChatColor.GRAY + "The leggings donned many times by");
- alllore.add(ChatColor.GRAY + "Alexander the Great!");
- ItemStack allegs = createItem(Material.CHAINMAIL_LEGGINGS, "Royal Leggings", true, alllore);
- allegs.addEnchantment(Enchantment.DURABILITY, 3);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(allegs, 10);
- shopInventory.setItem(23, allegs);
- List<String> alblore = new ArrayList<String>();
- alblore.add(ChatColor.GRAY + "The steel-hard boots of Alexander");
- alblore.add(ChatColor.GRAY + "the Great!");
- ItemStack alboots = createItem(Material.CHAINMAIL_BOOTS, "Royal Boots", true, alblore);
- alboots.addEnchantment(Enchantment.DURABILITY, 3);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(alboots, 10);
- shopInventory.setItem(24, alboots);
- List<String> fslore = new ArrayList<String>();
- fslore.add(ChatColor.GREEN + "A sword once used by Helios,");
- fslore.add(ChatColor.GREEN + "it is sure to burn down your foes!");
- ItemStack fsword = createItem(Material.GOLD_SWORD, ChatColor.GOLD + "Flaming Sword", true, fslore);
- fsword.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, 5);
- EnchantmentAPI.getEnchantment("Sharpness+").addToItem(fsword, 15);
- fsword.addUnsafeEnchantment(Enchantment.DURABILITY, 12);
- shopInventory.setItem(29, fsword);
- List<String> sblore = new ArrayList<String>();
- sblore.add(ChatColor.GREEN + "A pair of boots used by Helios!");
- ItemStack sboots = createItem(Material.GOLD_BOOTS, ChatColor.RED + "Burning Boots", true, sblore);
- EnchantmentAPI.getEnchantment("Flame Coat").addToItem(sboots, 5);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(sboots, 15);
- sboots.addUnsafeEnchantment(Enchantment.DURABILITY, 12);
- shopInventory.setItem(33, sboots);
- List<String> sllore = new ArrayList<String>();
- sllore.add(ChatColor.GREEN + "Leggings used by Helios!");
- ItemStack sleggings = createItem(Material.GOLD_LEGGINGS, ChatColor.RED + "Past-Flaming Pants", true, sllore);
- EnchantmentAPI.getEnchantment("Flame Coat").addToItem(sleggings, 5);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(sleggings, 15);
- sleggings.addUnsafeEnchantment(Enchantment.DURABILITY, 12);
- shopInventory.setItem(32, sleggings);
- List<String> sclore = new ArrayList<String>();
- sclore.add(ChatColor.GREEN + "A chestplate used by Helios!");
- ItemStack schest = createItem(Material.GOLD_CHESTPLATE, ChatColor.RED + "Sizziling Chestplate", true, sclore);
- EnchantmentAPI.getEnchantment("Flame Coat").addToItem(schest, 5);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(schest, 15);
- schest.addUnsafeEnchantment(Enchantment.DURABILITY, 12);
- shopInventory.setItem(31, schest);
- List<String> shlore = new ArrayList<String>();
- shlore.add(ChatColor.GREEN + "A helmet used by Helios!");
- ItemStack shelm = createItem(Material.GOLD_HELMET, ChatColor.RED + "Heated Helmet", true, shlore);
- EnchantmentAPI.getEnchantment("Flame Coat").addToItem(shelm, 5);
- EnchantmentAPI.getEnchantment("Protection+").addToItem(shelm, 15);
- shelm.addUnsafeEnchantment(Enchantment.DURABILITY, 12);
- shopInventory.setItem(30, shelm);
- ItemStack balance = new ItemStack(Material.EXP_BOTTLE);
- ItemMeta bmeta = balance.getItemMeta();
- bmeta.setDisplayName(ChatColor.GOLD + "Currency XP Balance");
- List<String> balance_lore = new ArrayList<String>();
- balance_lore.add(ChatColor.GREEN + "Click this to see your XPCurrency balance.");
- bmeta.setLore(balance_lore);
- balance.setItemMeta(bmeta);
- shopInventory.setItem(4, balance);
- ItemStack netherstar = new ItemStack(Material.NETHER_STAR);
- ItemMeta nsmeta = netherstar.getItemMeta();
- nsmeta.setDisplayName(ChatColor.GRAY + "General TriSkull's Heart Trade");
- List<String> nslore = new ArrayList<String>();
- nslore.add(ChatColor.GREEN + "If General TriSkull's Heart is in your hand,");
- nslore.add(ChatColor.GREEN + "I'll trade for it!");
- nsmeta.setLore(nslore);
- netherstar.setItemMeta(nsmeta);
- shopInventory.setItem(5, netherstar);
- ItemStack skull = new ItemStack(Material.SKULL_ITEM);
- SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
- skull.setDurability((short) 3);
- skullMeta.setOwner("KingEnderman");
- skull.setItemMeta(skullMeta);
- ItemMeta skullIMeta = skull.getItemMeta();
- skullIMeta.setDisplayName(ChatColor.RED + "General Draco's Head");
- List<String> slore = new ArrayList<String>();
- slore.add(ChatColor.GREEN + "If General Draco's Head is in your hand,");
- slore.add(ChatColor.GREEN + "I'll trade for it!");
- skullMeta.setLore(slore);
- skull.setItemMeta(skullIMeta);
- shopInventory.setItem(3, skull);
- ItemStack dsword = new ItemStack(Material.DIAMOND_SWORD);
- ItemMeta dsmeta = dsword.getItemMeta();
- dsmeta.setDisplayName("" + ChatColor.GREEN + ChatColor.BOLD + "The Delta Sword");
- List<String> dslore = new ArrayList<String>();
- dslore.add(ChatColor.GOLD + "The Delta Sword contains the ancient ");
- dslore.add(ChatColor.GOLD + "forbidden power to damage a immortal.");
- dsmeta.setLore(dslore);
- dsword.setItemMeta(dsmeta);
- EnchantmentAPI.getEnchantment("Sharpness+").addToItem(dsword, 10);
- dsword.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
- dsword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
- EnchantmentAPI.getEnchantment("Alpha's Blessing").addToItem(dsword, 1);
- shopInventory.setItem(38, dsword);
- ItemStack ahelmet = new ItemStack(Material.DIAMOND_HELMET);
- ItemMeta ahmeta = ahelmet.getItemMeta();
- ahmeta.setDisplayName(ChatColor.BLUE + "The Alpha's Helmet");
- List<String> ahlore = new ArrayList<String>();
- ahlore.add(ChatColor.GOLD + "A helmet blessed by the Alpha herself.");
- ahmeta.setLore(ahlore);
- ahelmet.setItemMeta(ahmeta);
- ahelmet.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 19);
- ahelmet.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
- EnchantmentAPI.getEnchantment("Alpha's Blessing").addToItem(ahelmet, 1);
- shopInventory.setItem(39, ahelmet);
- ItemStack achest = new ItemStack(Material.DIAMOND_CHESTPLATE);
- ItemMeta acmeta = achest.getItemMeta();
- acmeta.setDisplayName(ChatColor.BLUE + "The Alpha's Chestplate");
- List<String> aclore = new ArrayList<String>();
- aclore.add(ChatColor.GOLD + "A chestplate blessed by the Alpha herself.");
- acmeta.setLore(aclore);
- achest.setItemMeta(acmeta);
- achest.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 19);
- achest.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
- EnchantmentAPI.getEnchantment("Alpha's Blessing").addToItem(achest, 1);
- shopInventory.setItem(40, achest);
- ItemStack alegs = new ItemStack(Material.DIAMOND_LEGGINGS);
- ItemMeta almeta = alegs.getItemMeta();
- almeta.setDisplayName(ChatColor.BLUE + "The Alpha's Leggings");
- List<String> allore = new ArrayList<String>();
- allore.add(ChatColor.GOLD + "Leggings that are blessed by the Alpha herself.");
- almeta.setLore(allore);
- alegs.setItemMeta(almeta);
- alegs.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 19);
- alegs.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
- EnchantmentAPI.getEnchantment("Alpha's Blessing").addToItem(alegs, 1);
- shopInventory.setItem(41, alegs);
- ItemStack aboots = new ItemStack(Material.DIAMOND_BOOTS);
- ItemMeta abmeta = aboots.getItemMeta();
- abmeta.setDisplayName(ChatColor.BLUE + "The Alpha's Boots");
- List<String> ablore = new ArrayList<String>();
- ablore.add(ChatColor.GOLD + "A pair of boots blessed by the Alpha herself.");
- abmeta.setLore(ablore);
- aboots.setItemMeta(abmeta);
- aboots.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 19);
- aboots.addUnsafeEnchantment(Enchantment.DURABILITY, 4);
- EnchantmentAPI.getEnchantment("Alpha's Blessing").addToItem(aboots, 1);
- shopInventory.setItem(42, aboots);
- }
- @EventHandler
- public void inventoryClickEvent(InventoryClickEvent e){
- Player p = (Player) e.getWhoClicked();
- ItemStack clicked = e.getCurrentItem();
- Inventory inventory = e.getInventory();
- if(inventory.getName().equals(shopInventory.getName())){
- if(clicked.getType() != null || clicked.getType() != Material.AIR){
- e.setCancelled(true);
- Material type = clicked.getType();
- if(type == Material.DIAMOND_HELMET){
- buyItem(p, clicked, 5000);
- }else if(type == Material.DIAMOND_CHESTPLATE){
- buyItem(p, clicked, 8000);
- }else if(type == Material.DIAMOND_LEGGINGS){
- buyItem(p, clicked, 7000);
- }else if(type == Material.DIAMOND_BOOTS){
- buyItem(p, clicked, 4000);
- }else if(type == Material.DIAMOND_SWORD){
- buyItem(p, clicked, 10000);
- }else if(type == Material.EXP_BOTTLE){
- p.sendMessage(StoryCommand.alphatag + "You have " + Main.instance.getConfig().getLong(p.getUniqueId() + ".XPCurrency") + " XP Currnecy.");
- }else if(type == Material.SKULL_ITEM || type == Material.NETHER_STAR){
- bossTrade(p, p.getItemInHand());
- }else if(type == Material.GOLD_HELMET){
- buyItem(p, clicked, 2250);
- }else if(type == Material.GOLD_CHESTPLATE){
- buyItem(p, clicked, 3950);
- }else if(type == Material.GOLD_LEGGINGS){
- buyItem(p, clicked, 2950);
- }else if(type == Material.GOLD_BOOTS){
- buyItem(p, clicked, 1800);
- }else if(type == Material.GOLD_SWORD){
- buyItem(p, clicked, 4250);
- }else if(type == Material.CHAINMAIL_HELMET){
- buyItem(p, clicked, 1550);
- }else if(type == Material.CHAINMAIL_CHESTPLATE){
- buyItem(p, clicked, 3200);
- }else if(type == Material.CHAINMAIL_LEGGINGS){
- buyItem(p, clicked, 2560);
- }else if(type == Material.CHAINMAIL_BOOTS){
- buyItem(p, clicked, 1000);
- }else if(type == Material.IRON_SWORD){
- if(clicked.getItemMeta().getDisplayName().equals(ChatColor.GOLD + "Alexander's Sword")){
- buyItem(p, clicked, 3375);
- }else{
- buyItem(p, clicked, 325);
- }
- }else if(type == Material.IRON_HELMET){
- buyItem(p, clicked, 515);
- }else if(type == Material.IRON_CHESTPLATE){
- buyItem(p, clicked, 1050);
- }else if(type == Material.IRON_LEGGINGS){
- buyItem(p, clicked, 850);
- }else if(type == Material.IRON_BOOTS){
- buyItem(p, clicked, 300);
- }else if(type == Material.LAPIS_ORE){
- buyItem(p, clicked, 75);
- }
- }
- }
- }
- public void buyItem(Player p, ItemStack item, int price){
- long xpCurrency = Main.instance.getConfig().getLong(p.getUniqueId() + ".XPCurrency");
- if(xpCurrency < price){
- long remaining = price - xpCurrency;
- p.sendMessage(StoryCommand.alphatag + "I'm sorry, but you don't have enough XP Currency to buy this! You need " + ChatColor.AQUA + remaining + ChatColor.RED + " more XPCurrency to buy this!");
- }else{
- if(confirm_list.contains(p)){
- p.sendMessage(StoryCommand.alphatag + "Thank you for your purchase!");
- p.getInventory().addItem(item);
- Main.instance.getConfig().set(p.getUniqueId() + ".XPCurrency", xpCurrency - price);
- p.closeInventory();
- confirm_list.remove(p);
- }else if(!confirm_list.contains(p)){
- p.sendMessage(StoryCommand.alphatag + "You chose the " + item.getItemMeta().getDisplayName() + ChatColor.RESET + ChatColor.GREEN + " which is priced at " + ChatColor.AQUA + price + " Currency XP" + ChatColor.GREEN + ".");
- p.sendMessage(StoryCommand.alphatag + "Are you sure you want to do this? If you are, click this item again. If you don't, exit the inventory.");
- confirm_list.add(p);
- }
- }
- }
- public void bossTrade(Player p, ItemStack item){
- if(item.getType() == Material.NETHER_STAR){
- if(EnchantmentAPI.itemHasEnchantment(item, "Evil Aura")){
- if(triskull_confirm_list.contains(p)){
- p.getInventory().removeItem(item);
- Main.instance.getConfig().set(p.getUniqueId() + ".XPCurrency", Main.instance.getConfig().getLong(p.getUniqueId() + ".XPCurrency") + 100);
- Main.instance.saveConfig();
- Main.instance.reloadConfig();
- p.sendMessage(StoryCommand.alphatag + "Thank you for the heart. Here's your XPCurrency. Pleasure doing business with you.");
- }else{
- triskull_confirm_list.add(p);
- p.sendMessage(StoryCommand.alphatag + "You have General TriSkull's heart? Very impressive. If you allow me, I'll buy it for 100 XPCurrency.");
- p.sendMessage(StoryCommand.alphatag + "If you want me to buy it, click the Nether Star again. If not, close the inventory.");
- }
- }else{
- p.sendMessage(StoryCommand.alphatag + "I'm sorry, but this is not General TriSkull's heart. Yet it seems... similar.");
- }
- }else if(item.getType() == Material.SKULL_ITEM){
- if(EnchantmentAPI.itemHasEnchantment(item, "Evil Aura")){
- if(draco_confirm_list.contains(p)){
- p.getInventory().removeItem(item);
- Main.instance.getConfig().set(p.getUniqueId() + ".XPCurrency", Main.instance.getConfig().getLong(p.getUniqueId() + ".XPCurrency") + 250);
- Main.instance.saveConfig();
- Main.instance.reloadConfig();
- p.sendMessage(StoryCommand.alphatag + "Thank you for the head. Here's your XPCurrency. Pleasure doing business with you.");
- }else{
- draco_confirm_list.add(p);
- p.sendMessage(StoryCommand.alphatag + "You have General Draco's head? I'm astonished! If you allow me, I'll buy it for 250 XPCurrency.");
- p.sendMessage(StoryCommand.alphatag + "If you want me to buy it, click General Draco's head again. If not, close the inventory.");
- }
- }else{
- p.sendMessage(StoryCommand.alphatag + "I'm sorry, but this is not General Draco's head.");
- }
- }else{
- p.sendMessage(StoryCommand.alphatag + "I'm sorry, but you don't have General TriSkull's heart or General Draco's head!");
- }
- }
- public static ItemStack createItem(Material type, String name, boolean hasLore, List<String> lore){
- ItemStack item = new ItemStack(type);
- ItemMeta imeta = item.getItemMeta();
- imeta.setDisplayName(name);
- if(hasLore == true){
- imeta.setLore(lore);
- }
- item.setItemMeta(imeta);
- return item;
- }
- @EventHandler
- public void inventoryClose(InventoryCloseEvent e){
- if(e.getInventory().getName().equals(shopInventory.getName())){
- Player p = (Player) e.getPlayer();
- if(confirm_list.contains(p)){
- confirm_list.remove(p);
- }
- if(draco_confirm_list.contains(p)){
- draco_confirm_list.remove(p);
- }
- if(triskull_confirm_list.contains(p)){
- triskull_confirm_list.remove(p);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement