Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Creates and opens a spectator menu.
- @param player The player.
- */
- public void openMenu(Player player) {
- int cells = Math.min(((Bukkit.getOnlinePlayers().length - 2) / 9) * 9 + 9, 54);
- Inventory panel = Bukkit.createInventory(null, cells, "Spectator Menu");
- List<ItemStack> heads = new ArrayList<ItemStack>();
- for (Player p : Bukkit.getOnlinePlayers()) {
- if (equals(p) || p.getGameMode() != GameMode.SURVIVAL)
- continue;
- ItemStack head = new ItemStack(Material.SKULL_ITEM);
- SkullMeta hMeta = (SkullMeta) head.getItemMeta();
- hMeta.setOwner(p.getName());
- hMeta.setDisplayName(p.getName());
- List<String> lore = new ArrayList<String>();
- lore.add("");
- lore.add("§7§oRight Click to teleport!");
- hMeta.setLore(lore);
- head.setItemMeta(hMeta);
- }
- for (ItemStack h : heads)
- panel.addItem(h);
- getPlayer().openInventory(panel);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement