001 package org.bukkit.conversations; 002 003 import org.bukkit.entity.Player; 004 import org.bukkit.plugin.Plugin; 005 006 /** 007 * PlayerNamePrompt is the base class for any prompt that requires the player 008 * to enter another player's name. 009 */ 010 public abstract class PlayerNamePrompt extends ValidatingPrompt{ 011 private Plugin plugin; 012 013 public PlayerNamePrompt(Plugin plugin) { 014 super(); 015 this.plugin = plugin; 016 } 017 018 @Override 019 protected boolean isInputValid(ConversationContext context, String input) { 020 return plugin.getServer().getPlayer(input) != null; 021 022 } 023 024 @Override 025 protected Prompt acceptValidatedInput(ConversationContext context, String input) { 026 return acceptValidatedInput(context, plugin.getServer().getPlayer(input)); 027 } 028 029 /** 030 * Override this method to perform some action with the user's player name 031 * response. 032 * 033 * @param context Context information about the conversation. 034 * @param input The user's player name response. 035 * @return The next {@link Prompt} in the prompt graph. 036 */ 037 protected abstract Prompt acceptValidatedInput(ConversationContext context, Player input); 038 }