Guest User

Untitled

a guest
May 15th, 2015
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.BukkitCodes.BVG;
  2.  
  3. import me.confuser.barapi.BarAPI;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Material;
  7. import org.bukkit.Server;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.configuration.file.FileConfiguration;
  11. import org.bukkit.configuration.file.FileConfigurationOptions;
  12. import org.bukkit.entity.Player;
  13. import org.bukkit.event.EventHandler;
  14. import org.bukkit.event.Listener;
  15. import org.bukkit.event.inventory.InventoryClickEvent;
  16. import org.bukkit.inventory.Inventory;
  17. import org.bukkit.inventory.ItemStack;
  18. import org.bukkit.inventory.meta.ItemMeta;
  19. import org.bukkit.plugin.PluginManager;
  20. import org.bukkit.plugin.java.JavaPlugin;
  21. import org.bukkit.scheduler.BukkitScheduler;
  22.  
  23. public class VoteGUI
  24. extends JavaPlugin
  25. implements Listener
  26. {
  27. public void onEnable()
  28. {
  29. getConfig().options().copyDefaults(true);
  30. saveConfig();
  31. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  32. }
  33.  
  34. public static Inventory myInventory = Bukkit.createInventory(null, 27, "Vote For Our Server!");
  35.  
  36. static
  37. {
  38. ItemStack vote1 = new ItemStack(Material.DIAMOND_BLOCK, 1);
  39. ItemMeta vote1meta = vote1.getItemMeta();
  40. vote1meta.setDisplayName(ChatColor.AQUA + "Vote For Us!");
  41. vote1.setItemMeta(vote1meta);
  42. myInventory.setItem(0, vote1);
  43. ItemStack vote2 = new ItemStack(Material.EMERALD_BLOCK, 1);
  44. ItemMeta vote2meta = vote2.getItemMeta();
  45. vote2meta.setDisplayName(ChatColor.GREEN + "Vote For Us!");
  46. vote2.setItemMeta(vote2meta);
  47. myInventory.setItem(1, vote2);
  48. ItemStack vote3 = new ItemStack(Material.GOLD_BLOCK, 1);
  49. ItemMeta vote3meta = vote3.getItemMeta();
  50. vote3meta.setDisplayName(ChatColor.GOLD + "Vote For Us!");
  51. vote3.setItemMeta(vote3meta);
  52. myInventory.setItem(2, vote3);
  53. ItemStack vote4 = new ItemStack(Material.IRON_BLOCK, 1);
  54. ItemMeta vote4meta = vote4.getItemMeta();
  55. vote4meta.setDisplayName(ChatColor.GRAY + "Vote For Us!");
  56. vote4.setItemMeta(vote4meta);
  57. myInventory.setItem(3, vote4);
  58. ItemStack vote5 = new ItemStack(Material.REDSTONE_BLOCK, 1);
  59. ItemMeta vote5meta = vote5.getItemMeta();
  60. vote5meta.setDisplayName(ChatColor.RED + "Vote For Us!");
  61. vote5.setItemMeta(vote5meta);
  62. myInventory.setItem(4, vote5);
  63. ItemStack vote6 = new ItemStack(Material.COAL_BLOCK, 1);
  64. ItemMeta vote6meta = vote6.getItemMeta();
  65. vote6meta.setDisplayName(ChatColor.BLACK + "Vote For Us!");
  66. vote6.setItemMeta(vote6meta);
  67. myInventory.setItem(5, vote6);
  68. ItemStack vote7 = new ItemStack(Material.TNT, 1);
  69. ItemMeta vote7meta = vote7.getItemMeta();
  70. vote7meta.setDisplayName(ChatColor.DARK_RED + "Vote For Us!");
  71. vote7.setItemMeta(vote7meta);
  72. myInventory.setItem(6, vote7);
  73. ItemStack vote8 = new ItemStack(Material.NOTE_BLOCK, 1);
  74. ItemMeta vote8meta = vote8.getItemMeta();
  75. vote8meta.setDisplayName(ChatColor.DARK_GRAY + "Vote For Us!");
  76. vote8.setItemMeta(vote8meta);
  77. myInventory.setItem(7, vote8);
  78. ItemStack vote9 = new ItemStack(Material.BEACON, 1);
  79. ItemMeta vote9meta = vote9.getItemMeta();
  80. vote9meta.setDisplayName(ChatColor.BLUE + "Vote For Us!");
  81. vote9.setItemMeta(vote9meta);
  82. myInventory.setItem(8, vote9);
  83. ItemStack vote99 = new ItemStack(Material.EMERALD, 1);
  84. ItemMeta vote99meta = vote99.getItemMeta();
  85. vote99meta.setDisplayName(ChatColor.GREEN + "All Vote Links!");
  86. vote99.setItemMeta(vote99meta);
  87. myInventory.setItem(22, vote99);
  88. }
  89.  
  90. @EventHandler
  91. public void onInventoryClick(InventoryClickEvent event)
  92. {
  93. Player player = (Player)event.getWhoClicked();
  94. ItemStack clicked = event.getCurrentItem();
  95. Inventory inventory = event.getInventory();
  96. if ((inventory.getName().equals(myInventory.getName())) &&
  97. (clicked.getType() == Material.DIAMOND_BLOCK))
  98. {
  99. event.setCancelled(true);
  100. player.closeInventory();
  101. player.sendMessage(getConfig().getString("vote1").replaceAll("&", "§"));
  102. }
  103. }
  104.  
  105. @EventHandler
  106. public void onInventoryClick1(InventoryClickEvent event)
  107. {
  108. Player player = (Player)event.getWhoClicked();
  109. ItemStack clicked = event.getCurrentItem();
  110. Inventory inventory = event.getInventory();
  111. if ((inventory.getName().equals(myInventory.getName())) &&
  112. (clicked.getType() == Material.EMERALD_BLOCK))
  113. {
  114. event.setCancelled(true);
  115. player.closeInventory();
  116. player.sendMessage(getConfig().getString("vote2").replaceAll("&", "§"));
  117. }
  118. }
  119.  
  120. @EventHandler
  121. public void onInventoryClick2(InventoryClickEvent event)
  122. {
  123. Player player = (Player)event.getWhoClicked();
  124. ItemStack clicked = event.getCurrentItem();
  125. Inventory inventory = event.getInventory();
  126. if ((inventory.getName().equals(myInventory.getName())) &&
  127. (clicked.getType() == Material.GOLD_BLOCK))
  128. {
  129. event.setCancelled(true);
  130. player.closeInventory();
  131. player.sendMessage(getConfig().getString("vote3").replaceAll("&", "§"));
  132. }
  133. }
  134.  
  135. @EventHandler
  136. public void onInventoryClick3(InventoryClickEvent event)
  137. {
  138. Player player = (Player)event.getWhoClicked();
  139. ItemStack clicked = event.getCurrentItem();
  140. Inventory inventory = event.getInventory();
  141. if ((inventory.getName().equals(myInventory.getName())) &&
  142. (clicked.getType() == Material.IRON_BLOCK))
  143. {
  144. event.setCancelled(true);
  145. player.closeInventory();
  146. player.sendMessage(getConfig().getString("vote4").replaceAll("&", "§"));
  147. }
  148. }
  149.  
  150. @EventHandler
  151. public void onInventoryClick4(InventoryClickEvent event)
  152. {
  153. Player player = (Player)event.getWhoClicked();
  154. ItemStack clicked = event.getCurrentItem();
  155. Inventory inventory = event.getInventory();
  156. if ((inventory.getName().equals(myInventory.getName())) &&
  157. (clicked.getType() == Material.REDSTONE_BLOCK))
  158. {
  159. event.setCancelled(true);
  160. player.closeInventory();
  161. player.sendMessage(getConfig().getString("vote5").replaceAll("&", "§"));
  162. }
  163. }
  164.  
  165. @EventHandler
  166. public void onInventoryClick5(InventoryClickEvent event)
  167. {
  168. Player player = (Player)event.getWhoClicked();
  169. ItemStack clicked = event.getCurrentItem();
  170. Inventory inventory = event.getInventory();
  171. if ((inventory.getName().equals(myInventory.getName())) &&
  172. (clicked.getType() == Material.COAL_BLOCK))
  173. {
  174. event.setCancelled(true);
  175. player.closeInventory();
  176. player.sendMessage(getConfig().getString("vote6").replaceAll("&", "§"));
  177. }
  178. }
  179.  
  180. @EventHandler
  181. public void onInventoryClick6(InventoryClickEvent event)
  182. {
  183. Player player = (Player)event.getWhoClicked();
  184. ItemStack clicked = event.getCurrentItem();
  185. Inventory inventory = event.getInventory();
  186. if ((inventory.getName().equals(myInventory.getName())) &&
  187. (clicked.getType() == Material.TNT))
  188. {
  189. event.setCancelled(true);
  190. player.closeInventory();
  191. player.sendMessage(getConfig().getString("vote7").replaceAll("&", "§"));
  192. }
  193. }
  194.  
  195. @EventHandler
  196. public void onInventoryClick7(InventoryClickEvent event)
  197. {
  198. Player player = (Player)event.getWhoClicked();
  199. ItemStack clicked = event.getCurrentItem();
  200. Inventory inventory = event.getInventory();
  201. if ((inventory.getName().equals(myInventory.getName())) &&
  202. (clicked.getType() == Material.NOTE_BLOCK))
  203. {
  204. event.setCancelled(true);
  205. player.closeInventory();
  206. player.sendMessage(getConfig().getString("vote8").replaceAll("&", "§"));
  207. }
  208. }
  209.  
  210. @EventHandler
  211. public void onInventoryClick8(InventoryClickEvent event)
  212. {
  213. Player player = (Player)event.getWhoClicked();
  214. ItemStack clicked = event.getCurrentItem();
  215. Inventory inventory = event.getInventory();
  216. if ((inventory.getName().equals(myInventory.getName())) &&
  217. (clicked.getType() == Material.BEACON))
  218. {
  219. event.setCancelled(true);
  220. player.closeInventory();
  221. player.sendMessage(getConfig().getString("vote9").replaceAll("&", "§"));
  222. }
  223. }
  224.  
  225. @EventHandler
  226. public void onInventoryClick9(InventoryClickEvent event)
  227. {
  228. Player player = (Player)event.getWhoClicked();
  229. ItemStack clicked = event.getCurrentItem();
  230. Inventory inventory = event.getInventory();
  231. if ((inventory.getName().equals(myInventory.getName())) &&
  232. (clicked.getType() == Material.EMERALD))
  233. {
  234. event.setCancelled(true);
  235. player.closeInventory();
  236. player.sendMessage(getConfig().getString("alllinks").replaceAll("&", "§"));
  237. player.sendMessage(getConfig().getString("vote1").replaceAll("&", "§"));
  238. player.sendMessage(getConfig().getString("vote2").replaceAll("&", "§"));
  239. player.sendMessage(getConfig().getString("vote3").replaceAll("&", "§"));
  240. player.sendMessage(getConfig().getString("vote4").replaceAll("&", "§"));
  241. player.sendMessage(getConfig().getString("vote5").replaceAll("&", "§"));
  242. player.sendMessage(getConfig().getString("vote6").replaceAll("&", "§"));
  243. player.sendMessage(getConfig().getString("vote7").replaceAll("&", "§"));
  244. player.sendMessage(getConfig().getString("vote8").replaceAll("&", "§"));
  245. player.sendMessage(getConfig().getString("vote9").replaceAll("&", "§"));
  246. }
  247. }
  248.  
  249. public boolean onCommand(final CommandSender sender, Command cmd, String label, String[] args)
  250. {
  251. Player player = (Player)sender;
  252. if (cmd.getName().equalsIgnoreCase("vote")) {
  253. if (player.hasPermission("bvg.vote"))
  254. {
  255. BarAPI.setMessage(player, getConfig().getString("bossbar").replaceAll("&", "§"), 100.0F);
  256. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  257. {
  258. public void run()
  259. {
  260. Player player = (Player)sender;
  261. BarAPI.setHealth(player, 90.0F);
  262. }
  263. }, 4L);
  264. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  265. {
  266. public void run()
  267. {
  268. Player player = (Player)sender;
  269. BarAPI.setHealth(player, 80.0F);
  270. }
  271. }, 8L);
  272. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  273. {
  274. public void run()
  275. {
  276. Player player = (Player)sender;
  277. BarAPI.setHealth(player, 70.0F);
  278. }
  279. }, 12L);
  280. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  281. {
  282. public void run()
  283. {
  284. Player player = (Player)sender;
  285. BarAPI.setHealth(player, 60.0F);
  286. }
  287. }, 16L);
  288. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  289. {
  290. public void run()
  291. {
  292. Player player = (Player)sender;
  293. BarAPI.setHealth(player, 50.0F);
  294. }
  295. }, 20L);
  296. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  297. {
  298. public void run()
  299. {
  300. Player player = (Player)sender;
  301. BarAPI.setHealth(player, 40.0F);
  302. }
  303. }, 24L);
  304. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  305. {
  306. public void run()
  307. {
  308. Player player = (Player)sender;
  309. BarAPI.setHealth(player, 30.0F);
  310. }
  311. }, 28L);
  312. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  313. {
  314. public void run()
  315. {
  316. Player player = (Player)sender;
  317. BarAPI.setHealth(player, 20.0F);
  318. }
  319. }, 32L);
  320. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  321. {
  322. public void run()
  323. {
  324. Player player = (Player)sender;
  325. BarAPI.setHealth(player, 10.0F);
  326. }
  327. }, 36L);
  328. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  329. {
  330. public void run()
  331. {
  332. Player player = (Player)sender;
  333. BarAPI.setHealth(player, 0.0F);
  334. }
  335. }, 40L);
  336. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
  337. {
  338. public void run()
  339. {
  340. Player player = (Player)sender;
  341. BarAPI.removeBar(player);
  342. player.openInventory(VoteGUI.myInventory);
  343. }
  344. }, 41L);
  345. }
  346. else
  347. {
  348. player.sendMessage(ChatColor.RED + "No Permission.");
  349. }
  350. }
  351. return true;
  352. }
  353. }
RAW Paste Data