类 ConversationFactory
java.lang.Object
org.bukkit.conversations.ConversationFactory
A ConversationFactory is responsible for creating a
Conversation
from a predefined template. A ConversationFactory is typically created when
a plugin is instantiated and builds a Conversation each time a user
initiates a conversation with the plugin. Each Conversation maintains its
own state and calls back as needed into the plugin.
The ConversationFactory implements a fluid API, allowing parameters to be set as an extension to the constructor.
-
字段概要
修饰符和类型字段说明protected List<ConversationAbandonedListener>
protected List<ConversationCanceller>
protected Prompt
protected boolean
protected boolean
protected String
protected Plugin
protected ConversationPrefix
-
构造器概要
-
方法概要
修饰符和类型方法说明Adds aConversationAbandonedListener
to all conversations constructed by this factory.buildConversation
(Conversable forWhom) Constructs aConversation
in accordance with the defaults set for this factory.thatExcludesNonPlayersWithMessage
(String playerOnlyMessage) Prevents this factory from creating a conversation for non-playerConversable
objects.withConversationCanceller
(ConversationCanceller canceller) Adds aConversationCanceller
to constructed conversations.withEscapeSequence
(String escapeSequence) Sets the player input that, when received, will immediately terminate the conversation.withFirstPrompt
(Prompt firstPrompt) Sets the first prompt to use in all generated conversations.withInitialSessionData
(Map<Object, Object> initialSessionData) Sets any initial data with which to populate the conversation context sessionData map.withLocalEcho
(boolean localEchoEnabled) Sets the local echo status for allConversation
s created by this factory.withModality
(boolean modal) Sets the modality of allConversation
s created by this factory.withPrefix
(ConversationPrefix prefix) Sets theConversationPrefix
that prepends all output from all generated conversations.withTimeout
(int timeoutSeconds) Sets the number of inactive seconds to wait before automatically abandoning all generated conversations.
-
字段详细资料
-
plugin
-
isModal
protected boolean isModal -
localEchoEnabled
protected boolean localEchoEnabled -
prefix
-
firstPrompt
-
initialSessionData
-
playerOnlyMessage
-
cancellers
-
abandonedListeners
-
-
构造器详细资料
-
ConversationFactory
Constructs a ConversationFactory.- 参数:
plugin
- The plugin that owns the factory.
-
-
方法详细资料
-
withModality
Sets the modality of allConversation
s created by this factory. If a conversation is modal, all messages directed to the player are suppressed for the duration of the conversation.The default is True.
- 参数:
modal
- The modality of all conversations to be created.- 返回:
- This object.
-
withLocalEcho
Sets the local echo status for allConversation
s created by this factory. If local echo is enabled, any text submitted to a conversation gets echoed back into the submitter's chat window.- 参数:
localEchoEnabled
- The status of local echo.- 返回:
- This object.
-
withPrefix
Sets theConversationPrefix
that prepends all output from all generated conversations.The default is a
NullConversationPrefix
;- 参数:
prefix
- The ConversationPrefix to use.- 返回:
- This object.
-
withTimeout
Sets the number of inactive seconds to wait before automatically abandoning all generated conversations.The default is 600 seconds (5 minutes).
- 参数:
timeoutSeconds
- The number of seconds to wait.- 返回:
- This object.
-
withFirstPrompt
Sets the first prompt to use in all generated conversations.The default is Prompt.END_OF_CONVERSATION.
- 参数:
firstPrompt
- The first prompt.- 返回:
- This object.
-
withInitialSessionData
Sets any initial data with which to populate the conversation context sessionData map.- 参数:
initialSessionData
- The conversation context's initial sessionData.- 返回:
- This object.
-
withEscapeSequence
Sets the player input that, when received, will immediately terminate the conversation.- 参数:
escapeSequence
- Input to terminate the conversation.- 返回:
- This object.
-
withConversationCanceller
Adds aConversationCanceller
to constructed conversations.- 参数:
canceller
- TheConversationCanceller
to add.- 返回:
- This object.
-
thatExcludesNonPlayersWithMessage
Prevents this factory from creating a conversation for non-playerConversable
objects.- 参数:
playerOnlyMessage
- The message to return to a non-play in lieu of starting a conversation.- 返回:
- This object.
-
addConversationAbandonedListener
Adds aConversationAbandonedListener
to all conversations constructed by this factory.- 参数:
listener
- The listener to add.- 返回:
- This object.
-
buildConversation
Constructs aConversation
in accordance with the defaults set for this factory.- 参数:
forWhom
- The entity for whom the new conversation is mediating.- 返回:
- A new conversation.
-