Player name in custom ItemStack

Discussion in 'Plugin Development' started by macproman();, Dec 10, 2014.

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

    macproman();

    Hello again,

    I've been wondering how I can have a players name in a custom ItemStack? I mean I know you can use

    Code:
    + p.getName() + "blah"
    
    Put how would I define the player a p?

    Thanks!
     
  2. Offline

    Totom3

    @macproman(); There are several ways to get a Player objet. It all depends on the context... Could you explain what you are trying to do exactly?
     
  3. Offline

    macproman();

    @Totom3 I'm making a custom ItemStack to go in an inventory.
     
  4. Offline

    Sneling

    Get the ItemMeta, set displayName to player " "blah". Set the itemstack to the meta you changed
    Done!
     
  5. Offline

    Totom3

    @macproman(); I understood that, I asked under which context this is happening.
    • If it's when a PlayerEvent is fired, you can use PlayerEvent#getPlayer()
    • If it's when a command is entered, you can use sender if it's a Player
    • If the player's name is entered and you want to get the corresponding Player, you can use Bukkit#getPlayer(String)
    • If the player's UUID is entered and you want to get the corresponding Player, you can use Bukkit#getPlayer(UUID)
     
Thread Status:
Not open for further replies.

Share This Page