How to collect input with AsyncChatEvent in spigot API

Viewed 25

i try to make a plugin that implement a gui to the spigot API and EssentialsX API but i tried everything and i don't know how to do it. Here is the goal and the following code under.

when the item EMERALD_BLOCK is clicked a message is sent to the player that request him to enter the amount of money he want to send. The plugin check if it's a number, else it show a message error. then the following number is put in a variable that can be used to send the good amount of money !

//This is the code that listen to the chat and implement args with the chat only when we want (not a good method btw)

@EventHandler
public String onPlayerChat(AsyncPlayerChatEvent event) {
    System.out.println("post");
    if (go==true) {
        System.out.println("go est true");
        System.out.println(args);
        String msg = event.getMessage();
        args = msg;
        System.out.println(args);
        go = false;
        System.out.println(args);
        return args;
    }
    else{
        System.out.println("pas go");
        args = null;
    }
    return args;
}

    // and here is the code that launch the rest of the code (you don't have all the code it's just to show you my method
            switch (e.getCurrentItem().getType()){
                case EMERALD:
                    e.getWhoClicked().closeInventory();
                    player.sendMessage("enter your message");
                    go = true;
                    System.out.println(args);
                    break;
0 Answers
Related