org.bukkit.help.HelpMap Java Examples
The following examples show how to use
org.bukkit.help.HelpMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScriptCommand.java From Skript with GNU General Public License v3.0 | 6 votes |
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 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<>((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()); } } }
Example #2
Source File: CommandAliasHelpTopic.java From Kettle with GNU General Public License v3.0 | 5 votes |
public CommandAliasHelpTopic(String alias, String aliasFor, HelpMap helpMap) { this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor; this.helpMap = helpMap; this.name = alias.startsWith("/") ? alias : "/" + alias; Validate.isTrue(!this.name.equals(this.aliasFor), "Command " + this.name + " cannot be alias for itself"); this.shortText = ChatColor.YELLOW + "Alias for " + ChatColor.WHITE + this.aliasFor; }
Example #3
Source File: Commands.java From Skript with GNU General Public License v3.0 | 5 votes |
public CommandAliasHelpTopic(final String alias, final String aliasFor, final HelpMap helpMap) { this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor; this.helpMap = helpMap; name = alias.startsWith("/") ? alias : "/" + alias; Validate.isTrue(!name.equals(this.aliasFor), "Command " + name + " cannot be alias for itself"); shortText = ChatColor.YELLOW + "Alias for " + ChatColor.WHITE + this.aliasFor; }
Example #4
Source File: CommandAliasHelpTopic.java From Thermos with GNU General Public License v3.0 | 5 votes |
public CommandAliasHelpTopic(String alias, String aliasFor, HelpMap helpMap) { this.aliasFor = aliasFor.startsWith("/") ? aliasFor : "/" + aliasFor; this.helpMap = helpMap; this.name = alias.startsWith("/") ? alias : "/" + alias; Validate.isTrue(!this.name.equals(this.aliasFor), "Command " + this.name + " cannot be alias for itself"); this.shortText = ChatColor.YELLOW + "Alias for " + ChatColor.WHITE + this.aliasFor; }
Example #5
Source File: HelpCommand.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public boolean execute(CommandSender sender, String currentAlias, String[] args) { if (!testPermission(sender)) return true; String command; int pageNumber; int pageHeight; int pageWidth; if (args.length == 0) { command = ""; pageNumber = 1; } else if (NumberUtils.isDigits(args[args.length - 1])) { command = StringUtils.join(ArrayUtils.subarray(args, 0, args.length - 1), " "); try { pageNumber = NumberUtils.createInteger(args[args.length - 1]); } catch (NumberFormatException exception) { pageNumber = 1; } if (pageNumber <= 0) { pageNumber = 1; } } else { command = StringUtils.join(args, " "); pageNumber = 1; } if (sender instanceof ConsoleCommandSender) { pageHeight = ChatPaginator.UNBOUNDED_PAGE_HEIGHT; pageWidth = ChatPaginator.UNBOUNDED_PAGE_WIDTH; } else { 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("/"); header.append(page.getTotalPages()); header.append(") "); } header.append(ChatColor.YELLOW); for (int i = header.length(); i < ChatPaginator.GUARANTEED_NO_WRAP_CHAT_PAGE_WIDTH; i++) { header.append("-"); } sender.sendMessage(header.toString()); sender.sendMessage(page.getLines()); return true; }
Example #6
Source File: CustomIndexHelpTopic.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) { super(name, shortText, permission, new HashSet<HelpTopic>(), preamble); this.helpMap = helpMap; this.futureTopics = futureTopics; }
Example #7
Source File: CraftServer.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public HelpMap getHelpMap() { return helpMap; }
Example #8
Source File: MockServer.java From Chimera with MIT License | 4 votes |
@Override public HelpMap getHelpMap() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
Example #9
Source File: MockServer.java From SaneEconomy with GNU General Public License v3.0 | 4 votes |
@Override public HelpMap getHelpMap() { return null; }
Example #10
Source File: CustomIndexHelpTopic.java From Thermos with GNU General Public License v3.0 | 4 votes |
public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) { super(name, shortText, permission, new HashSet<HelpTopic>(), preamble); this.helpMap = helpMap; this.futureTopics = futureTopics; }
Example #11
Source File: CraftServer.java From Thermos with GNU General Public License v3.0 | 4 votes |
@Override public HelpMap getHelpMap() { return helpMap; }
Example #12
Source File: Server.java From Kettle with GNU General Public License v3.0 | 2 votes |
/** * Gets the {@link HelpMap} providing help topics for this server. * * @return a help map for this server */ public HelpMap getHelpMap();
Example #13
Source File: Bukkit.java From Kettle with GNU General Public License v3.0 | 2 votes |
/** * Gets the {@link HelpMap} providing help topics for this server. * * @return a help map for this server */ public static HelpMap getHelpMap() { return server.getHelpMap(); }