Class ConversationHandler

java.lang.Object
com.jackdaw.chatwithnpc.conversation.ConversationHandler

public class ConversationHandler extends Object
Conversation of an NPC

The conversation will record the conversation of a NPC.

It is used to execute the conversation with OpenAI asynchronously.

Version:
1.0
  • Field Details

    • npc

      protected final NPCEntity npc
    • isTalking

      protected boolean isTalking
    • updateTime

      protected long updateTime
  • Method Details

    • getNpc

      public NPCEntity getNpc()
      Get the NPC that this conversation is handling.
      Returns:
      The NPC that this conversation is handling.
    • replyToEntity

      public void replyToEntity(String message)
      Reply to the NPC with a message. Then the NPC will reply to the player something. This method is asynchronous.
      Parameters:
      message - The message sent to the NPC.
    • getUpdateTime

      public long getUpdateTime()
      Get the time when the conversation was last updated.
      Returns:
      The time when the conversation was last updated.
    • getUpdateTimeString

      public String getUpdateTimeString()
      Get the time when the conversation was last updated in a human-readable format.
      Returns:
      The time when the conversation was last updated in a human-readable format.
    • isTalking

      public boolean isTalking()
      Get the NPC's current conversation.
      Returns:
      The NPC's current conversation.
    • setTalking

      public void setTalking(boolean isTalking)
      Set the NPC's current conversation.
      Parameters:
      isTalking - The NPC's current conversation.
    • discard

      public void discard()
      Discard the conversation. This will stop the conversation with the NPC. If the NPC is not needed to remember the conversation, all the messages in this conversation will be deleted.