Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PlayerNamePrompt.java
1 package org.bukkit.conversations;
2 
3 import org.bukkit.entity.Player;
4 import org.bukkit.plugin.Plugin;
5 
6 /**
7  * PlayerNamePrompt is the base class for any prompt that requires the player
8  * to enter another player's name.
9  */
10 public abstract class PlayerNamePrompt extends ValidatingPrompt{
11  private Plugin plugin;
12 
13  public PlayerNamePrompt(Plugin plugin) {
14  super();
15  this.plugin = plugin;
16  }
17 
18  @Override
19  protected boolean isInputValid(ConversationContext context, String input) {
20  return plugin.getServer().getPlayer(input) != null;
21 
22  }
23 
24  @Override
25  protected Prompt acceptValidatedInput(ConversationContext context, String input) {
26  return acceptValidatedInput(context, plugin.getServer().getPlayer(input));
27  }
28 
29  /**
30  * Override this method to perform some action with the user's player name
31  * response.
32  *
33  * @param context Context information about the conversation.
34  * @param input The user's player name response.
35  * @return The next {@link Prompt} in the prompt graph.
36  */
37  protected abstract Prompt acceptValidatedInput(ConversationContext context, Player input);
38 }
Player getPlayer(String name)