Java 类org.bukkit.help.IndexHelpTopic 实例源码

项目:Skript    文件:ScriptCommand.java   
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());
        }
    }
}
项目:Skript    文件:ScriptCommand.java   
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();
}
项目:NekoooGuilds    文件:BukkitCommands.java   
private IndexHelpTopic createHelpIndex() {
    return new IndexHelpTopic(
            this.getPluginName(),
            "Wszystkie komendy " + this.getPluginName(),
            null,
            this.getHelpTopics()
    );
}
项目:Arcade2    文件:BukkitCommands.java   
private IndexHelpTopic createHelpIndex() {
    return new IndexHelpTopic(
            this.getPluginName(),
            "Wszystkie komendy " + this.getPluginName(),
            null,
            this.getHelpTopics()
    );
}
项目:Thermos-Bukkit    文件:HelpCommand.java   
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;
    }
}
项目:CauldronGit    文件:HelpCommand.java   
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;
    }
}
项目:Cauldron    文件:HelpCommand.java   
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;
    }
}
项目:Cauldron    文件:HelpCommand.java   
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;
    }
}
项目:Cauldron    文件:HelpCommand.java   
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;
    }
}
项目:Almura-API    文件:HelpCommand.java   
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;
    }
}
项目:Spigot-API    文件:HelpCommand.java   
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;
    }
}
项目:Bukkit-JavaDoc    文件:HelpCommand.java   
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;
    }
}