Package net.citizensnpcs.trait.text
Class Text
java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.trait.text.Text
Persists text metadata, i.e. text that will be said by an NPC on certain triggers.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a piece of text that will be said by the NPC.void
Edit the text at a given index to a new text.Builds a text editor in game for the suppliedPlayer
.getTexts()
boolean
hasIndex
(int index) boolean
void
Loads a trait.void
onSpawn()
Called when anNPC
is spawned.void
remove
(int index) Remove text at a given index.void
run()
Called every tick if overridden.void
Saves a trait.boolean
void
setDelay
(int delay) Set the text delay between messages.void
setItemInHandPattern
(String pattern) Sets the item in hand pattern required to talk to NPCs, if enabled.void
setRange
(double range) Set the range in blocks before text will be sent.void
setSpeechBubbleDuration
(Duration duration) boolean
boolean
Toggles talking at random intervals.boolean
Toggles requiring line of sight before talking.boolean
Toggles sending text through chatboolean
Toggles using speech bubbles instead of messages.boolean
Toggles talking to nearby Players.boolean
boolean
-
Constructor Details
-
Text
public Text()
-
-
Method Details
-
add
Adds a piece of text that will be said by the NPC.- Parameters:
string
- the text to say
-
edit
Edit the text at a given index to a new text.- Parameters:
index
- the text's indexnewText
- the new text to use
-
getEditor
Builds a text editor in game for the suppliedPlayer
. -
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
Description copied from class:Trait
Loads a trait. -
onSpawn
public void onSpawn()Description copied from class:Trait
Called when anNPC
is spawned.NPC.getEntity()
will return null until this is called. This is also called onAttach when the NPC is already spawned. -
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. -
save
Description copied from class:Trait
Saves a trait. -
sendTextToChat
public boolean sendTextToChat() -
setDelay
public void setDelay(int delay) Set the text delay between messages.- Parameters:
delay
- the delay in ticks
-
setItemInHandPattern
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
-
-
setSpeechBubbleDuration
-
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. -
toggleSendTextToChat
public boolean toggleSendTextToChat()Toggles sending text through chat -
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()
-