类 ValidatingPrompt

java.lang.Object
org.bukkit.conversations.ValidatingPrompt
所有已实现的接口:
Cloneable, Prompt
直接已知子类:
BooleanPrompt, FixedSetPrompt, NumericPrompt, PlayerNamePrompt, RegexPrompt

public abstract class ValidatingPrompt extends Object implements Prompt
ValidatingPrompt 是任何需要验证的提示的基类。ValidatingPrompt 将不断重放提示文本,直到用户输入有效的响应。
  • 构造器详细资料

    • ValidatingPrompt

      public ValidatingPrompt()
  • 方法详细资料

    • acceptInput

      接受并处理来自用户的输入并进行验证。如果验证失败,返回此提示以重新执行,否则返回提示图中的下一个 Prompt。

      原文: Accepts and processes input from the user and validates it. If validation fails, this prompt is returned for re-execution, otherwise the next Prompt in the prompt graph is returned.

      指定者:
      acceptInput 在接口中 Prompt
      参数:
      context - 关于对话的上下文信息。
      input - 来自用户的输入文本。
      返回:
      此提示或提示图中的下一个 Prompt。
    • blocksForInput

      public boolean blocksForInput(@NotNull @NotNull ConversationContext context)
      确保提示等待用户提供输入。

      原文: Ensures that the prompt waits for the user to provide input.

      指定者:
      blocksForInput 在接口中 Prompt
      参数:
      context - 关于对话的上下文信息。
      返回:
      True。
    • isInputValid

      protected abstract boolean isInputValid(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String input)
      覆盖此方法以检查玩家输入的有效性。

      原文: Override this method to check the validity of the player's input.

      参数:
      context - 关于对话的上下文信息。
      input - 玩家的原始控制台输入。
      返回:
      根据输入的有效性返回 true 或 false。
    • acceptValidatedInput

      @Nullable protected abstract @Nullable Prompt acceptValidatedInput(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String input)
      覆盖此方法以接受并处理来自用户的验证输入。使用输入,应返回提示图中的下一个 Prompt。

      原文: Override this method to accept and processes the validated input from the user. Using the input, the next Prompt in the prompt graph should be returned.

      参数:
      context - 关于对话的上下文信息。
      input - 来自用户的验证输入文本。
      返回:
      提示图中的下一个 Prompt。
    • getFailedValidationText

      @Nullable protected @Nullable String getFailedValidationText(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String invalidInput)
      可选择覆盖此方法以在用户输入无效输入时显示额外消息。

      原文: Optionally override this method to display an additional message if the user enters an invalid input.

      参数:
      context - 关于对话的上下文信息。
      invalidInput - 用户提供的无效输入。
      返回:
      解释如何纠正输入的消息。