Class Text

java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.text.Text
All Implemented Interfaces:
Runnable, Listener

public class Text extends Trait implements Runnable, Listener
Persists text metadata, i.e. text that will be said by an NPC on certain triggers.
  • Constructor Details

    • Text

      public Text()
  • Method Details

    • add

      public void add(String string)
      Adds a piece of text that will be said by the NPC.
      Parameters:
      string - the text to say
    • edit

      public void edit(int index, String newText)
      Edit the text at a given index to a new text.
      Parameters:
      index - the text's index
      newText - the new text to use
    • getEditor

      public Editor getEditor(Player player)
      Builds a text editor in game for the supplied Player.
    • getTexts

      public List<String> getTexts()
      Returns:
      The list of all texts
    • hasIndex

      public boolean hasIndex(int index)
      Returns:
      whether there is text at a certain index
    • isRandomTalker

      public boolean isRandomTalker()
    • load

      public void load(DataKey key) throws NPCLoadException
      Description copied from class: Trait
      Loads a trait.
      Overrides:
      load in class Trait
      Parameters:
      key - DataKey to load from
      Throws:
      NPCLoadException - Thrown if this trait failed to load properly
    • remove

      public void remove(int index)
      Remove text at a given index.
    • run

      public void run()
      Description copied from class: Trait
      Called every tick if overridden.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Trait
    • save

      public void save(DataKey key)
      Description copied from class: Trait
      Saves a trait.
      Overrides:
      save in class Trait
      Parameters:
      key - DataKey to save to
    • setDelay

      public void setDelay(int delay)
      Set the text delay between messages.
      Parameters:
      delay - the delay in ticks
    • setItemInHandPattern

      public void setItemInHandPattern(String pattern)
      Sets the item in hand pattern required to talk to NPCs, if enabled.
      Parameters:
      pattern - The new pattern
    • setRange

      public void setRange(double range)
      Set the range in blocks before text will be sent.
      Parameters:
      range -
    • shouldTalkClose

      public boolean shouldTalkClose()
      Returns:
      Whether talking close is enabled.
    • toggleRandomTalker

      public boolean toggleRandomTalker()
      Toggles talking at random intervals.
    • toggleRealisticLooking

      public boolean toggleRealisticLooking()
      Toggles requiring line of sight before talking.
    • toggleSpeechBubbles

      public boolean toggleSpeechBubbles()
      Toggles using speech bubbles instead of messages.
    • toggleTalkClose

      public boolean toggleTalkClose()
      Toggles talking to nearby Players.
    • useRealisticLooking

      public boolean useRealisticLooking()
    • useSpeechBubbles

      public boolean useSpeechBubbles()