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.World;
 import  org.bukkit.command.CommandSender;
 import  org.bukkit.entity.Player;
 
public class WorldArgumentHandler extends ArgumentHandler<World> {
		setMessage("world_not_found""The world \"%1\" was not found");
		addVariable("sender""The command executor"new ArgumentVariable<World>() {
			public World var(CommandSender senderCommandArgument argumentString varNamethrows CommandError {
				if(!(sender instanceof Player))
					throw new CommandError(argument.getMessage("cant_as_console"));
				return ((Player)sender).getWorld();
			}
		});
	}
	public World transform(CommandSender senderCommandArgument argumentString valuethrows TransformError {
		World world = Bukkit.getWorld(value);
		if(world == null)
			throw new TransformError(argument.getMessage("world_not_found"value));
		return world;
	}
New to GrepCode? Check out our FAQ X