if (sender instanceof Player)
{
Player player = (Player) sender;
AutoRefMatch match = AutoReferee.getInstance().getMatch(player.getWorld());
Role role = match == null ? AutoRefMatch.Role.NONE : match.getRole(player);
if (!role.atLeast(permissions.role()))
throw new CommandPermissionException(command, match == null
? "Command available only within an AutoReferee match"
: ("Command not available to " + role.toString().toLowerCase()));
for (String node : permissions.nodes()) if (!player.hasPermission(node))
throw new CommandPermissionException(command, "Insufficient permissions");
}
}