Package org.bukkit.conversations
Class NumericPrompt
- java.lang.Object
-
- org.bukkit.conversations.ValidatingPrompt
-
- org.bukkit.conversations.NumericPrompt
-
public abstract class NumericPrompt extends ValidatingPrompt
NumericPrompt is the base class for any prompt that requires aNumber
response from the user.
-
-
Field Summary
-
Fields inherited from interface org.bukkit.conversations.Prompt
END_OF_CONVERSATION
-
-
Constructor Summary
Constructors Constructor Description NumericPrompt()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract @Nullable Prompt
acceptValidatedInput(@NotNull ConversationContext context, @NotNull Number input)
Override this method to perform some action with the user's integer response.protected @Nullable Prompt
acceptValidatedInput(@NotNull ConversationContext context, @NotNull String input)
Override this method to accept and processes the validated input from the user.protected @Nullable String
getFailedValidationText(@NotNull ConversationContext context, @NotNull Number invalidInput)
Optionally override this method to display an additional message if the user enters an invalid numeric input.protected @Nullable String
getFailedValidationText(@NotNull ConversationContext context, @NotNull String invalidInput)
Optionally override this method to display an additional message if the user enters an invalid input.protected @Nullable String
getInputNotNumericText(@NotNull ConversationContext context, @NotNull String invalidInput)
Optionally override this method to display an additional message if the user enters an invalid number.protected boolean
isInputValid(@NotNull ConversationContext context, @NotNull String input)
Override this method to check the validity of the player's input.protected boolean
isNumberValid(@NotNull ConversationContext context, @NotNull Number input)
Override this method to do further validation on the numeric player input after the input has been determined to actually be a number.-
Methods inherited from class org.bukkit.conversations.ValidatingPrompt
acceptInput, blocksForInput
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.bukkit.conversations.Prompt
getPromptText
-
-
-
-
Method Detail
-
isInputValid
protected boolean isInputValid(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String input)
Description copied from class:ValidatingPrompt
Override this method to check the validity of the player's input.- Specified by:
isInputValid
in classValidatingPrompt
- Parameters:
context
- Context information about the conversation.input
- The player's raw console input.- Returns:
- True or false depending on the validity of the input.
-
isNumberValid
protected boolean isNumberValid(@NotNull @NotNull ConversationContext context, @NotNull @NotNull Number input)
Override this method to do further validation on the numeric player input after the input has been determined to actually be a number.- Parameters:
context
- Context information about the conversation.input
- The number the player provided.- Returns:
- The validity of the player's input.
-
acceptValidatedInput
@Nullable protected @Nullable Prompt acceptValidatedInput(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String input)
Description copied from class:ValidatingPrompt
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.- Specified by:
acceptValidatedInput
in classValidatingPrompt
- Parameters:
context
- Context information about the conversation.input
- The validated input text from the user.- Returns:
- The next Prompt in the prompt graph.
-
acceptValidatedInput
@Nullable protected abstract @Nullable Prompt acceptValidatedInput(@NotNull @NotNull ConversationContext context, @NotNull @NotNull Number input)
Override this method to perform some action with the user's integer response.
-
getFailedValidationText
@Nullable protected @Nullable String getFailedValidationText(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String invalidInput)
Description copied from class:ValidatingPrompt
Optionally override this method to display an additional message if the user enters an invalid input.- Overrides:
getFailedValidationText
in classValidatingPrompt
- Parameters:
context
- Context information about the conversation.invalidInput
- The invalid input provided by the user.- Returns:
- A message explaining how to correct the input.
-
getInputNotNumericText
@Nullable protected @Nullable String getInputNotNumericText(@NotNull @NotNull ConversationContext context, @NotNull @NotNull String invalidInput)
Optionally override this method to display an additional message if the user enters an invalid number.- Parameters:
context
- Context information about the conversation.invalidInput
- The invalid input provided by the user.- Returns:
- A message explaining how to correct the input.
-
getFailedValidationText
@Nullable protected @Nullable String getFailedValidationText(@NotNull @NotNull ConversationContext context, @NotNull @NotNull Number invalidInput)
Optionally override this method to display an additional message if the user enters an invalid numeric input.- Parameters:
context
- Context information about the conversation.invalidInput
- The invalid input provided by the user.- Returns:
- A message explaining how to correct the input.
-
-