当前位置: 首页>>代码示例>>Java>>正文


Java CommandPermissionsException类代码示例

本文整理汇总了Java中com.sk89q.minecraft.util.commands.CommandPermissionsException的典型用法代码示例。如果您正苦于以下问题:Java CommandPermissionsException类的具体用法?Java CommandPermissionsException怎么用?Java CommandPermissionsException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandPermissionsException类属于com.sk89q.minecraft.util.commands包,在下文中一共展示了CommandPermissionsException类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: take

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "take", "remove" }, desc = "Gives the specified player a rank.", min = 2, max = 2)
@CommandPermissions("cardinal.ranks.take")
public static void take(final CommandContext args, final CommandSender sender) throws CommandException {
    Player target = Bukkit.getPlayer(args.getString(0));
    if (!sender.hasPermission("cardinal.ranks.take." + args.getString(1))) {
        throw new CommandPermissionsException();
    }

    if (!PermissionModule.rankExists(args.getString(1))) {
        sender.sendMessage(ChatColor.RED + "The specified rank does not exist!");
        return;
    }

    if (!PermissionModule.hasRank(target.getUniqueId(), args.getString(1))) {
        sender.sendMessage(ChatColor.RED + "The specified player is not a member of that rank!");
        return;
    }
    
    PermissionModule.takeRank(target.getUniqueId(), args.getString(1));
    Bukkit.getServer().getPluginManager().callEvent(new PlayerNameUpdateEvent(target));
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:22,代码来源:RankCommands.java

示例2: restart

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "restart"}, desc = "Restarts the server", usage = "<time>", min = 0, max = 1)
public static void restart(final CommandContext args, CommandSender sender) throws Exception {
	if(sender instanceof Player) {
		if(!Client.getClient((Player)sender).isRanked()) {
			sender.sendMessage(ChatColor.RED + "No permission!");
			throw new CommandPermissionsException();
		}
	}

	Match match = Rixor.getRotation().getSlot().getMatch();
	if(match.isCurrentlyRunning()) {
		match.end(true);
	}
	if (args.argsLength() == 0){
		Rixor.getRotation().getSlot().getMatch().restart(30);
	}
	else {
		Rixor.getRotation().getSlot().getMatch().restart(args.getInteger(0));
	}

}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:22,代码来源:RestartCommand.java

示例3: admin

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "admin", "a" , "adminchat"}, desc = "Speaks in admin chat", usage = "[message]", min = 1, max = -1)
public static void admin(final CommandContext args, CommandSender sender) throws Exception { {
	if(sender instanceof Player) {
		if(!Client.getClient((Player)sender).isRanked()) {
				throw new CommandPermissionsException();
		}
	}
	
	String message = args.getJoinedStrings(0);
	for (Player Online : Bukkit.getOnlinePlayers()) {
		if (Client.getClient((Player) Online).isRanked()) {
			Online.sendMessage(ChatColor.WHITE + "[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + (Client.getClient((Player) sender).getStars()) + (Client.getClient((Player) sender).getTeam().getColor()) + sender.getName() + ChatColor.GRAY + ": " + ChatColor.WHITE + message);
		}
	}
	}
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:17,代码来源:AdminChat.java

示例4: channel

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(
        aliases = "t",
        desc = "Sends a message to the team channel (or sets the team channel to your default channel).",
        usage = "[message...]",
        min = 0,
        max = -1,
        anyFlags = true
)
public static void teamChat(CommandContext args, CommandSender sender) throws CommandException {
    MatchPlayer player = CommandUtils.senderToMatchPlayer(sender);

    if (player.getBukkit().hasPermission(ChannelMatchModule.TEAM_SEND_PERMISSION)) {
        ChannelMatchModule cmm = player.getMatch().needMatchModule(ChannelMatchModule.class);

        if (args.argsLength() == 0) {
            cmm.setTeamChat(player, true);
            player.sendMessage(new TranslatableComponent("command.chat.team.switchSuccess"));
        } else {
            Channel channel = cmm.getChannel(player.getParty());
            channel.sendMessage(args.getJoinedStrings(0), player.getBukkit());
            if (!player.getBukkit().hasPermission(channel.getListeningPermission())) {
                sender.sendMessage(ChatColor.YELLOW + PGMTranslations.t("command.chat.team.success", player));
            }
        }
    } else {
        throw new CommandPermissionsException();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:29,代码来源:ChannelCommands.java

示例5: give

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "give", "add" }, desc = "Gives the specified player a rank.", min = 2, max = 2)
@CommandPermissions("cardinal.ranks.give")
public static void give(final CommandContext args, final CommandSender sender) throws CommandException {
    if (!sender.hasPermission("cardinal.ranks.give." + args.getString(1))) {
        throw new CommandPermissionsException();
    }

    Player target = Bukkit.getPlayer(args.getString(0));
    if (!PermissionModule.rankExists(args.getString(1))) {
        sender.sendMessage(ChatColor.RED + "The specified rank does not exist!");
        return;
    }

    if (PermissionModule.hasRank(target.getUniqueId(), args.getString(1))) {
        sender.sendMessage(ChatColor.RED + "The specified player is already a member of that rank!");
        return;
    }
    
    if (target.isOp()) {
        if (PermissionModule.isStaffRank(args.getString(1))) {
            sender.sendMessage(ChatColor.RED + "The specified player is opped!");
            return;
        }
    }
    
    PermissionModule.giveRank(target.getUniqueId(), args.getString(1));
    Bukkit.getServer().getPluginManager().callEvent(new PlayerNameUpdateEvent(target));
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:29,代码来源:RankCommands.java

示例6: call

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Override
public Object call(String arguments, CommandLocals locals, String[] parentCommands) throws CommandException {
    // We have permission for this command if we have permissions for subcommands
    if (!testPermission(locals)) {
        throw new CommandPermissionsException();
    }

    String[] split = arguments.split(" ", -1);
    Set<String> aliases = getPrimaryAliases();

    if (aliases.isEmpty()) {
        throw new InvalidUsageException("This command has no sub-commands.", this);
    } else if (split.length > 0) {
        String subCommand = split[0];
        String subArguments = Joiner.on(" ").join(Arrays.copyOfRange(split, 1, split.length));
        String[] subParents = Arrays.copyOf(parentCommands, parentCommands.length + 1);
        subParents[parentCommands.length] = subCommand;
        CommandMapping mapping = get(subCommand);

        if (mapping != null) {
            try {
                return mapping.getCallable().call(subArguments, locals, subParents);
            } catch (CommandException e) {
                e.prependStack(subCommand);
                throw e;
            } catch (Throwable t) {
                throw new WrappedCommandException(t);
            }
        }

    }

    throw new InvalidUsageException("Please choose a sub-command.", this, true);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:SimpleDispatcher.java

示例7: cycle

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "cycle"}, desc = "Cycles the map", usage = "[seconds]", min = 1, max = 1)
public static void cycle(final CommandContext args, CommandSender sender) throws Exception {
	if(sender instanceof Player) {
		if(!Client.getClient((Player)sender).isRanked()) {
			sender.sendMessage(ChatColor.RED + "No permission!");
			throw new CommandPermissionsException();
		}
	}
	
	Match match = Rixor.getRotation().getSlot().getMatch();
	if(match.isCurrentlyRunning()) {
		match.end(true);
	}
	
	int time = 0;
	if(args.argsLength() == 1)
		if(ConversionUtil.convertStringToInteger(args.getString(0),0) >= 1)
			time = ConversionUtil.convertStringToInteger(args.getString(0), 0);
		else {
			throw new CommandException("Please supply a valid time greater than or equal to 1.");
		}
	
	if(!match.isCurrentlyCycling()) Rixor.getRotation().getSlot().getMatch().stop();
	else Rixor.getRotation().getSlot().getMatch().setCycling(time);
	
	Rixor.getRotation().getSlot().getMatch().cycle(time);
	for (Player Online : Bukkit.getOnlinePlayers()) {
		if (Client.getClient((Player) Online).isRanked()) {
			Online.sendMessage(ChatColor.WHITE + "[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + (Client.getClient((Player) sender).getStars()) + (Client.getClient((Player) sender).getTeam().getColor()) + sender.getName() + ChatColor.WHITE + " has started the cycle at " + ChatColor.GOLD + time);
			}
	}
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:33,代码来源:CycleCommand.java

示例8: start

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "start"}, desc = "Starts the match", usage = "[seconds]", flags = "f", min = 1, max = 1)
public static void start(final CommandContext args, CommandSender sender) throws Exception {

	if(sender instanceof Player) {
		if(!Client.getClient((Player)sender).isRanked()) {
			sender.sendMessage(ChatColor.RED + "No permission!");
			throw new CommandPermissionsException();
		}
	}

	Match match = Rixor.getRotation().getSlot().getMatch();
	if(!match.isCurrentlyStarting()) {
		throw new CommandException("A match is already running!");
	}
	
	int time = 30;
	if(args.argsLength() == 1)
		if(ConversionUtil.convertStringToInteger(args.getString(0),-1) > -1)
			time = ConversionUtil.convertStringToInteger(args.getString(0), -1);
		else {
			throw new CommandException("Please supply a valid time greater than -1");
		}
	if (match.isHasEnded() && args.hasFlag('f')){
		Rixor.getRotation().getSlot().getMatch().start(time);
	}
	else if (match.isHasEnded()) {
		throw new CommandException("This match has already ended. Use -f to force start.");
	}
	Rixor.getRotation().getSlot().getMatch().start(time);
	/*Rixor.broadcast(ChatColor.RED + sender.getName() + ChatColor.DARK_PURPLE + " has started the countdown.");*/
	for (Player Online : Bukkit.getOnlinePlayers()) {
		if (Client.getClient((Player) Online).isRanked()) {

			Online.sendMessage(ChatColor.WHITE + "[" + ChatColor.GOLD + "A" + ChatColor.WHITE + "] " + (Client.getClient((Player) sender).getStars()) + (Client.getClient((Player) sender).getTeam().getColor()) + sender.getName() + ChatColor.WHITE + " has started the countdown at " + time + ".");

		}
	}

}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:40,代码来源:StartCommand.java

示例9: update

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = { "update", "updateplugin"}, desc = "Updates the plugin to the latest version", usage = "", min = 0, max = -1)
public static void update(final CommandContext args, CommandSender sender) throws Exception {
	if(sender instanceof Player) {
		if(!Client.getClient((Player)sender).isRanked()) {
			throw new CommandPermissionsException();
		}
	}

	UpdateUtil.checkForUpdate("http://update.masterejay.us/Version.txt","http://update.masterejay.us/Rixor.jar",
			Rixor.getInstance().getDescription(),(Player)sender);
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:12,代码来源:UpdateCommand.java

示例10: cardinal

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(aliases = "cardinal", flags = "vru", desc = "Various functions related to Cardinal.", min = 0, max = 0)
public static void cardinal(final CommandContext cmd, CommandSender sender) throws CommandPermissionsException {
    if (cmd.hasFlag('v')) {
        sender.sendMessage(ChatColor.GOLD + ChatConstant.UI_VERSION.asMessage(new UnlocalizedChatMessage(Cardinal.getInstance().getDescription().getVersion())).getMessage(ChatUtil.getLocale(sender)));
        sender.sendMessage(ChatColor.GOLD + ChatConstant.UI_JAVA_VERSION.asMessage(new UnlocalizedChatMessage(System.getProperty("java.version"))).getMessage(ChatUtil.getLocale(sender)));
        if (System.getProperty("java.version").startsWith("1.7")) {
            sender.sendMessage(ChatColor.DARK_RED + ChatConstant.UI_JAVA_UPDATE.getMessage(ChatUtil.getLocale(sender)));
        }
        Bukkit.getScheduler().runTaskAsynchronously(Cardinal.getInstance(), UpdateHandler.getUpdateHandler().getNotificationTask(sender));
    }
    if (cmd.hasFlag('r')) {
        if (sender.hasPermission("cardinal.reload")) {
            Cardinal.getInstance().reloadConfig();
            sender.sendMessage(new UnlocalizedChatMessage(ChatColor.GREEN + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_CONFIG_RELOAD)).getMessage(sender instanceof Player ? ((Player) sender).getLocale() : Locale.getDefault().toString()));
            Cardinal.getInstance().registerRanks();
            sender.sendMessage(new UnlocalizedChatMessage(ChatColor.GREEN + "{0}", new LocalizedChatMessage(ChatConstant.GENERIC_RANKS_RELOAD)).getMessage(sender instanceof Player ? ((Player) sender).getLocale() : Locale.getDefault().toString()));
        } else {
            throw new CommandPermissionsException();
        }
    }
    if (cmd.hasFlag('u')) {
        if (sender.hasPermission("cardinal.update")) {
            Bukkit.getScheduler().runTaskAsynchronously(Cardinal.getInstance(), UpdateHandler.getUpdateHandler().getUpdateTask(sender));
        } else {
            throw new CommandPermissionsException();
        }
    }
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:29,代码来源:CardinalCommand.java

示例11: queueRestart

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
@Command(
    aliases = {"queuerestart", "qr"},
    desc = "Restart the server at the next safe opportunity",
    usage = "[-l/h (low/high priority)]",
    min = 0,
    max = 0,
    flags = "lh"
)
@CommandPermissions("server.queuerestart")
@Console
public void queueRestart(CommandContext args, final CommandSender sender) throws CommandException {
    final Audience audience = audiences.get(sender);

    final int priority;
    if(args.hasFlag('l')) {
        priority = ServerDoc.Restart.Priority.LOW;
    } else if(args.hasFlag('h')) {
        if(!sender.hasPermission("server.queuerestart.high")) {
            throw new CommandPermissionsException();
        }
        priority = ServerDoc.Restart.Priority.HIGH;
    } else {
        priority = ServerDoc.Restart.Priority.NORMAL;
    }

    if(restartManager.isRestartRequested(priority)) {
        audience.sendMessage(new TranslatableComponent("command.admin.queueRestart.restartQueued"));
        return;
    }

    syncExecutor.callback(
        restartManager.requestRestart("/queuerestart command", priority),
        CommandFutureCallback.onSuccess(sender, args, result -> {
            if(restartManager.isRestartDeferred()) {
                audience.sendMessage(new TranslatableComponent("command.admin.queueRestart.restartQueued"));
            } else {
                audience.sendMessage(new TranslatableComponent("command.admin.queueRestart.restartingNow"));
            }
        })
    );
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:42,代码来源:RestartCommands.java

示例12: assertPermission

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
public static void assertPermission(Permissible permissible, String permission) throws CommandPermissionsException {
    if(!permissible.hasPermission(permission)) {
        throw new CommandPermissionsException();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:CommandUtils.java

示例13: permission

import com.sk89q.minecraft.util.commands.CommandPermissionsException; //导入依赖的package包/类
public boolean permission(CommandSender sender, @Nullable Type type) throws CommandException {
    if(!sender.hasPermission(fromType(type))) {
        throw new CommandPermissionsException();
    }
    return true;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:PunishmentCommands.java


注:本文中的com.sk89q.minecraft.util.commands.CommandPermissionsException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。