Getting the player

Discussion in 'Spigot Plugin Development' started by LazerShadow, Jun 1, 2015.

  1. So I'm going to have a command where you type /hi <player> and it opens a inventory and if you click a item it sends the target player a message. This isn't what I'm using it for but I need to know how to get the target player from the command and use it in the GUI. I know how to get the player from the command and stuff, just not how to get the player in the inventory class.

    If this doesn't make sense I can try to explain it better.
     
  2. Inkzzz

    Resource Staff

    You could save the target player in a hashmap, or set the display name of the item in the gui to the target player, and then get the player from the display name.
     
  3. What you could also do, is give the items in the inventory GUI a metadata, which you can then use to send it to the correct player.
     
  4. Thanks, although I haven't really used HashMaps before. Could you quickly explain how to do that?