Getting the player

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

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


    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. Offline


    This should work:

  3. Offline


    That will get the player in the inventory, not the target player. The target player is
    Player targetplayer = player.getServer().getPlayer(args[0]);
    ForsakenRealmz likes this.
  4. Offline


    I misread that. Okay, I see. You're trying to run a command that will open an inventory based off the target player chosen in the command.

    The best way to do this might be to set the Inventory title to contain the player's username so you can verify that it was the target player you opened.
  5. Offline


    @bubblefat_ Store the playername in a variable.
    Or create an hashmap with the playerClicker and playerReceiver.
    then when the playerClicker click the inventory, check if he is in the hashmap, then get back playerReceiver and send him the message.
  6. Offline


    I don't know much about HashMaps, could you explain how to do that?
  7. Offline


Thread Status:
Not open for further replies.

Share This Page