Class SpeechContext

java.lang.Object
net.citizensnpcs.api.ai.speech.SpeechContext
All Implemented Interfaces:
Iterable<Talkable>

public class SpeechContext extends Object implements Iterable<Talkable>
SpeechContext contains information about a NPCSpeechEvent, including the Talkable talker, recipients, and message.
  • Constructor Details

    • SpeechContext

      public SpeechContext()
    • SpeechContext

      public SpeechContext(NPC talker, String message)
    • SpeechContext

      public SpeechContext(NPC talker, String message, Entity recipient)
    • SpeechContext

      public SpeechContext(String message)
    • SpeechContext

      public SpeechContext(String message, Entity recipient)
  • Method Details

    • addRecipient

      public SpeechContext addRecipient(Entity entity)
      Adds a direct Talkable recipient.
      Parameters:
      entity - Talkable entity
      Returns:
      the speech context
    • addRecipients

      public SpeechContext addRecipients(List<Talkable> talkables)
      Adds a list of Talkable recipients.
      Parameters:
      talkables - Talkable entities
      Returns:
      the Tongue
    • getMessage

      public String getMessage()
      Gets the text message sent.
    • getTalker

      public Talkable getTalker()
      Gets the talker.
      Returns:
      NPC doing the talking
    • hasRecipients

      public boolean hasRecipients()
      Checks if there are any recipients. If none, this SpeechContext is not targeted.
      Returns:
      true if recipients are specified.
    • iterator

      public Iterator<Talkable> iterator()
      Gets direct recipients, if any.
      Specified by:
      iterator in interface Iterable<Talkable>
      Returns:
      recipients Iterator
    • setMessage

      public void setMessage(String message)
      Sets the text message sent. Overrides text set with the constructor.
      Parameters:
      message - The text to send.
    • setTalker

      public void setTalker(Entity entity)
      Sets the talker.
      Parameters:
      entity - NPC doing the talking
    • size

      public int size()
      Returns:
      number of recipients.