Class ConversationHandler
java.lang.Object
com.jackdaw.chatwithnpc.conversation.ConversationHandler
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConversationHandler
(@NotNull NPCEntity npc) Construct a new Conversation for an NPC. -
Method Summary
Modifier and TypeMethodDescriptionvoid
discard()
Discard the conversation.getNpc()
Get the NPC that this conversation is handling.long
Get the time when the conversation was last updated.Get the time when the conversation was last updated in a human-readable format.boolean
Get the NPC's current conversation.void
replyToEntity
(String message) Reply to the NPC with a message.void
Send a wait message to the NPC.void
setTalking
(boolean isTalking) Set the NPC's current conversation.void
Say hello to the NPC.
-
Field Details
-
npc
-
isTalking
protected boolean isTalking -
updateTime
protected long updateTime
-
-
Constructor Details
-
ConversationHandler
Construct a new Conversation for an NPC. This will start a conversation with the NPC asynchronously.- Parameters:
npc
- The NPC to start a conversation with.
-
-
Method Details
-
getNpc
Get the NPC that this conversation is handling.- Returns:
- The NPC that this conversation is handling.
-
sendWaitMessage
public void sendWaitMessage()Send a wait message to the NPC. This will make the NPC reply to the player with a waiting message. -
startConversation
public void startConversation()Say hello to the NPC. This will start a conversation with the NPC asynchronously. -
replyToEntity
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
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.
-