Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package se.ranzdo.bukkit.methodcommand.handlers;
 
 import  org.bukkit.Bukkit;
 import  org.bukkit.command.CommandSender;
 import  org.bukkit.entity.Player;
 
public class PlayerArgumentHandler extends ArgumentHandler<Player> {
		setMessage("player_not_online""The player %1 is not online");
		addVariable("sender""The command executor"new ArgumentVariable<Player>() {
			public Player var(CommandSender senderCommandArgument argumentString varNamethrows CommandError {
				if(!(sender instanceof Player))
					throw new CommandError(argument.getMessage("cant_as_console"));
				return ((Player)sender);
			}
		});
	}
	public Player transform(CommandSender senderCommandArgument argumentString valuethrows TransformError {
		Player p = Bukkit.getPlayer(value);
		if(p == null)
			throw new TransformError(argument.getMessage("player_not_online"value));
		return p;
	}
New to GrepCode? Check out our FAQ X