LoginSystem/src/main/java/fr/xephi/authme/command/PlayerCommand.java
ljacqu a0da423a7b Minor - Javadoc changes
- Add/replace/improve javadoc in the commands and encryption section
- Note: A simple <p> is the javadoc way to make a new paragraph
http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#format
- Note: Do not escape '<' and '>' inside of {@code }
- Note: '>' does not need to be escaped
2015-12-31 13:32:41 +01:00

47 lines
1.6 KiB
Java

package fr.xephi.authme.command;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* Common base type for player-only commands, handling the verification that the command sender is indeed a player.
*/
public abstract class PlayerCommand implements ExecutableCommand {
@Override
public void executeCommand(CommandSender sender, List<String> arguments, CommandService commandService) {
if (sender instanceof Player) {
runCommand((Player) sender, arguments, commandService);
} else {
String alternative = getAlternativeCommand();
if (alternative != null) {
sender.sendMessage("Player only! Please use " + alternative + " instead.");
} else {
sender.sendMessage("This command is only for players.");
}
}
}
/**
* Run the command with the given player and arguments.
*
* @param player The player who initiated the command
* @param arguments The arguments supplied with the command
* @param commandService The command service
*/
protected abstract void runCommand(Player player, List<String> arguments, CommandService commandService);
/**
* Return an alternative command (textual representation) that is not restricted to players only.
* Example: {@code "authme register <playerName> <password>"}
*
* @return Alternative command not only for players, or null if not applicable
*/
protected String getAlternativeCommand() {
return null;
}
}