sendMessage dont working while Conversation

Discussion in 'Spigot Plugin Development' started by Armagidon, Jan 7, 2020.

  1. Hey!
    I wanna realize editing chat message. I've made it by sending empty lines and resending all player's chat history. I've almost done it, but sendMessage doesn't work while Conversation is doing! Player's history sends but empty line not.
    Code (Text):
    public void edit(UUID uuid){
        Player player = Bukkit.getPlayer(messages.getMessageByID(uuid).getSender());
        ChatMessage message = messages.getMessageByID(uuid);
        TextComponent component = new TextComponent(new ComponentBuilder("┬žaPut message from clipboard").create());
        component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,message.getMessage()));
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new ComponentBuilder("┬žaPut message from clipboard!").create()));
        player.spigot().sendMessage(component);
        for(int i = 0; i < 50; i++) player.sendMessage("\n");
        ConversationFactory factory = new ConversationFactory(ArmagidonChatManager.getManager());
        Conversation conversation = factory.withFirstPrompt(new EditConversation(message,messages)).buildConversation(player);
        conversation.begin();
    }
     
    Code (Text):
    public class EditConversation extends StringPrompt
    {
        private final ChatMessage message;
        private final MessageManager queue;

        public EditConversation(ChatMessage edit, MessageManager queue) {
            this.message = edit;
            this.queue = queue;
        }

        @Override
        public String getPromptText(ConversationContext conversationContext) {
            return "EDIT";
        }

        @Override
        public Prompt acceptInput(ConversationContext context, String answer) {
            Player player = (Player) context.getForWhom();
            if(queue.editMessage(message.getId(),answer)){
                queue.resend(message);
            }
            return END_OF_CONVERSATION;
        }
    }
     
    Why is it the way? How to use sendMessage while conversation? If I can use conversation API can you give me link to the documentation or the tutorial, because Hub Spigot documentation isn't enough clear for me!
    Thanks!