Solved How to get Online players (To Heads)

Discussion in 'Spigot Plugin Development' started by ShishKaBobz, Apr 27, 2017.

  1. Hello! I know this is no easy task, But i would like to know how you can Add heads to a inventory, Then change there meta to the players skin (I want this to be done for all the players online) If any ones kind enough it would be great if you could walk me though it! Thanks in advance
  2. I think you create a Skull ItemStack, get the meta and then set the owner
    Code (Java):
    ItemStack skull = new ItemStack(Material.SKULL_ITEM);
    SkullMeta meta = (SkullMeta) skull.getItemMeta();
    meta.setOwner(/*Skin Owner*/)
    //Add skull to inventory
  3. Code (Text):
    private Inventory onlinePlayersSkull() {
            Inventory inv = Bukkit.createInventory(null, 54, "Online Players");
            int time = 0;
            for(Player p: Bukkit.getOnlinePlayers()) {
                ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
                SkullMeta meta = (SkullMeta) skull.getItemMeta();
                meta.setDisplayName(ChatColor.LIGHT_PURPLE + p.getName());
                inv.setItem(time, skull);
            return inv;
  4. Thank you guys Soo much!
  5. Got one question though... How can i make it so it outputs all the players
  6. Loop thru the players.
  7. Example Please? :D If you dont mind
  8. What do you mean by "outputs"?
  9. I never said OutPuts
    • Funny Funny x 1
  10. You did, actually.
    • Agree Agree x 1
  11. Well i meant "Shows" All the players heads
  12. Loop through the players, if you don't know what that means, please learn some Java before you start learning the Bukkit API.