Advertisement
Guest User

Menu 1

a guest
Jun 5th, 2018
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None
  1. package ts.uba; //The package your class is located it
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Bukkit; //Importing types (You already know this)
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.inventory.InventoryClickEvent;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.inventory.meta.ItemMeta;
  14. import org.bukkit.plugin.Plugin;
  15.  
  16. public class CraftingSelection implements Listener { //Inventory = the name of this class)
  17.  
  18. private org.bukkit.inventory.Inventory inv; //Settings inventory to inv
  19.  
  20. private Craft menu;
  21.  
  22. public CraftingSelection(Plugin p) {
  23. inv = Bukkit.getServer().createInventory(null, 9, "§c§lCrafting Menu"); //settings the inventory name
  24.  
  25. ItemStack Rifle = new ItemStack(Material.RECORD_3);
  26. ItemMeta RifleMeta = Rifle.getItemMeta();
  27. RifleMeta.setDisplayName(ChatColor.AQUA + "Energy Rifle");
  28. ArrayList<String> lore = new ArrayList<String>();
  29. lore.add(ChatColor.GOLD + "Craft Stages");
  30. lore.add(ChatColor.GREEN + "Trigger -> Fuse -> Rifle Body -> Energy Rifle");
  31. RifleMeta.setLore(lore);
  32. Rifle.setItemMeta(RifleMeta);
  33.  
  34. ItemStack Close = new ItemStack(Material.BARRIER);
  35. ItemMeta meta3 = Close.getItemMeta();
  36. meta3.setDisplayName(ChatColor.RED + "Close");
  37. Close.setItemMeta(meta3);
  38.  
  39. inv.setItem(3, Rifle);
  40. inv.setItem(0, Close);
  41.  
  42. Bukkit.getServer().getPluginManager().registerEvents(this, p);
  43.  
  44. }
  45.  
  46. public void showmenu(Player p) {
  47. p.openInventory(inv);
  48.  
  49. }
  50.  
  51. @EventHandler
  52. public void onInventoryClick1(InventoryClickEvent e) {
  53. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
  54. if (e.getCurrentItem().getItemMeta() == null) return;
  55. if (e.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.AQUA + "Energy Rifle")) {
  56. e.setCancelled(true);
  57. Player p = (Player) e.getWhoClicked();
  58. menu.showmenu(p);
  59. p.closeInventory();
  60.  
  61.  
  62. }
  63. }
  64. @EventHandler
  65. public void onInventoryClick2(InventoryClickEvent e) {
  66. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
  67. if (e.getCurrentItem().getItemMeta() == null) return;
  68. if (e.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.RED + "Close")) {
  69. e.setCancelled(true);
  70. e.getWhoClicked().closeInventory();
  71.  
  72. }
  73. }
  74. }
Advertisement
RAW Paste Data Copied
Advertisement