Hi!
I am trying to build something like a prompt. The plugin asks the user to type in a name. The user simply sends the name in the chat. The message is not displayed in the public chat. It will be sent to the plugin. The user can cancel the prompt by clicking on a “Cancel” text(with callback to cancel the prompt). But what if the user executes a command? Then the prompt should also be canceled.
But as far as I can see there is no PlayerCommandEvent. How should I do that?
Edit: Or this could help Conversation API · Issue #432 · SpongePowered/SpongeAPI · GitHub
There is an event, CommandEvent
You can use an Arraylist in sich the user will be droped after he enters a command. Then you use the PlayerChatEvent and you check if the Arraylist contains the event source. Then you simply do event.setCanceled(true);
and you are basically done.
Yes, I also have to asign an id to every player as he is in prompt mode because my plugin main class receives all PlayerChatEvents and broadcasts it to the relevant places. These places decide what(and whether) to do with the input.(bases on the id).
Thanks for the .setCanceled reminder, I almost forgot