Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
org.bukkit.conversations.ValidatingPrompt Class Referenceabstract
Inheritance diagram for org.bukkit.conversations.ValidatingPrompt:
org.bukkit.conversations.Prompt org.bukkit.conversations.BooleanPrompt org.bukkit.conversations.FixedSetPrompt org.bukkit.conversations.NumericPrompt org.bukkit.conversations.PlayerNamePrompt org.bukkit.conversations.RegexPrompt

Public Member Functions

Prompt acceptInput (ConversationContext context, String input)
 
boolean blocksForInput (ConversationContext context)
 
- Public Member Functions inherited from org.bukkit.conversations.Prompt
String getPromptText (ConversationContext context)
 

Protected Member Functions

abstract boolean isInputValid (ConversationContext context, String input)
 
abstract Prompt acceptValidatedInput (ConversationContext context, String input)
 
String getFailedValidationText (ConversationContext context, String invalidInput)
 

Additional Inherited Members

- Static Public Attributes inherited from org.bukkit.conversations.Prompt
static final Prompt END_OF_CONVERSATION = null
 

Detailed Description

ValidatingPrompt is the base class for any prompt that requires validation. ValidatingPrompt will keep replaying the prompt text until the user enters a valid response.

Definition at line 10 of file ValidatingPrompt.java.

Member Function Documentation

Prompt org.bukkit.conversations.ValidatingPrompt.acceptInput ( ConversationContext  context,
String  input 
)

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.

Parameters
contextContext information about the conversation.
inputThe input text from the user.
Returns
This prompt or the next Prompt in the prompt graph.

Implements org.bukkit.conversations.Prompt.

Definition at line 24 of file ValidatingPrompt.java.

References org.bukkit.conversations.ValidatingPrompt.acceptValidatedInput(), org.bukkit.conversations.ValidatingPrompt.getFailedValidationText(), org.bukkit.conversations.ConversationContext.getForWhom(), org.bukkit.conversations.ValidatingPrompt.isInputValid(), org.bukkit.ChatColor.RED, and org.bukkit.conversations.Conversable.sendRawMessage().

24  {
25  if (isInputValid(context, input)) {
26  return acceptValidatedInput(context, input);
27  } else {
28  String failPrompt = getFailedValidationText(context, input);
29  if (failPrompt != null) {
30  context.getForWhom().sendRawMessage(ChatColor.RED + failPrompt);
31  }
32  // Redisplay this prompt to the user to re-collect input
33  return this;
34  }
35  }
String getFailedValidationText(ConversationContext context, String invalidInput)
abstract Prompt acceptValidatedInput(ConversationContext context, String input)
abstract boolean isInputValid(ConversationContext context, String input)
abstract Prompt org.bukkit.conversations.ValidatingPrompt.acceptValidatedInput ( ConversationContext  context,
String  input 
)
abstractprotected

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.

Parameters
contextContext information about the conversation.
inputThe validated input text from the user.
Returns
The next Prompt in the prompt graph.

Referenced by org.bukkit.conversations.ValidatingPrompt.acceptInput().

boolean org.bukkit.conversations.ValidatingPrompt.blocksForInput ( ConversationContext  context)

Ensures that the prompt waits for the user to provide input.

Parameters
contextContext information about the conversation.
Returns
True.

Implements org.bukkit.conversations.Prompt.

Definition at line 43 of file ValidatingPrompt.java.

43  {
44  return true;
45  }
String org.bukkit.conversations.ValidatingPrompt.getFailedValidationText ( ConversationContext  context,
String  invalidInput 
)
protected

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

Parameters
contextContext information about the conversation.
invalidInputThe invalid input provided by the user.
Returns
A message explaining how to correct the input.

Definition at line 75 of file ValidatingPrompt.java.

Referenced by org.bukkit.conversations.ValidatingPrompt.acceptInput().

75  {
76  return null;
77  }
abstract boolean org.bukkit.conversations.ValidatingPrompt.isInputValid ( ConversationContext  context,
String  input 
)
abstractprotected

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

Parameters
contextContext information about the conversation.
inputThe player's raw console input.
Returns
True or false depending on the validity of the input.

Referenced by org.bukkit.conversations.ValidatingPrompt.acceptInput().


The documentation for this class was generated from the following file: