DSHunterMC

Untitled

Nov 26th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. package ItemStacksAndInventories;
  2.  
  3.  
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.Material;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandExecutor;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.block.Action;
  14. import org.bukkit.event.inventory.InventoryClickEvent;
  15. import org.bukkit.event.player.PlayerInteractEvent;
  16. import org.bukkit.inventory.Inventory;
  17.  
  18.  
  19.  
  20.  
  21. public class AdminGUI extends AdminGuiItemStacks implements CommandExecutor,Listener {
  22.  
  23. public Inventory agui;
  24.  
  25.  
  26. @Override
  27. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  28. Player p = (Player) sender;
  29.  
  30. // --------------------------------- Admin Gui Main Inventory ---------------------------------------
  31. agui = Bukkit.createInventory(null, 54, ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "Admin" +
  32. ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "GUI");
  33.  
  34. agui.setItem(45, ReloadButton);
  35.  
  36.  
  37. // --------------------------------- Admin Gui Main Inventory ---------------------------------------
  38. if(cmd.getName().equalsIgnoreCase("AguiGui")) {
  39. if(p.hasPermission("hhf.agui.gui")) {
  40. p.openInventory(agui);
  41. }else {
  42. if(!p.hasPermission("hhf.agui.get")) {
  43. p.sendMessage(ChatColor.DARK_RED + "" + ChatColor.BOLD + "HHF" + ChatColor.RED + " - I'm sorry, but I believe this command is not accessable to you. Please contact the server admin to check if this is an error!");
  44. }
  45. }
  46. }
  47.  
  48.  
  49. return true;
  50. }
  51.  
  52. @EventHandler
  53. public void AGUI(PlayerInteractEvent e) {
  54. Player p = e.getPlayer();
  55.  
  56. if(p.hasPermission("hhf.agui.open")) {
  57. if(p.getInventory().getItemInMainHand().getType() == Material.END_CRYSTAL) {
  58. if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
  59. p.performCommand("Aguigui");
  60.  
  61. }
  62. }
  63. }
  64. }
  65.  
  66.  
  67. @EventHandler
  68. public void AGUI2(InventoryClickEvent e) {
  69. Player p = (Player) e.getWhoClicked();
  70.  
  71. if(e.getInventory().getName().equals(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "Admin" +
  72. ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "" + ChatColor.ITALIC + "GUI")) {
  73. e.setCancelled(true);
  74. }
  75.  
  76. if(e.getCurrentItem() == null) {
  77. return;
  78. }
  79.  
  80. if(e.getSlot() == 45) {
  81. p.getOpenInventory().close();
  82. p.performCommand("plugins");
  83. }
  84.  
  85. }
  86.  
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment