Guest User

LoadoutGUI

a guest
May 28th, 2018
86
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.uba;
  2.  
  3. import java.util.ArrayList;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Material;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.Listener;
  10. import org.bukkit.event.inventory.InventoryClickEvent;
  11. import org.bukkit.inventory.Inventory;
  12. import org.bukkit.inventory.ItemStack;
  13. import org.bukkit.inventory.meta.ItemMeta;
  14. import org.bukkit.plugin.Plugin;
  15.  
  16. public class loadoutgui implements Listener {
  17.  
  18. main main = me.uba.main.getInstance();
  19.  
  20. loadouts loadouts = me.uba.loadouts.getInstance();
  21.  
  22. private Inventory inv;
  23.  
  24. public loadoutgui(Plugin p) {
  25. inv = Bukkit.getServer().createInventory(null, 9, "Loadout Editor");
  26.  
  27. ItemStack item = new ItemStack(Material.EYE_OF_ENDER);
  28. ItemMeta meta = item.getItemMeta();
  29. meta.setDisplayName(ChatColor.BLUE+ "Save Loadout");
  30. ArrayList<String> Lore = new ArrayList<String>();
  31. Lore.add("Saves your inventory to your loadout!");
  32. meta.setLore(Lore);
  33. item.setItemMeta(meta);
  34.  
  35. ItemStack item2 = new ItemStack(Material.DIAMOND_HELMET);
  36. ItemMeta meta2 = item2.getItemMeta();
  37. meta2.setDisplayName(ChatColor.GREEN+ "Close");
  38. ArrayList<String> Lore2 = new ArrayList<String>();
  39. Lore2.add("Gives you your set loadout!");
  40. meta2.setLore(Lore2);
  41. item2.setItemMeta(meta2);
  42.  
  43. ItemStack item3 = new ItemStack(Material.CHEST);
  44. ItemMeta meta3 = item3.getItemMeta();
  45. meta3.setDisplayName(ChatColor.GOLD+ "Get Loadout");
  46. ArrayList<String> Lore3 = new ArrayList<String>();
  47. Lore3.add("Gives you youre loadout!");
  48. meta3.setLore(Lore3);
  49. item3.setItemMeta(meta3);
  50.  
  51. inv.setItem(4, item);
  52. inv.setItem(5, item2);
  53. inv.setItem(6, item3);
  54.  
  55. Bukkit.getServer().getPluginManager().registerEvents(this, p);
  56. }
  57.  
  58. public void openLoadout(Player p) {
  59. p.openInventory(inv);
  60. }
  61.  
  62. @EventHandler
  63. public void onInventoryClick(InventoryClickEvent e) {
  64. Player p = (Player) e.getWhoClicked();
  65. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
  66. if (e.getCurrentItem().getItemMeta() == null) return;
  67. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Save Loadout")) {
  68. e.setCancelled(true);
  69. loadouts.saveLoadout(p);
  70. e.getWhoClicked().closeInventory();
  71. }
  72. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Close")) {
  73. e.setCancelled(true);
  74. e.getWhoClicked().closeInventory();
  75. }
  76. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Get Loadout")) {
  77. e.setCancelled(true);
  78. loadouts.restoreLoadout(p);
  79. e.getWhoClicked().closeInventory();
  80. }
  81. }
  82. }
RAW Paste Data