當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。