get player name through inventory menu?

Discussion in 'Plugin Development' started by IsThisDisplayed, Jun 13, 2018.

  1. Offline

    IsThisDisplayed

    is it possible for a person to type a players name in the chat and invsee them? Ive got a working invsee command, but im tryna make one through onplayerinventoryclick.

    basically: im sending the person "Enter a player name. . ." then when they type a name, i want my plugin to open the targets inventory, but how? (dont spoon feed me with codes please)
     
  2. Online

    timtower Ninja on the waves Moderator

  3. Offline

    MightyOne

    With the AsnyPlayerChatEvemt it is surely possible to get a players name typed in chat after a player runs a command. You will probably need some kind of list to note players that are typing a name instead of common chatting
     
  4. Offline

    ThePandaPlayer

    This is precisely what I do. My Plugin allows the user to set an on-join title and subtitle and grabs the message from the chat. I add the players that are changing the setting to an ArrayList and then listen for an AsyncPlayerChatEvent from them. e.getMessage() works beautifully in this case as it allows you to get the message, cancel the event, and use it.
     
  5. Could you not create an arraylist with the players' name then use a runnable to self cancel it after x seconds? AsyncPlayerChatEvent going into a cancel if the string typed is a player name?
     
  6. Offline

    CommonSenze

    @NullPointerExptn
    You won't even have to do that.

    Simply Bukkit#getPlayer(String name) and check if it doesn't equal null.
    Then there you have it, open the inventory.
     

Share This Page