Solved Help Interfacing the Conversations API

Discussion in 'Spigot Plugin Development' started by DynamicDylan, May 26, 2016.

  1. I am attempting to write a re-usable class for the conversations API, however, I am trying to use an interface to make this possible. My class:

    Code (Text):
    public class Input extends StringPrompt {
       
        public static ConversationFactory conservationFactory = new ConversationFactory(Core.getPlugin());
        public String query;
        public String input;
        public ConversationContext context;
       
        public interface acceptInputHandler {
            public Prompt acceptInput(ConversationContext context, String input);
        }
       
        public Input(Player player, String query, acceptInputHandler handler) {
            this.query = query;
       
            Conversation conversation = conservationFactory.withFirstPrompt(this).withLocalEcho(true).buildConversation(player);
            conversation.begin();
        }
       
        public Prompt acceptInput(ConversationContext context, String input) {
            return null;
        }
       
        @Override
        public String getPromptText(ConversationContext context) {
            return this.query;
        }

    }
    And the use in another class:

    Code (Text):

               Input input = new Input(player, "What is your favorite color?", new acceptInputHandler() {
                        @Override
                        public Prompt acceptInput(ConversationContext context, String input) {
                            context.getForWhom().sendRawMessage("Cool! I like the color " + input + " too!");
                            return null;
                        }
                    });
     
    The problem is the message is not sending to the user ("Cool! I like the color...").

    Any suggestions? Thanks!
     
  2. I don't see anywhere in your code where you actually call the acceptInput method.
     
  3. I figured this out on my own. Thanks though!