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


Java IndexHelpTopic类代码示例

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


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

示例1: registerHelp

import org.bukkit.help.IndexHelpTopic; //导入依赖的package包/类
public void registerHelp() {
	helps.clear();
	final HelpMap help = Bukkit.getHelpMap();
	final HelpTopic t = new GenericCommandHelpTopic(bukkitCommand);
	help.addTopic(t);
	helps.add(t);
	final HelpTopic aliases = help.getHelpTopic("Aliases");
	if (aliases != null && aliases instanceof IndexHelpTopic) {
		aliases.getFullText(Bukkit.getConsoleSender()); // CraftBukkit has a lazy IndexHelpTopic class (org.bukkit.craftbukkit.help.CustomIndexHelpTopic) - maybe its used for aliases as well
		try {
			final Field topics = IndexHelpTopic.class.getDeclaredField("allTopics");
			topics.setAccessible(true);
			@SuppressWarnings("unchecked")
			final ArrayList<HelpTopic> as = new ArrayList<HelpTopic>((Collection<HelpTopic>) topics.get(aliases));
			for (final String alias : activeAliases) {
				final HelpTopic at = new CommandAliasHelpTopic("/" + alias, "/" + getLabel(), help);
				as.add(at);
				helps.add(at);
			}
			Collections.sort(as, HelpTopicComparator.helpTopicComparatorInstance());
			topics.set(aliases, as);
		} catch (final Exception e) {
			Skript.outdatedError(e);//, "error registering aliases for /" + getName());
		}
	}
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:27,代码来源:ScriptCommand.java

示例2: unregisterHelp

import org.bukkit.help.IndexHelpTopic; //导入依赖的package包/类
public void unregisterHelp() {
	Bukkit.getHelpMap().getHelpTopics().removeAll(helps);
	final HelpTopic aliases = Bukkit.getHelpMap().getHelpTopic("Aliases");
	if (aliases != null && aliases instanceof IndexHelpTopic) {
		try {
			final Field topics = IndexHelpTopic.class.getDeclaredField("allTopics");
			topics.setAccessible(true);
			@SuppressWarnings("unchecked")
			final ArrayList<HelpTopic> as = new ArrayList<HelpTopic>((Collection<HelpTopic>) topics.get(aliases));
			as.removeAll(helps);
			topics.set(aliases, as);
		} catch (final Exception e) {
			Skript.outdatedError(e);//, "error unregistering aliases for /" + getName());
		}
	}
	helps.clear();
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:18,代码来源:ScriptCommand.java

示例3: createHelpIndex

import org.bukkit.help.IndexHelpTopic; //导入依赖的package包/类
private IndexHelpTopic createHelpIndex() {
    return new IndexHelpTopic(
            this.getPluginName(),
            "Wszystkie komendy " + this.getPluginName(),
            null,
            this.getHelpTopics()
    );
}
 
开发者ID:NekoooGuilds,项目名称:NekoooGuilds,代码行数:9,代码来源:BukkitCommands.java

示例4: findPossibleMatches

import org.bukkit.help.IndexHelpTopic; //导入依赖的package包/类
protected HelpTopic findPossibleMatches(String searchString) {
    int maxDistance = (searchString.length() / 5) + 3;
    Set<HelpTopic> possibleMatches = new TreeSet<HelpTopic>(HelpTopicComparator.helpTopicComparatorInstance());

    if (searchString.startsWith("/")) {
        searchString = searchString.substring(1);
    }

    for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) {
        String trimmedTopic = topic.getName().startsWith("/") ? topic.getName().substring(1) : topic.getName();

        if (trimmedTopic.length() < searchString.length()) {
            continue;
        }

        if (Character.toLowerCase(trimmedTopic.charAt(0)) != Character.toLowerCase(searchString.charAt(0))) {
            continue;
        }

        if (damerauLevenshteinDistance(searchString, trimmedTopic.substring(0, searchString.length())) < maxDistance) {
            possibleMatches.add(topic);
        }
    }

    if (possibleMatches.size() > 0) {
        return new IndexHelpTopic("Search", null, null, possibleMatches, "Search for: " + searchString);
    } else {
        return null;
    }
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:31,代码来源:HelpCommand.java


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