Advertisement
iSach

Spectator Menu creator.

Oct 19th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.   Creates and opens a spectator menu.
  3.   @param player The player.
  4. */
  5. public void openMenu(Player player) {
  6.     int cells = Math.min(((Bukkit.getOnlinePlayers().length - 2) / 9) * 9 + 9, 54);
  7.     Inventory panel = Bukkit.createInventory(null, cells, "Spectator Menu");
  8.  
  9.     List<ItemStack> heads = new ArrayList<ItemStack>();
  10.  
  11.     for (Player p : Bukkit.getOnlinePlayers()) {
  12.         if (equals(p) || p.getGameMode() != GameMode.SURVIVAL)
  13.             continue;
  14.  
  15.         ItemStack head = new ItemStack(Material.SKULL_ITEM);
  16.  
  17.         SkullMeta hMeta = (SkullMeta) head.getItemMeta();
  18.         hMeta.setOwner(p.getName());
  19.        
  20.         hMeta.setDisplayName(p.getName());
  21.  
  22.         List<String> lore = new ArrayList<String>();
  23.         lore.add("");
  24.         lore.add("§7§oRight Click to teleport!");
  25.         hMeta.setLore(lore);
  26.  
  27.         head.setItemMeta(hMeta);
  28.     }
  29.  
  30.     for (ItemStack h : heads)
  31.         panel.addItem(h);
  32.  
  33.     getPlayer().openInventory(panel);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement