程序包 org.bukkit.conversations

# 类 ConversationFactory

java.lang.Object
org.bukkit.conversations.ConversationFactory

public class ConversationFactory extends Object
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>`
  `abandonedListeners`
  `protected List<ConversationCanceller>`
  `cancellers`
  `protected Prompt`
  `firstPrompt`
  `protected Map<Object,Object>`
  `initialSessionData`
  `protected boolean`
  `isModal`
  `protected boolean`
  `localEchoEnabled`
  `protected String`
  `playerOnlyMessage`
  `protected Plugin`
  `plugin`
  `protected ConversationPrefix`
  `prefix`

- ## 构造器概要

  构造器
  构造器
  说明
  `ConversationFactory(@NotNull Plugin plugin)`
  Constructs a ConversationFactory.

- ## 方法概要

  修饰符和类型
  方法
  说明
  `@NotNull ConversationFactory`
  `addConversationAbandonedListener(@NotNull ConversationAbandonedListener listener)`
  Adds a `ConversationAbandonedListener` to all conversations constructed by this factory.
  `@NotNull Conversation`
  `buildConversation(@NotNull Conversable forWhom)`
  Constructs a `Conversation` in accordance with the defaults set for this factory.
  `@NotNull ConversationFactory`
  `thatExcludesNonPlayersWithMessage(@Nullable String playerOnlyMessage)`
  Prevents this factory from creating a conversation for non-player `Conversable` objects.
  `@NotNull ConversationFactory`
  `withConversationCanceller(@NotNull ConversationCanceller canceller)`
  Adds a `ConversationCanceller` to constructed conversations.
  `@NotNull ConversationFactory`
  `withEscapeSequence(@NotNull String escapeSequence)`
  Sets the player input that, when received, will immediately terminate the conversation.
  `@NotNull ConversationFactory`
  `withFirstPrompt(@Nullable Prompt firstPrompt)`
  Sets the first prompt to use in all generated conversations.
  `@NotNull ConversationFactory`
  `withInitialSessionData(@NotNull Map<Object,Object> initialSessionData)`
  Sets any initial data with which to populate the conversation context sessionData map.
  `@NotNull ConversationFactory`
  `withLocalEcho(boolean localEchoEnabled)`
  Sets the local echo status for all `Conversation`s created by this factory.
  `@NotNull ConversationFactory`
  `withModality(boolean modal)`
  Sets the modality of all `Conversation`s created by this factory.
  `@NotNull ConversationFactory`
  `withPrefix(@NotNull ConversationPrefix prefix)`
  Sets the `ConversationPrefix` that prepends all output from all generated conversations.
  `@NotNull ConversationFactory`
  `withTimeout(int timeoutSeconds)`
  Sets the number of inactive seconds to wait before automatically abandoning all generated conversations.

  ### 从类继承的方法 java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 字段详细资料

  - ### plugin

    protected Plugin plugin

  - ### isModal

    protected boolean isModal

  - ### localEchoEnabled

    protected boolean localEchoEnabled

  - ### prefix

    protected ConversationPrefix prefix

  - ### firstPrompt

    protected Prompt firstPrompt

  - ### initialSessionData

    protected Map<Object,Object> initialSessionData

  - ### playerOnlyMessage

    protected String playerOnlyMessage

  - ### cancellers

    protected List<ConversationCanceller> cancellers

  - ### abandonedListeners

    protected List<ConversationAbandonedListener> abandonedListeners

- ## 构造器详细资料

  - ### ConversationFactory

    public ConversationFactory(@NotNull @NotNull Plugin plugin)
    Constructs a ConversationFactory.
    参数:
      `plugin` - The plugin that owns the factory.

- ## 方法详细资料

  - ### withModality

    @NotNull public @NotNull ConversationFactory withModality(boolean modal)
    Sets the modality of all `Conversation`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

    @NotNull public @NotNull ConversationFactory withLocalEcho(boolean localEchoEnabled)
    Sets the local echo status for all `Conversation`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

    @NotNull public @NotNull ConversationFactory withPrefix(@NotNull @NotNull ConversationPrefix prefix)
    Sets the `ConversationPrefix` that prepends all output from all generated conversations.

    The default is a `NullConversationPrefix`;

    参数:
      `prefix` - The ConversationPrefix to use.
    返回:
      This object.

  - ### withTimeout

    @NotNull public @NotNull ConversationFactory withTimeout(int timeoutSeconds)
    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

    @NotNull public @NotNull ConversationFactory withFirstPrompt(@Nullable @Nullable Prompt firstPrompt)
    Sets the first prompt to use in all generated conversations.

    The default is Prompt.END_OF_CONVERSATION.

    参数:
      `firstPrompt` - The first prompt.
    返回:
      This object.

  - ### withInitialSessionData

    @NotNull public @NotNull ConversationFactory withInitialSessionData(@NotNull @NotNull Map<Object,Object> initialSessionData)
    Sets any initial data with which to populate the conversation context sessionData map.
    参数:
      `initialSessionData` - The conversation context's initial sessionData.
    返回:
      This object.

  - ### withEscapeSequence

    @NotNull public @NotNull ConversationFactory withEscapeSequence(@NotNull @NotNull String escapeSequence)
    Sets the player input that, when received, will immediately terminate the conversation.
    参数:
      `escapeSequence` - Input to terminate the conversation.
    返回:
      This object.

  - ### withConversationCanceller

    @NotNull public @NotNull ConversationFactory withConversationCanceller(@NotNull @NotNull ConversationCanceller canceller)
    Adds a `ConversationCanceller` to constructed conversations.
    参数:
      `canceller` - The `ConversationCanceller` to add.
    返回:
      This object.

  - ### thatExcludesNonPlayersWithMessage

    @NotNull public @NotNull ConversationFactory thatExcludesNonPlayersWithMessage(@Nullable @Nullable String playerOnlyMessage)
    Prevents this factory from creating a conversation for non-player `Conversable` objects.
    参数:
      `playerOnlyMessage` - The message to return to a non-play in lieu of starting a conversation.
    返回:
      This object.

  - ### addConversationAbandonedListener

    @NotNull public @NotNull ConversationFactory addConversationAbandonedListener(@NotNull @NotNull ConversationAbandonedListener listener)
    Adds a `ConversationAbandonedListener` to all conversations constructed by this factory.
    参数:
      `listener` - The listener to add.
    返回:
      This object.

  - ### buildConversation

    @NotNull public @NotNull Conversation buildConversation(@NotNull @NotNull Conversable forWhom)
    Constructs a `Conversation` in accordance with the defaults set for this factory.
    参数:
      `forWhom` - The entity for whom the new conversation is mediating.
    返回:
      A new conversation.