Advertisement
Guest User

Menu.java

a guest
Aug 3rd, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.79 KB | None | 0 0
  1. package Piano;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.DyeColor;
  6. import org.bukkit.Sound;
  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.material.Wool;
  15. import org.bukkit.plugin.Plugin;
  16.  
  17. public class Menu implements Listener {
  18.  
  19. private Inventory inv;
  20. private ItemStack a;
  21. private ItemStack b;
  22. private ItemStack c;
  23. private ItemStack d;
  24. private ItemStack e;
  25. private ItemStack f;
  26. private ItemStack g;
  27. private ItemStack h;
  28. private ItemStack i;
  29. private ItemStack j;
  30. private ItemStack k;
  31. private ItemStack l;
  32. private ItemStack m;
  33. private ItemStack n;
  34. private ItemStack o;
  35. private ItemStack p2;
  36. private ItemStack q;
  37. private ItemStack r;
  38. private ItemStack s;
  39. private ItemStack t;
  40. private ItemStack u;
  41. private ItemStack v;
  42. private ItemStack w;
  43. private ItemStack x;
  44. private ItemStack y;
  45. private ItemStack z;
  46.  
  47. public Menu(Plugin p) {
  48. inv = Bukkit.getServer().createInventory(null, 54, "Piano");
  49.  
  50. a = createItem(DyeColor.BLACK, ChatColor.GRAY + "F# O0");
  51. b = createItem(DyeColor.WHITE, ChatColor.WHITE + "G O0");
  52. c = createItem(DyeColor.BLACK, ChatColor.GRAY + "G# O0");
  53. d = createItem(DyeColor.WHITE, ChatColor.WHITE + "A O0");
  54. e = createItem(DyeColor.BLACK, ChatColor.GRAY + "A# O0");
  55. f = createItem(DyeColor.WHITE, ChatColor.WHITE + "B O0");
  56. g = createItem(DyeColor.WHITE, ChatColor.WHITE + "C O0");
  57. h = createItem(DyeColor.BLACK, ChatColor.GRAY + "C# O0");
  58. i = createItem(DyeColor.WHITE, ChatColor.WHITE + "D O0");
  59. j = createItem(DyeColor.BLACK, ChatColor.GRAY + "D# O0");
  60. k = createItem(DyeColor.WHITE, ChatColor.WHITE + "E O0");
  61. l = createItem(DyeColor.WHITE, ChatColor.WHITE + "F O0");
  62. m = createItem(DyeColor.BLACK, ChatColor.GRAY + "F# O1");
  63. n = createItem(DyeColor.WHITE, ChatColor.WHITE + "G O1");
  64. o = createItem(DyeColor.BLACK, ChatColor.GRAY + "G# O1");
  65. p2 = createItem(DyeColor.WHITE, ChatColor.WHITE + "A O1");
  66. q = createItem(DyeColor.BLACK, ChatColor.GRAY + "A# O1");
  67. r = createItem(DyeColor.WHITE, ChatColor.WHITE + "B O1");
  68. s = createItem(DyeColor.WHITE, ChatColor.WHITE + "C O1");
  69. t = createItem(DyeColor.BLACK, ChatColor.GRAY + "C# O1");
  70. u = createItem(DyeColor.WHITE, ChatColor.WHITE + "D O1");
  71. v = createItem(DyeColor.BLACK, ChatColor.GRAY + "D# O1");
  72. w = createItem(DyeColor.WHITE, ChatColor.WHITE + "E O1");
  73. x = createItem(DyeColor.WHITE, ChatColor.WHITE + "F O1");
  74. y = createItem(DyeColor.BLACK, ChatColor.GRAY + "F# O2");
  75. z = createItem(DyeColor.RED, ChatColor.RED + "Exit");
  76. inv.setItem(0, a);
  77. inv.setItem(1, b);
  78. inv.setItem(2, c);
  79. inv.setItem(3, d);
  80. inv.setItem(4, e);
  81. inv.setItem(5, f);
  82. inv.setItem(6, g);
  83. inv.setItem(7, h);
  84. inv.setItem(8, i);
  85. inv.setItem(9, j);
  86. inv.setItem(10, k);
  87. inv.setItem(11, l);
  88. inv.setItem(12, m);
  89. inv.setItem(13, n);
  90. inv.setItem(14, o);
  91. inv.setItem(15, p2);
  92. inv.setItem(16, q);
  93. inv.setItem(17, r);
  94. inv.setItem(18, s);
  95. inv.setItem(19, t);
  96. inv.setItem(20, u);
  97. inv.setItem(21, v);
  98. inv.setItem(22, w);
  99. inv.setItem(23, x);
  100. inv.setItem(24, y);
  101. inv.setItem(53, z);
  102. Bukkit.getServer().getPluginManager().registerEvents(this, p);
  103. }
  104.  
  105. private ItemStack createItem(DyeColor dc, String name) {
  106. ItemStack i = new Wool(dc).toItemStack(1);
  107. ItemMeta im = i.getItemMeta();
  108. im.setDisplayName(name);
  109. i.setItemMeta(im);
  110. return i;
  111. }
  112.  
  113. public void show(Player p) {
  114. p.openInventory(inv);
  115. }
  116.  
  117. @EventHandler
  118. public void onInventoryClick(InventoryClickEvent e) {
  119. if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
  120. if (e.getCurrentItem().getItemMeta() == null) return;
  121. if (e.getCurrentItem().getItemMeta().getDisplayName().contains("F# O0")) {
  122. e.setCancelled(true);
  123. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.500f);
  124. }
  125. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("G O0")) {
  126. e.setCancelled(true);
  127. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.525f);
  128. }
  129.  
  130. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("G# O0")) {
  131. e.setCancelled(true);
  132. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.550f);
  133.  
  134.  
  135. }
  136.  
  137.  
  138. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("A O0")) {
  139. e.setCancelled(true);
  140. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.600f);
  141.  
  142.  
  143.  
  144. }
  145. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("A# O0")) {
  146. e.setCancelled(true);
  147. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.650f);
  148.  
  149.  
  150.  
  151. }
  152. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("B O0")) {
  153. e.setCancelled(true);
  154. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.675f);
  155.  
  156.  
  157.  
  158. }
  159. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("C O0")) {
  160. e.setCancelled(true);
  161. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.700f);
  162.  
  163.  
  164.  
  165. }
  166. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("C# O0")) {
  167. e.setCancelled(true);
  168. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.750f);
  169.  
  170.  
  171.  
  172. }
  173. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("D O0")) {
  174. e.setCancelled(true);
  175. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.800f);
  176.  
  177.  
  178.  
  179. }
  180. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("D# O0")) {
  181. e.setCancelled(true);
  182. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.850f);
  183.  
  184.  
  185.  
  186. }
  187. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("E O0")) {
  188. e.setCancelled(true);
  189. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.900f);
  190.  
  191.  
  192.  
  193. }
  194. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("F O0")) {
  195. e.setCancelled(true);
  196. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 0.950f);
  197.  
  198.  
  199.  
  200. }
  201. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("F# O1")) {
  202. e.setCancelled(true);
  203. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1f);
  204.  
  205.  
  206.  
  207. }
  208. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("G O1")) {
  209. e.setCancelled(true);
  210. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.050f);
  211.  
  212.  
  213.  
  214. }
  215. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("G# O1")) {
  216. e.setCancelled(true);
  217. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.100f);
  218.  
  219.  
  220.  
  221. }
  222. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("A O1")) {
  223. e.setCancelled(true);
  224. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.200f);
  225.  
  226.  
  227.  
  228. }
  229. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("A# O1")) {
  230. e.setCancelled(true);
  231. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.250f);
  232.  
  233.  
  234.  
  235. }
  236. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("B O1")) {
  237. e.setCancelled(true);
  238. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.350f);
  239.  
  240.  
  241.  
  242. }
  243. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("C O1")) {
  244. e.setCancelled(true);
  245. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.400f);
  246.  
  247.  
  248.  
  249. }
  250. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("C# O1")) {
  251. e.setCancelled(true);
  252. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.450f);
  253.  
  254.  
  255.  
  256. }
  257. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("D O1")) {
  258. e.setCancelled(true);
  259. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.600f);
  260.  
  261.  
  262.  
  263. }
  264. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("D# O1")) {
  265. e.setCancelled(true);
  266. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.700f);
  267.  
  268.  
  269.  
  270. }
  271. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("E O1")) {
  272. e.setCancelled(true);
  273. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.750f);
  274.  
  275.  
  276.  
  277. }
  278. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("F O1")) {
  279. e.setCancelled(true);
  280. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 1.900f);
  281.  
  282.  
  283.  
  284. }
  285. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains("F# O2")) {
  286. e.setCancelled(true);
  287. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.NOTE_PIANO, 1, 2.00f);
  288.  
  289.  
  290.  
  291. }
  292. else if (e.getCurrentItem().getItemMeta().getDisplayName().contains(ChatColor.RED + "Exit")) {
  293. e.setCancelled(true);
  294. e.getWhoClicked().getLocation().getWorld().playSound(e.getWhoClicked().getLocation(), Sound.GHAST_SCREAM, 1, 1);
  295. e.getWhoClicked().closeInventory();
  296.  
  297.  
  298. }
  299. }
  300. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement