Bukkit ask player to input text

Discussion in 'Plugin Development' started by Broadwell, Apr 25, 2015.

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

    Broadwell

    Hi,
    how can I ask a user to enter a number into the chat? I want to make the player enter a value for which the player wants to sell an item. The server should output something like Please enter a value, and the player can then input text without it getting send to all players. I am using this in a onPlayerUse event.
     
    Last edited: Apr 25, 2015
  2. @Broadwell You haven't implemented Listener and registered the event. You also do not need to log messages on enable and disable, Bukkit does it for you. Also please use the [c0de] tags (o not 0) for us to better see the code.
     
  3. Offline

    Broadwell

    Thank you, I edited the question because I have another one and I don't want to spam the formu with my nooby questions :p
     
  4. Offline

    Tamir

    @Broadwell
    If I understood you well.
    A. Create an arraylist
    B. Add the player to the arraylist.
    C. Use the event PlayerChatEvent
    Check if the arraylist contains the player, if it isn't return.
    Check if the players message is int (or double), if so, remove him from the arraylist.
    Else, send him a message "Please type a number" and cancel the chat event in both cases.
    Hope I helped.
     
  5. Offline

    Broadwell

    Isn't there any easier method? :(
     
  6. Offline

    Zombie_Striker

    Make a ChatEvent that when the player is in an arraylist, cancel the event (so other players don't see what he typed), parse out each word and do Integer.parseInt(args[0]) to get an int which would be first word. You don't need to be a good coder to understand what to do.

    [Edit] Just read the rest of the posts, Tamir explained it better.
     
  7. Offline

    Broadwell

    Yeah I kinda understood it now and will try to implement it :)
     
  8. Offline

    teej107

    @Broadwell Those "easy" methods are not the easy method. Use Bukkit's Conversation API.
     
    vhbob and Konato_K like this.
Thread Status:
Not open for further replies.

Share This Page