Advertisement
DSHunterMC

Untitled

Sep 24th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.57 KB | None | 0 0
  1. package com.hexigonhf.Hexentials;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.logging.Logger;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.GameMode;
  9. import org.bukkit.Material;
  10. import org.bukkit.Sound;
  11. import org.bukkit.command.Command;
  12. import org.bukkit.command.CommandSender;
  13. import org.bukkit.enchantments.Enchantment;
  14. import org.bukkit.entity.Player;
  15. import org.bukkit.event.EventHandler;
  16. import org.bukkit.event.Listener;
  17. import org.bukkit.event.block.Action;
  18. import org.bukkit.event.inventory.InventoryClickEvent;
  19. import org.bukkit.event.player.PlayerInteractEvent;
  20. import org.bukkit.event.player.PlayerJoinEvent;
  21. import org.bukkit.inventory.Inventory;
  22. import org.bukkit.inventory.ItemFlag;
  23. import org.bukkit.inventory.ItemStack;
  24. import org.bukkit.inventory.meta.ItemMeta;
  25. import org.bukkit.plugin.PluginManager;
  26. import org.bukkit.plugin.java.JavaPlugin;
  27.  
  28. public class Main extends JavaPlugin implements Listener {
  29.  
  30. //-------------------- if player kills ---------------------------------------------------------
  31.  
  32. //-------------------- if player kills ---------------------------------------------------------
  33.  
  34.  
  35. // -------------------- Inventories (GUI's) -----------------------
  36. public Inventory agui;
  37. public Inventory rload;
  38. public Inventory stop;
  39.  
  40. // -------------------- Inventories (GUI's) -----------------------
  41.  
  42. //--------------------------------- AGUI Command 1 ----------------------------------
  43. ItemStack Agui = new ItemStack(Material.END_CRYSTAL, 1);{
  44. ItemMeta im = Agui.getItemMeta();
  45. ArrayList<String> al = new ArrayList<String>();
  46. im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  47. im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  48. im.addEnchant(Enchantment.MENDING, 0, false);
  49. im.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI");
  50. al.add(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "The Admin GUI!");
  51. al.add(ChatColor.DARK_AQUA + "Punishments, Tps");
  52. al.add(ChatColor.DARK_AQUA + "WorldSets, and more!");
  53. im.setLore(al);
  54. Agui.setItemMeta(im);}
  55.  
  56.  
  57. ItemStack Plugins = new ItemStack(Material.REDSTONE, 1);{
  58. ItemMeta IM = Plugins.getItemMeta();
  59. ArrayList<String> AL = new ArrayList<String>();
  60. IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  61. IM.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  62. IM.addEnchant(Enchantment.MENDING, 0, true);
  63. IM.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Plugins");
  64. AL.add(ChatColor.GREEN + "" + "Click to see the" );
  65. AL.add(ChatColor.GREEN + "" + ChatColor.UNDERLINE + "servers plugins" );
  66. IM.setLore(AL);
  67. Plugins.setItemMeta(IM);}
  68.  
  69.  
  70. ItemStack gm1 = new ItemStack(Material.ELYTRA, 1);{
  71. ItemMeta iM = gm1.getItemMeta();
  72. ArrayList<String> AL = new ArrayList<String>();
  73. iM.addEnchant(Enchantment.MENDING, 0, false);
  74. iM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  75. iM.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  76. iM.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Creative Mode");
  77. AL.add(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Sets you to gamemode 1!");
  78. iM.setLore(AL);
  79. gm1.setItemMeta(iM);}
  80.  
  81.  
  82. ItemStack gm0 = new ItemStack(Material.ENCHANTMENT_TABLE, 1);{
  83. ItemMeta im = gm0.getItemMeta();
  84. ArrayList<String> al = new ArrayList<String>();
  85. im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  86. im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  87. im.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
  88. im.addEnchant(Enchantment.MENDING, 0, false);
  89. im.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "Survival Mode");
  90. al.add(ChatColor.DARK_GREEN + "" + ChatColor.UNDERLINE + "Sets you to gamemode 0!");
  91. im.setLore(al);
  92. gm0.setItemMeta(im);}
  93.  
  94.  
  95. ItemStack gm3 = new ItemStack(Material.ENDER_PORTAL_FRAME, 1);{
  96. ItemMeta Im = gm3.getItemMeta();
  97. ArrayList<String> Al = new ArrayList<String>();
  98. Im.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Spectator Mode");
  99. Al.add(ChatColor.DARK_GRAY + "" + ChatColor.UNDERLINE + "" + ChatColor.BOLD + "Sets you to gamemode 3!");
  100. Im.setLore(Al);
  101. gm3.setItemMeta(Im);}
  102.  
  103.  
  104. ItemStack reload = new ItemStack(Material.PRISMARINE_SHARD);{
  105. ItemMeta im = reload.getItemMeta();
  106. ArrayList<String> al = new ArrayList<String>();
  107. im.addEnchant(Enchantment.MENDING, 0, false);
  108. im.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  109. im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
  110. im.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Reload");
  111. al.add(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Reloads the server");
  112. al.add(ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "(asks if you are sure)");
  113. im.setLore(al);
  114. reload.setItemMeta(im);}
  115.  
  116. ItemStack STOP = new ItemStack(Material.MAGMA_CREAM);{
  117. ItemMeta IM = STOP.getItemMeta();
  118. ArrayList<String> AL = new ArrayList<String>();
  119. IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  120. IM.setDisplayName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Stop");
  121. AL.add(ChatColor.RED + "" + ChatColor.BOLD + "Stops the server");
  122. AL.add(ChatColor.RED + "" + ChatColor.UNDERLINE + "(asks if you are sure)");
  123. IM.setLore(AL);
  124. STOP.setItemMeta(IM);
  125.  
  126. }
  127.  
  128. ItemStack RUSHURE = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);{
  129. ItemMeta IM = RUSHURE.getItemMeta();
  130. IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  131. IM.setDisplayName(ChatColor.GRAY + "" + ChatColor.BOLD + "Are you sure you want to do this?");
  132. RUSHURE.setItemMeta(IM);}
  133.  
  134. ItemStack accept = new ItemStack(Material.EMERALD_BLOCK);{
  135. ItemMeta IM = accept.getItemMeta();
  136. IM.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  137. IM.setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "Yes, I am sure!");
  138. accept.setItemMeta(IM);}
  139.  
  140. ItemStack deny = new ItemStack(Material.BARRIER);{
  141. ItemMeta M = deny.getItemMeta();
  142. M.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
  143. M.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Go back");
  144. deny.setItemMeta(M);}
  145.  
  146.  
  147. //--------------------------------- AGUI Command 1 ----------------------------------
  148.  
  149. // ------------------------------ onEnable -------------------------------
  150. public void onEnable() {
  151. Logger logger = getLogger();
  152. logger.warning("[HHF-Hexentials] has been enabled!");
  153. PluginManager pm = getServer().getPluginManager();
  154. pm.registerEvents(this, this);
  155. this.getCommand("greet").setExecutor(new greet());
  156. this.getCommand("invg").setExecutor(new InvChest());
  157. this.getCommand("invc").setExecutor(new InvGui(this));
  158. pm.registerEvents(new InvCListener(this), this);
  159.  
  160. // ------------------------------ onEnable -------------------------------
  161. }
  162. //----------------------------- onJoinMessage -----------------------------
  163. @EventHandler
  164. public void onJoin(PlayerJoinEvent e) {
  165. Player p = e.getPlayer();
  166.  
  167. if(p.hasPlayedBefore()) {
  168. e.setJoinMessage(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Hexigon" +
  169. ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF" + ChatColor.AQUA + ">>" +
  170. ChatColor.GRAY + "" + ChatColor.BOLD + " Welcome back " + ChatColor.LIGHT_PURPLE + ChatColor.BOLD +
  171. e.getPlayer().getName() + ChatColor.GRAY + "" + ChatColor.BOLD + " to " + ChatColor.DARK_PURPLE + ChatColor.BOLD + " Hexigon" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF!");}
  172.  
  173. else {
  174. e.setJoinMessage(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Hexigon" +
  175. ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF" + ChatColor.AQUA + ">>" +
  176. ChatColor.GREEN + "" + ChatColor.BOLD + " Welcome " + ChatColor.DARK_GREEN +
  177. "" + ChatColor.BOLD + e.getPlayer().getName() + ChatColor.GREEN + "" + ChatColor.BOLD + " to" +ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + " Hexigon" + ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "HF");
  178. }
  179. }
  180. //----------------------------- onJoinMessage -----------------------------
  181.  
  182. // ----------------------------- Command Center ----------------------------------------------
  183. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args ) {
  184. Player p = (Player) sender;
  185. //--------------------------------- AGUI Command 2 ----------------------------------
  186. if(cmd.getName().equalsIgnoreCase("Agui")) {
  187. if(p.hasPermission("hhf.agui.get")) {
  188. p.getInventory().addItem(new ItemStack(Agui));
  189. p.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "You have been given the " + ChatColor.DARK_AQUA + "ADMIN GUI!");
  190. } else {
  191. p.sendMessage(ChatColor.RED + "You do not have permission to execute this command! -HHF");
  192. }
  193. }
  194.  
  195. //--------------------------------- AGUI Command 2 ----------------------------------
  196. return false;
  197. // ----------------------------- Command Center ----------------------------------------------
  198.  
  199. //------------------------ onDisable ------------------------------
  200. }
  201. public void onDisable() {
  202. Logger logger = getLogger();
  203. logger.warning("[HHF-Hexentials] has been disabled!");
  204. //------------------------ onDisable ------------------------------
  205. }
  206.  
  207. //-------------------------- Stop GUI -----------------------------------------------
  208.  
  209. @EventHandler
  210. public void STOP(PlayerInteractEvent e) {
  211. stop = Bukkit.createInventory(null, 9, ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "Are you sure?");
  212. stop.setItem(0, accept);
  213. stop.setItem(8, deny);
  214. stop.setItem(4, RUSHURE);
  215.  
  216. }
  217. //-------------------------- Stop GUI ------------------------------------------------
  218. @SuppressWarnings("deprecation")
  219. @EventHandler
  220. public void STOP2(InventoryClickEvent e) {
  221. Player p = (Player) e.getWhoClicked();
  222.  
  223. //------------------------------------------ accept stop -----------------------------------------------------
  224. if(e.getInventory().getName().equals(ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "Are you sure?")) {
  225. e.setCancelled(true);
  226.  
  227. if(e.getCurrentItem() == null) {
  228. return;
  229. }
  230.  
  231. if(e.getCurrentItem().getType() == Material.EMERALD_BLOCK) {
  232. p.performCommand("stop");
  233. p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1.0f, 1.0f);
  234. p.closeInventory();
  235. p.getInventory().remove(accept);
  236. p.updateInventory();
  237. //------------------------------------------ accept stop -----------------------------------------------------
  238. }
  239. //------------------------------------------- deny stop ------------------------------------------------------
  240.  
  241. if(e.getInventory().getName().equals(ChatColor.DARK_RED + "" + ChatColor.UNDERLINE + "Are you sure?")) {
  242. e.setCancelled(true);
  243.  
  244. if(e.getCurrentItem() == null) {
  245. return;
  246. }
  247.  
  248. if(e.getCurrentItem().getType() == Material.BARRIER) {
  249. p.openInventory(agui);
  250. p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BREAK, 1.0f, 1.0f);
  251.  
  252. }
  253.  
  254. }
  255.  
  256.  
  257. //------------------------------------------- deny stop ------------------------------------------------------
  258. }
  259.  
  260. }
  261.  
  262. //-------------------------- Stop GUI ------------------------------------------------
  263.  
  264. // ------------------------- Agui GUI -----------------------------
  265.  
  266. @EventHandler
  267. public void Reload(PlayerInteractEvent e) {
  268. rload = Bukkit.createInventory(null, 9, ChatColor.RED + "" + ChatColor.UNDERLINE + "Are you sure?");
  269. rload.setItem(4, RUSHURE);
  270. rload.setItem(0, accept);
  271. rload.setItem(8, deny);
  272.  
  273. }
  274.  
  275. @SuppressWarnings("deprecation")
  276. @EventHandler
  277. public void Reload2(InventoryClickEvent e) {
  278. Player p = (Player) e.getWhoClicked();
  279.  
  280. //-------------------------------- Reload ------------------------------------------------
  281.  
  282. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.UNDERLINE + "Are you sure?")) {
  283. e.setCancelled(true);
  284.  
  285. if(e.getCurrentItem() == null) {
  286. return;
  287. }
  288.  
  289. if(e.getCurrentItem().getType() == Material.EMERALD_BLOCK) {
  290. p.performCommand("reload");
  291. p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1.0f, 1.0f);
  292. p.closeInventory();
  293. p.getInventory().remove(accept);
  294. p.updateInventory();
  295.  
  296.  
  297. }
  298.  
  299.  
  300.  
  301.  
  302. //-------------------------------- Reload ------------------------------------------------
  303.  
  304. // ------------------------------- reload button ------------------------------------------
  305.  
  306. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
  307.  
  308. if(e.getCurrentItem() == null) {
  309. return;
  310.  
  311. }
  312.  
  313. if(e.getCurrentItem().getType() == Material.PRISMARINE_SHARD) {
  314. }
  315.  
  316.  
  317. }
  318. // ------------------------------- reload button ------------------------------------------
  319.  
  320. // ------------------------------- go back button -----------------------------------------
  321.  
  322. if(e.getInventory().getName().equals(rload.getName())) {
  323.  
  324. if(e.getCurrentItem() == null) {
  325. return;
  326. }
  327.  
  328. if(e.getCurrentItem().getType() == Material.BARRIER) {
  329. p.openInventory(agui);
  330. p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BREAK, 1.0f, 1.0f);
  331.  
  332. }
  333. }
  334. }
  335. }
  336.  
  337. // ------------------------------- go back button -----------------------------------------
  338.  
  339.  
  340. @SuppressWarnings("deprecation")
  341. @EventHandler
  342. public void AGUI(PlayerInteractEvent e ) {
  343. Player p = e.getPlayer();
  344. // GUI! V---
  345. agui = Bukkit.createInventory(null, 54, ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!");
  346. agui.setItem(0, Plugins);
  347. agui.setItem(40, gm1);
  348. agui.setItem(37, gm0);
  349. agui.setItem(43, gm3);
  350. agui.setItem(45, reload);
  351. agui.setItem(53, STOP);
  352. if(p.hasPermission("hhf.agui.open")) {
  353. if(p.getInventory().getItemInHand().getType() == Material.END_CRYSTAL) {
  354. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
  355. p.openInventory(agui);
  356. }
  357. }
  358.  
  359. }
  360.  
  361.  
  362. // ------------------------- Agui GUI -----------------------------
  363. }
  364. //----------------------------- Execute Commands for Agui buttons -------------------------------------
  365. @EventHandler
  366. public void AGUI2(InventoryClickEvent e) {
  367. Player p = (Player) e.getWhoClicked();
  368.  
  369. // --------------------------- Plugins button -----------------------------------------
  370. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
  371. e.setCancelled(true);
  372.  
  373. if(e.getCurrentItem() == null) {
  374. return;
  375. }
  376.  
  377. if(e.getCurrentItem().getType() == Material.REDSTONE) {
  378. p.performCommand("plugins");
  379. p.closeInventory();
  380. p.playSound(p.getLocation(), Sound.ENTITY_ARMORSTAND_PLACE, 1.0f, 1.0f);
  381. }
  382. // --------------------------- Plugins button -----------------------------------------
  383.  
  384. // ------------------------------- Gamemode 1 button -----------------------------------
  385. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
  386.  
  387. if(e.getCurrentItem() == null) {
  388. return;
  389.  
  390. }
  391.  
  392. if(e.getCurrentItem().getType() == Material.ELYTRA) {
  393. p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Gamemode set to " + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Gamemode 1!");
  394. p.setGameMode(GameMode.CREATIVE);
  395. p.closeInventory();
  396. p.playSound(p.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 1.0f, 1.0f);
  397.  
  398. }
  399. // ------------------------------- Gamemode 1 button -----------------------------------
  400.  
  401. // ------------------------------- Gamemode 0 button --------------------------------------
  402.  
  403. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
  404. e.setCancelled(true);
  405.  
  406. if(e.getCurrentItem() == null) {
  407. return;
  408.  
  409. }
  410.  
  411. if(e.getCurrentItem().getType() == Material.ENCHANTMENT_TABLE) {
  412. p.setGameMode(GameMode.SURVIVAL);
  413. p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Gamemode set to " + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Gamemode 0!");
  414. p.closeInventory();
  415. p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_PLACE, 1.0f, 1.0f);
  416.  
  417. }
  418. }
  419.  
  420.  
  421. // ------------------------------- Gamemode 0 button --------------------------------------
  422.  
  423. // ------------------------------- Gamemode 3 button --------------------------------------
  424.  
  425. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!")) {
  426. e.setCancelled(true);
  427.  
  428. if(e.getCurrentItem() == null) {
  429. return;
  430.  
  431. }
  432.  
  433. if(e.getCurrentItem().getType() == Material.ENDER_PORTAL_FRAME) {
  434. p.setGameMode(GameMode.SPECTATOR);
  435. p.sendMessage(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Gamemode set to " + ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Gamemode 3!");
  436. p.closeInventory();
  437. p.playSound(p.getLocation(), Sound.ENTITY_ITEMFRAME_BREAK, 1.0f, 1.0f);
  438.  
  439. }
  440. }
  441.  
  442.  
  443. }
  444.  
  445. }
  446. // ------------------------------- Gamemode 3 button --------------------------------------
  447.  
  448.  
  449. //----------------------------- Execute Commands for Agui buttons -------------------------------------
  450.  
  451. }
  452.  
  453. // ---------------------------------- reload and stop slots ------------------------------------------------------
  454. @EventHandler
  455. public void onClick(InventoryClickEvent e) {
  456.  
  457. Player p = (Player) e.getWhoClicked();
  458.  
  459. if(e.getInventory().getTitle().equals("agui"));
  460. if(e.getInventory().getName().equals(ChatColor.RED + "" + ChatColor.BOLD + "Admin GUI!"))
  461.  
  462. if(e.getSlot() == 45) {
  463.  
  464. p.openInventory(rload);
  465. p.playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1.0f, 1.0f);
  466.  
  467. } else if (e.getSlot() == 53) {
  468. p.openInventory(stop);
  469. p.playSound(p.getLocation(), Sound.ITEM_BUCKET_EMPTY_LAVA, 1.0f, 1.0f);
  470.  
  471. }
  472. }
  473. }
  474.  
  475.  
  476. // ---------------------------------- reload and stop slots ------------------------------------------------------
  477.  
  478.  
  479. // ------------------------- Agui GUI's -----------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement