View difference between Paste ID: FvUiPj8q and WcfQ4brK
SHOW: | | - or go back to the newest paste.
1-
	static int cells = Math.min(((playerOnline() - 2) / 9) * 9 + 9, 54); 
1+
/**
2-
	
2+
  Creates and opens a spectator menu.
3-
	private static Integer playerOnline(){
3+
  @param player The player.
4-
		int plson = 0;
4+
*/
5-
		for(Player pls : Bukkit.getOnlinePlayers()){
5+
public void openMenu(Player player) {
6-
			if(pls.getGameMode() == GameMode.SURVIVAL){
6+
	int cells = Math.min(((Bukkit.getOnlinePlayers().length - 2) / 9) * 9 + 9, 54);
7-
				plson ++;
7+
	Inventory panel = Bukkit.createInventory(null, cells, "Spectator Menu");
8-
			}
8+
9-
		}
9+
	List<ItemStack> heads = new ArrayList<ItemStack>();
10-
		return plson;
10+
11
	for (Player p : Bukkit.getOnlinePlayers()) {
12-
	
12+
		if (equals(p) || p.getGameMode() != GameMode.SURVIVAL)
13-
	public static void openMenu(Player player){
13+
			continue;
14-
		Inventory inv = Bukkit.createInventory(null, cells, "§cJoueurs en vie");
14+
15
		ItemStack head = new ItemStack(Material.SKULL_ITEM);
16-
		for(Player plon : HungerGames.players){
16+
17-
			int slot = 0;
17+
		SkullMeta hMeta = (SkullMeta) head.getItemMeta();
18-
			for(int i = 0; i < cells; i++){
18+
		hMeta.setOwner(p.getName());
19-
				ItemStack head =  new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
19+
20-
				SkullMeta meta = (SkullMeta) head.getItemMeta();
20+
		hMeta.setDisplayName(p.getName());
21-
				meta.setOwner(plon.getName());
21+
22-
				meta.setDisplayName(plon.getName());
22+
		List<String> lore = new ArrayList<String>();
23-
				head.setItemMeta(meta);
23+
		lore.add("");
24-
				inv.setItem(slot, head);
24+
		lore.add("§7§oRight Click to teleport!");
25-
				slot++;
25+
		hMeta.setLore(lore);
26-
			}
26+
27-
		}
27+
		head.setItemMeta(hMeta);
28-
		player.openInventory(inv);
28+
29-
	}
29+
30
	for (ItemStack h : heads)
31
		panel.addItem(h);
32
33
	getPlayer().openInventory(panel);
34
}