Wait for playername input?

Discussion in 'Plugin Development' started by Jalau, May 17, 2013.

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

    Jalau

    So basicly my problem is:
    I want to wait the listener or command not just for a yes or no from player, i want it to wait for a playername that is currently online.. So an example if the player does /gift then the plugin will ask him for a playername so the player enteres Jalau in the chat, i will get a present ^^ I just need the Listener to wait for an input from player...
    Because it's a listener i cannot use instantly /gift Jalau..
    Thanks :)
     
  2. Offline

    caseif

    I don't quite understand what you're saying. If you want to have the plugin listen to a chat response after a command has been sent, you can add the player's username to a global List after they send a command, then listen to the PlayerChatEvent and check the message if they're in the List, in addition to cancelling the event and removing them from the List.
     
  3. Offline

    psycowithespn

  4. Offline

    Craftiii4

    No listener is needed, this can be done from within onCommand()

    Use 2 arguments (thats 0 & 1). Cast the 2nd (if first is gift) to online players (use bukkit.getplayer) if this returns null then the player does either not exist or is not online. (If you want to do offline players, you will need to try and get the offline player and save the gift to a file, also means you will need to listen to onJoin() to give gifts when the player logs on).
     
  5. Offline

    Jalau

    So my idea is:
    The guy is rightclicking with an item (already have this code) and the plugin will wait until the player that rightclicked enteres a player name of an online player in the chat, then the online player that name has been entered will recieve something...
     
  6. Offline

    EcMiner

    You should put the player in an arraylist and use the AsyncPlayerChatEvent and check if the player is in the arraylist, then you want to check if the message they write equals to a Playername, and then you also want to cancel the event. Or the set the message to null, and remove the Player from the arraylist

    NOTE: The arraylist should hold a String, whenever you add a player to that arraylist you need to add the getName() method to prevent a lot of problems
     
Thread Status:
Not open for further replies.

Share This Page