Package org.bukkit.help

Examples of org.bukkit.help.HelpTopic


            pageHeight = ChatPaginator.CLOSED_CHAT_PAGE_HEIGHT - 1;
            pageWidth = ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH;
        }

        HelpMap helpMap = Bukkit.getServer().getHelpMap();
        HelpTopic topic = helpMap.getHelpTopic(command);

        if (topic == null) {
            topic = helpMap.getHelpTopic("/" + command);
        }

        if (topic == null) {
            topic = findPossibleMatches(command);
        }

        if (topic == null || !topic.canSee(sender)) {
            sender.sendMessage(ChatColor.RED + "No help for " + command);
            return true;
        }

        ChatPaginator.ChatPage page = ChatPaginator.paginate(topic.getFullText(sender), pageNumber, pageWidth, pageHeight);

        StringBuilder header = new StringBuilder();
        header.append(ChatColor.YELLOW);
        header.append("--------- ");
        header.append(ChatColor.WHITE);
        header.append("Help: ");
        header.append(topic.getName());
        header.append(" ");
        if (page.getTotalPages() > 1) {
            header.append("(");
            header.append(page.getPageNumber());
            header.append("/");
View Full Code Here


    }

    Iterator<HelpTopic> iter = topics.iterator();
    for (iter = topics.iterator(); iter.hasNext(); )
    {
      HelpTopic topic = iter.next();
      Bukkit.getHelpMap().addTopic(topic);

      // remove the aliases from the list before we populate the index
      if (topic instanceof AutoRefCommandHelpTopic &&
        ((AutoRefCommandHelpTopic) topic).isAlias()) iter.remove();
View Full Code Here

  private transient Collection<HelpTopic> helps = new ArrayList<HelpTopic>();
 
  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);
        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);
View Full Code Here

    }
  }
 
  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);
        final ArrayList<HelpTopic> as = new ArrayList<HelpTopic>((Collection<HelpTopic>) topics.get(aliases));
View Full Code Here

    }
   
    @Override
    public String getFullText(final @Nullable CommandSender forWho) {
      final StringBuilder sb = new StringBuilder(shortText);
      final HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
      if (aliasForTopic != null) {
        sb.append("\n");
        sb.append(aliasForTopic.getFullText(forWho));
      }
      return "" + sb.toString();
    }
View Full Code Here

    }
   
    @Override
    public boolean canSee(final @Nullable CommandSender commandSender) {
      if (amendedPermission == null) {
        final HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
        if (aliasForTopic != null) {
          return aliasForTopic.canSee(commandSender);
        } else {
          return false;
        }
      } else {
        return commandSender != null && commandSender.hasPermission(amendedPermission);
View Full Code Here

TOP

Related Classes of org.bukkit.help.HelpTopic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.