Class NPCEntity

java.lang.Object
com.jackdaw.chatwithnpc.npc.NPCEntity

public class NPCEntity extends Object
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 Details

    • name

      protected final String name
    • entity

      protected final net.minecraft.entity.Entity entity
    • uuid

      protected final UUID uuid
    • assistantId

      protected String assistantId
    • ThreadId

      protected String ThreadId
    • career

      protected String career
    • instructions

      protected String instructions
    • group

      protected String group
    • needMemory

      protected boolean needMemory
    • updateTime

      protected long updateTime
    • functions

      protected ArrayList<String> functions
    • textBubble

      protected TextBubbleEntity 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

      public String 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

      public String getType()
      Get the type of the NPC, which should be one of the characteristics of the NPC.
      Returns:
      The type of the NPC
    • getCareer

      public String getCareer()
      Get the career of the NPC, which should be one of the characteristics of the NPC.
      Returns:
      The career of the NPC
    • setCareer

      public void setCareer(String career)
      Set the career of the NPC, which should be one of the characteristics of the NPC.
      Parameters:
      career - The career of the NPC
    • getInstructions

      public String 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

      public void setInstructions(String instructions)
      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

      public String 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

      public void setGroup(String group)
      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

      public NPCDataManager getDataManager()
      Get the NPC data manager, which should be used to manage the NPC's data.
      Returns:
      The NPC data manager
    • replyMessage

      public void replyMessage(String message, double range)
      Reply the message to the players nearby the NPC.
      Parameters:
      message - The message of the NPC
      range - The range of the NPC
    • findNearbyPlayers

      public List<net.minecraft.entity.player.PlayerEntity> findNearbyPlayers(double range)
      Find the nearby players.
      Parameters:
      range - The range of the NPC
      Returns:
      The nearby players
    • getUUID

      public UUID 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

      public String getAssistantId()
      Get the NPC's assistant ID.
      Returns:
      The NPC's assistant ID
    • setAssistantId

      public void setAssistantId(String id)
      Set the NPC's assistant ID.
      Parameters:
      id - The NPC's assistant ID
    • getThreadId

      public String getThreadId()
      Get the NPC's thread ID.
      Returns:
      The NPC's thread ID
    • setThreadId

      public void setThreadId(String threadId)
      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

      public void addFunction(String function)
      Add a function to the NPC.
      Parameters:
      function - The function to add
    • removeFunction

      public void removeFunction(String function)
      Remove a function from the NPC.
      Parameters:
      function - The function to remove
    • getFunctions

      public ArrayList<String> getFunctions()
      Get the functions of the NPC.
      Returns:
      The functions of the NPC
    • setFunctions

      public void setFunctions(ArrayList<String> functions)
      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

      @NotNull public @NotNull String instructions()
      Get the prompt of the NPC
      Returns:
      the prompt