Package com.jackdaw.chatwithnpc.npc
Class NPCEntity
java.lang.Object
com.jackdaw.chatwithnpc.npc.NPCEntity
NPC Entity Class
This is a class used to define the interaction with NPC. This class should record the basic information of NPC, such as name, career, basicPrompt, and localGroup, etc., which are all characteristics of NPC. At the same time, this class should record the dialogue state of NPC, such as the last message time, message record, and whether it is in dialogue with the player, etc. This class should provide methods for receiving player information, replying to player information, and executing actions, etc.
Please note: this class should set a life cycle to reduce repeated reading and memory usage
- Version:
- 1.1
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNPCEntity
(@NotNull net.minecraft.entity.Entity entity) This is a constructor used to initialize the NPC with the entity. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFunction
(String function) Add a function to the NPC.void
discard()
Discard the NPC.List<net.minecraft.entity.player.PlayerEntity>
findNearbyPlayers
(double range) Find the nearby players.Get the NPC's assistant ID.Get the career of the NPC, which should be one of the characteristics of the NPC.Get the NPC data manager, which should be used to manage the NPC's data.net.minecraft.entity.Entity
Get the entity of the NPC, which should be the entity of the NPC in the game.Get the functions of the NPC.getGroup()
Get the local group of the NPC, which should be one of the characteristics of the NPC.Get the basic instructions of the NPC, which should be one of the characteristics of the NPC.getName()
Get the name of the NPC, which should be the unique identifier of the NPC in this plugin and will be used as the file name for storage.Get the NPC's thread ID.getType()
Get the type of the NPC, which should be one of the characteristics of the NPC.long
Get the update time of the NPC.getUUID()
Get the UUID of the NPC, which should be the unique identifier of the NPC in the game.boolean
Check if the NPC has an assistant.boolean
Check if the NPC has a thread ID.@NotNull String
Get the prompt of the NPCboolean
Check if the NPC needs memory.void
removeFunction
(String function) Remove a function from the NPC.void
replyMessage
(String message, double range) Reply the message to the players nearby the NPC.void
setAssistantId
(String id) Set the NPC's assistant ID.void
Set the career of the NPC, which should be one of the characteristics of the NPC.void
setFunctions
(ArrayList<String> functions) Set the functions of the NPC.void
Set the local group of the NPC, which should be one of the characteristics of the NPC.void
setInstructions
(String instructions) Set the basic instructions of the NPC, which should be one of the characteristics of the NPC.void
setNeedMemory
(boolean needMemory) Set if the NPC needs memory.void
setThreadId
(String threadId) Set the NPC's thread ID.void
Set the update time of the NPC to the current time.void
setUpdateTime
(long updateTime) Set the update time of the NPC.
-
Field Details
-
name
-
entity
protected final net.minecraft.entity.Entity entity -
uuid
-
assistantId
-
ThreadId
-
career
-
instructions
-
group
-
needMemory
protected boolean needMemory -
updateTime
protected long updateTime -
functions
-
textBubble
-
-
Constructor Details
-
NPCEntity
public NPCEntity(@NotNull @NotNull net.minecraft.entity.Entity entity) This is a constructor used to initialize the NPC with the entity.- Parameters:
entity
- The entity of the NPC.
-
-
Method Details
-
getName
Get the name of the NPC, which should be the unique identifier of the NPC in this plugin and will be used as the file name for storage.- Returns:
- The name of the NPC
-
getType
Get the type of the NPC, which should be one of the characteristics of the NPC.- Returns:
- The type of the NPC
-
getCareer
Get the career of the NPC, which should be one of the characteristics of the NPC.- Returns:
- The career of the NPC
-
setCareer
Set the career of the NPC, which should be one of the characteristics of the NPC.- Parameters:
career
- The career of the NPC
-
getInstructions
Get the basic instructions of the NPC, which should be one of the characteristics of the NPC.- Returns:
- The instructions of the NPC
-
setInstructions
Set the basic instructions of the NPC, which should be one of the characteristics of the NPC.- Parameters:
instructions
- The instructions of the NPC
-
getGroup
Get the local group of the NPC, which should be one of the characteristics of the NPC.- Returns:
- The local group of the NPC
-
setGroup
Set the local group of the NPC, which should be one of the characteristics of the NPC.- Parameters:
group
- The local group of the NPC
-
getDataManager
Get the NPC data manager, which should be used to manage the NPC's data.- Returns:
- The NPC data manager
-
replyMessage
Reply the message to the players nearby the NPC.- Parameters:
message
- The message of the NPCrange
- The range of the NPC
-
findNearbyPlayers
Find the nearby players.- Parameters:
range
- The range of the NPC- Returns:
- The nearby players
-
getUUID
Get the UUID of the NPC, which should be the unique identifier of the NPC in the game.- Returns:
- The UUID of the NPC
-
getEntity
public net.minecraft.entity.Entity getEntity()Get the entity of the NPC, which should be the entity of the NPC in the game.- Returns:
- The entity of the NPC
-
isNeedMemory
public boolean isNeedMemory()Check if the NPC needs memory.- Returns:
- If the NPC needs memory
-
setNeedMemory
public void setNeedMemory(boolean needMemory) Set if the NPC needs memory.- Parameters:
needMemory
- If the NPC needs memory
-
hasAssistant
public boolean hasAssistant()Check if the NPC has an assistant.- Returns:
- If the NPC has an assistant
-
getAssistantId
Get the NPC's assistant ID.- Returns:
- The NPC's assistant ID
-
setAssistantId
Set the NPC's assistant ID.- Parameters:
id
- The NPC's assistant ID
-
getThreadId
Get the NPC's thread ID.- Returns:
- The NPC's thread ID
-
setThreadId
Set the NPC's thread ID.- Parameters:
threadId
- The NPC's thread ID
-
hasThreadId
public boolean hasThreadId()Check if the NPC has a thread ID.- Returns:
- If the NPC has a thread ID
-
addFunction
Add a function to the NPC.- Parameters:
function
- The function to add
-
removeFunction
Remove a function from the NPC.- Parameters:
function
- The function to remove
-
getFunctions
Get the functions of the NPC.- Returns:
- The functions of the NPC
-
setFunctions
Set the functions of the NPC.- Parameters:
functions
- The functions of the NPC
-
discard
public void discard()Discard the NPC. If the NPC is not needed to remember the conversation, all the messages in this conversation will be deleted. -
getUpdateTime
public long getUpdateTime()Get the update time of the NPC.- Returns:
- The update time of the NPC
-
setUpdateTime
public void setUpdateTime()Set the update time of the NPC to the current time. -
setUpdateTime
public void setUpdateTime(long updateTime) Set the update time of the NPC.- Parameters:
updateTime
- The update time of the NPC
-
instructions
Get the prompt of the NPC- Returns:
- the prompt
-