Solved Skull.SetOwner issue

Discussion in 'Plugin Development' started by Wispyy, Oct 23, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Wispyy

    Hi :p
    I've been working with a GUI and I'm using it to create a menu of all online players. I have code that adds in the skulls (see picture)
    Code:
    int i = -1;
    for (Player players : Bukkit.getOnlinePlayers()) {
        i = i + 1;
        if (i >= 54) {
            return;
        }
        ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
        SkullMeta skullmeta = (SkullMeta) skull.getItemMeta();
        skullmeta.setOwner(players.toString());
        skullmeta.setDisplayName(players.toString());
        skull.setItemMeta(skullmeta);
        inv.setItem(i, skull);
    }
    But the name of the player is CraftPlayer{name="MY_USERNAME"}. Is there a way I can change this to just the username?

    Thanks in advance.
     

    Attached Files:

    Last edited: Oct 23, 2016
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Wispyy

    That was simpler than I thought, haha yeah thanks that fixed it.
     
Thread Status:
Not open for further replies.

Share This Page