SHARE
TWEET

Tutorial Custom GUI - Test

Straiker123 Jun 17th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class main extends JavaPlugin implements Listener {
  2.     @Override
  3.     public void onEnable() {
  4.         Bukkit.getPluginManager().registerEvents(this, this);
  5.     }
  6.     Inventory i = Bukkit.createInventory(null, 36, "GUI By Straiker123");
  7.     @Override
  8.     public boolean onCommand(CommandSender s, Command cmd, String a, String[] args) {
  9.         if(cmd.getName().equalsIgnoreCase("GUI")) {
  10.             Player p = (Player)s;
  11.             ItemStack ref1 = new ItemStack(Material.BOOK);
  12.             ItemMeta metaref1 = ref1.getItemMeta();
  13.             ArrayList<String> lore= new ArrayList<String>();
  14.  
  15.             lore.add(" ");
  16.             lore.add("§7To clear global chat");
  17.            
  18.             metaref1.setLore(lore);
  19.             metaref1.setDisplayName("§6§lClearChat");
  20.    
  21.  
  22.             ref1.setItemMeta(metaref1);
  23.             i.setItem(5, ref1);
  24.              
  25.             p.openInventory(i);
  26.             return true;
  27.         }
  28.         return false;
  29.     }
  30.     @EventHandler
  31.     public void event(InventoryClickEvent e)
  32.    {
  33.         Player p = (Player) e.getWhoClicked();
  34.        
  35.          if (e.getInventory()==i){
  36.              e.setCancelled(true);
  37.              if ((e.getCurrentItem() == null) || (e.getCurrentItem().getType().equals(Material.AIR))) {
  38.                  return;
  39.              }
  40.              if(e.getSlot() == 5 && (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6§lClearChat"))){
  41.                  if(p.hasPermission("test")) {
  42.                  p.sendMessage("§6§lChat cleared..");
  43.               p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_LAND, 1.0f, 1.0f);
  44.  
  45.              }}
  46.              if(e.getSlot() == 5 && (e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("§6§lChatLock"))){
  47.                  if(p.hasPermission("test")) {
  48.                  p.sendMessage("§6§lChat lo");
  49.               p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_LAND, 1.0f, 1.0f);
  50.  
  51.              }}
  52.                     e.setResult(Result.DENY);
  53.           }}}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top