SHARE
TWEET

Untitled

a guest Jun 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.admirable.buffs.events.inventory;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.inventory.InventoryClickEvent;
  10. import org.bukkit.inventory.Inventory;
  11. import org.bukkit.inventory.ItemStack;
  12. import org.bukkit.inventory.meta.ItemMeta;
  13.  
  14. public class InventoryClick implements Listener {
  15.  
  16.     @EventHandler
  17.     public void onInventoryClick(InventoryClickEvent event) {
  18.         Inventory swift = Bukkit.createInventory(null, 9, "Swiftness");
  19.         Inventory haste = Bukkit.createInventory(null, 9, "Haste");
  20.         Inventory regen = Bukkit.createInventory(null, 9, "Regeneration");
  21.         Inventory night = Bukkit.createInventory(null, 9, "Night Vision");
  22.         Inventory sat = Bukkit.createInventory(null, 9, "Saturation");
  23.         Inventory invis = Bukkit.createInventory(null, 9, "Invisibility");
  24.         Inventory fire = Bukkit.createInventory(null, 9, "Fire Resistance");
  25.         Inventory health = Bukkit.createInventory(null, 9, "Health Boost");
  26.         Inventory jump = Bukkit.createInventory(null, 9, "Jump Boost");
  27.         Inventory resis = Bukkit.createInventory(null, 9, "Resistance");
  28.         Inventory strength = Bukkit.createInventory(null, 9, "Strength");
  29.         ItemStack sugar = nameItem(Material.SUGAR, ChatColor.AQUA + "Swiftness");
  30.         ItemStack carrot = nameItem(Material.CARROT_ITEM, ChatColor.AQUA + "Haste");
  31.         ItemStack ghastTear = nameItem(Material.GHAST_TEAR, ChatColor.AQUA + "Regeneration");
  32.         ItemStack gCarrot = nameItem(Material.GOLDEN_CARROT, ChatColor.AQUA + "Night Vision");
  33.         ItemStack fern = nameItem(Material.LONG_GRASS, ChatColor.AQUA + "Saturation");
  34.         ItemStack bush = nameItem(Material.DEAD_BUSH, ChatColor.AQUA + "Invisibilty");
  35.         ItemStack magma = nameItem(Material.MAGMA_CREAM, ChatColor.AQUA + "Fire Resistance");
  36.         ItemStack apple = nameItem(Material.APPLE, ChatColor.AQUA + "Health Boost");
  37.         ItemStack foot = nameItem(Material.RABBIT_FOOT, ChatColor.AQUA + "Jump Boost");
  38.         ItemStack gApple = nameItem(Material.GOLDEN_APPLE, ChatColor.AQUA + "Resistance");
  39.         ItemStack blazePowder = nameItem(Material.RABBIT_FOOT, ChatColor.AQUA + "Strength");
  40.         ItemStack glowstone = nameItem(Material.GLOWSTONE_DUST, ChatColor.AQUA + "Amplifier");
  41.         ItemStack redstone = nameItem(Material.REDSTONE, ChatColor.AQUA + "Duration");
  42.         ItemStack gunPowder = nameItem(Material.SULPHUR, ChatColor.AQUA + "Splash");
  43.         ItemStack get = nameItem(Material.POTION, ChatColor.AQUA + "Get Potion");
  44.         swift.setItem(0, sugar);
  45.         swift.setItem(2, redstone);
  46.         swift.setItem(4, glowstone);
  47.         swift.setItem(6, gunPowder);
  48.         swift.setItem(8, get);
  49.         if (!(event.getWhoClicked() instanceof Player))
  50.             return;
  51.         Inventory inv = event.getInventory();
  52.         if (!(inv.getTitle().equals("Buffs")))
  53.             return;
  54.         Player player = (Player) event.getWhoClicked();
  55.         ItemStack item = event.getCurrentItem();
  56.         if (item.getType() == Material.SUGAR) {
  57.             player.openInventory(swift);
  58.             return;
  59.         }
  60.         event.setCancelled(true);
  61.         player.closeInventory();
  62.     }
  63.     private ItemStack nameItem(ItemStack item, String name) {
  64.     ItemMeta meta = item.getItemMeta();
  65.     meta.setDisplayName(name);
  66.     item.setItemMeta(meta);
  67.     return item;
  68.     }
  69.     private ItemStack nameItem(Material item, String name) {
  70.         return nameItem(new ItemStack(item), name);
  71.     }
  72. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top