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


Java PluginCommand.getAliases方法代码示例

本文整理汇总了Java中org.bukkit.command.PluginCommand.getAliases方法的典型用法代码示例。如果您正苦于以下问题:Java PluginCommand.getAliases方法的具体用法?Java PluginCommand.getAliases怎么用?Java PluginCommand.getAliases使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.command.PluginCommand的用法示例。


在下文中一共展示了PluginCommand.getAliases方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unRegisterBukkitCommand

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
public void unRegisterBukkitCommand(PluginCommand cmd) {
    try {
        Object result = getPrivateField(plugin.getServer().getPluginManager(), "commandMap");
        SimpleCommandMap commandMap = (SimpleCommandMap) result;
        Object map = getPrivateField(commandMap, "knownCommands");
        @SuppressWarnings("unchecked")
        HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
        knownCommands.remove(cmd.getName());
        for (String alias : cmd.getAliases()) {
            if (knownCommands.containsKey(alias) && knownCommands.get(alias).toString().contains(plugin.getName())) {
                knownCommands.remove(alias);
            }
        }
    } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        plugin.getLogger().severe(e.toString());
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:18,代码来源:CommandManager.java

示例2: unRegisterBukkitCommand

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
 * unregister a command, credits to zeeveener for his awesome code to unregister commands!
 * 
 * @author zeeveener, xize
 * @param cmd - the command to be unregistered
 */
public void unRegisterBukkitCommand(PluginCommand cmd) {
	try {
		Object result = getPrivateField(Bukkit.getServer().getPluginManager(), "commandMap");
		SimpleCommandMap commandMap = (SimpleCommandMap) result;
		Object map = getPrivateField(commandMap, "knownCommands");
		@SuppressWarnings("unchecked")
		HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
		knownCommands.remove("xessentials"+":"+cmd.getName());
		if(knownCommands.containsKey(cmd.getName()) && knownCommands.get(cmd.getName().toLowerCase()).toString().contains(pl.getName())) {
			knownCommands.remove(cmd.getName());
		}
		for (String alias : cmd.getAliases()){
			if(knownCommands.containsKey("xessentials:"+alias) && knownCommands.get("xessentials:"+alias).toString().contains(pl.getName())){
				knownCommands.remove("xessentials:"+alias);
			}
			if(knownCommands.containsKey(alias) && knownCommands.get(alias).toString().contains(pl.getName())){
				knownCommands.remove(alias);
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:30,代码来源:CommandManager.java

示例3: unregisterBukkitCommand

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
public static void unregisterBukkitCommand(PluginCommand cmd) {
	try {
		Object result = getPrivateField(Bukkit.getServer().getPluginManager(), "commandMap");
		SimpleCommandMap commandMap = (SimpleCommandMap) result;
		Object map = getPrivateField(commandMap, "knownCommands");
		@SuppressWarnings("unchecked")
		HashMap<String, Command> knownCommands = (HashMap<String, Command>) map;
		knownCommands.remove(cmd.getName());
		for (String alias : cmd.getAliases()) {
			if(knownCommands.containsKey(alias) && knownCommands.get(alias).toString().contains(Bukkit.getName())) {
				knownCommands.remove(alias);
			}
		}
	}
	catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:jalapeno777,项目名称:AdminAid,代码行数:19,代码来源:CommandUtilities.java

示例4: execute

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
@Override
public void execute(Command command) {

    CommandSender sender = command.getSender();

    sender.sendMessage(ChatColor.GREEN + "==========[ MovieSets Help ]==========");

    PluginCommand registeredCommand = Bukkit.getPluginCommand("moviesets");
    String aliases = ChatColor.DARK_GREEN + "/" + registeredCommand.getLabel() + ChatColor.AQUA + ", ";
    for (String alias : registeredCommand.getAliases()) {
        aliases += ChatColor.DARK_GREEN + "/" + alias + ChatColor.AQUA + ", ";
    }
    aliases = aliases.substring(0, aliases.length() - 2);
    sender.sendMessage("Aliases: " + ChatColor.DARK_GREEN + aliases);

    List<CommandHandler> commandHandlers = ((CommandExecutor) registeredCommand.getExecutor()).getCommandHandlers();
    for (CommandHandler commandHandler : commandHandlers) {
        CommandInfo info = commandHandler.getInfo();

        if (! (sender instanceof Player) || info.getPermission() == null || ((Player) sender).hasPermission(info.getPermission())) {
            for (String label : info.getLabels()) {
                String printLabel = "";
                if (!label.equalsIgnoreCase("<empty>")) {
                    printLabel = " " + label;
                }

                String parameterUsage = "";
                if (info.getParameterUsage() != null && !info.getParameterUsage().isEmpty()) {
                    parameterUsage = " " + info.getParameterUsage();
                }

                sender.sendMessage(ChatColor.GOLD + "/" + command.getGlobalLabel() + printLabel + parameterUsage);
            }

            sender.sendMessage(ChatColor.DARK_RED + "  > " + ChatColor.GRAY + info.getDescription());
        }
    }
}
 
开发者ID:UnratedFilmIndustries,项目名称:MovieSets,代码行数:39,代码来源:HelpCommand.java

示例5: getEquivalentCommands

import org.bukkit.command.PluginCommand; //导入方法依赖的package包/类
/**
 * Computes a list containing equivalent commands of an input command. For instance, if input is "/aach stats", the
 * returned list is: ["aach stats", "advancedachievements stats", "aachievements stats", "aa stats"]
 * 
 * @param command
 * @return the list of commands have the same effect as the input one
 */
private List<String> getEquivalentCommands(String command) {
	int firstSpaceIndex = command.indexOf(' ');
	String commandName;
	String commandParameters;
	if (firstSpaceIndex >= 0) {
		commandName = command.substring(1, firstSpaceIndex);
		// Command parameters start with an initial space.
		commandParameters = command.substring(firstSpaceIndex).toLowerCase();
	} else {
		commandName = command.substring(1);
		commandParameters = "";
	}

	PluginCommand pluginCommand = plugin.getServer().getPluginCommand(commandName);
	if (pluginCommand == null || pluginCommand.getAliases() == null) {
		return Arrays.asList(commandName.toLowerCase() + commandParameters);
	}

	List<String> equivalentCommands = new ArrayList<>(pluginCommand.getAliases().size() + 1);
	// Aliases don't contain the main plugin command, add it to the returned list.
	equivalentCommands.add(pluginCommand.getName().toLowerCase() + commandParameters);
	for (String alias : pluginCommand.getAliases()) {
		equivalentCommands.add(alias.toLowerCase() + commandParameters);
	}
	return equivalentCommands;
}
 
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:34,代码来源:AchievePlayerCommandListener.java


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