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


Java HelpMap类代码示例

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


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

示例1: registerHelp

import org.bukkit.help.HelpMap; //导入依赖的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: testHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Test
public void testHelpMap() {
    HelpTopic topicTacos = new TestHelpTopic("taco", "Makes tacos", "taco.taco");
    HelpTopic topicDebuggery = new TestHelpTopic("debuggery", "Exposes API stuffs", "d.g");

    HelpMap helpMap = new TestHelpMap(topicTacos, topicDebuggery);

    String out = OutputFormatter.getOutput(helpMap);

    assertNotNull(out);
    assertTrue(out.contains(topicTacos.getName()));
    assertTrue(out.contains(topicTacos.getShortText()));
    assertTrue(out.contains(topicDebuggery.getName()));
    assertTrue(out.contains(topicDebuggery.getShortText()));
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:16,代码来源:OutputFormatterTest.java

示例3: CommandAliasHelpTopic

import org.bukkit.help.HelpMap; //导入依赖的package包/类
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;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:8,代码来源:CommandAliasHelpTopic.java

示例4: getOutput

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Nullable
public static String getOutput(@Nullable Object object) {

    if (object == null) {
        return null;
    }

    if (object instanceof String) {
        return (String) object;
    } else if (object instanceof Collection) {
        return handleCollection((Collection) object);
    } else if (object instanceof Map) {
        return handleMap((Map) object);
    } else if (object.getClass().isArray()) {
        return handleArray(object);
    } else if (object instanceof OfflinePlayer) {
        return handleOfflinePlayer((OfflinePlayer) object);
    } else if (object instanceof BlockState) {
        return handleBlockState((BlockState) object);
    } else if (object instanceof Inventory) {
        return handleInventory((Inventory) object);
    } else if (object instanceof WorldBorder) {
        return handleWorldBorder((WorldBorder) object);
    } else if (object instanceof CommandSender) {
        return handleCommandSender((CommandSender) object);
    } else if (object instanceof Messenger) {
        return handleMessenger((Messenger) object);
    } else if (object instanceof HelpMap) {
        return handleHelpMap((HelpMap) object);
    } else {
        return String.valueOf(object);
    }
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:34,代码来源:OutputFormatter.java

示例5: handleHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Nonnull
private static String handleHelpMap(HelpMap helpMap) {
    StringBuilder returnString = new StringBuilder("[");

    for (HelpTopic topic : helpMap.getHelpTopics()) {
        returnString.append("{").append(topic.getName()).append(", ").append(topic.getShortText()).append("}\n");
    }

    return returnString.append("]").toString();
}
 
开发者ID:zachbr,项目名称:Debuggery,代码行数:11,代码来源:OutputFormatter.java

示例6: CommandAliasHelpTopic

import org.bukkit.help.HelpMap; //导入依赖的package包/类
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;
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:8,代码来源:Commands.java

示例7: CustomIndexHelpTopic

import org.bukkit.help.HelpMap; //导入依赖的package包/类
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;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:6,代码来源:CustomIndexHelpTopic.java

示例8: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Override
public HelpMap getHelpMap() {
    return helpMap;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:5,代码来源:CraftServer.java

示例9: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Override
public HelpMap getHelpMap()
{
	// TODO Auto-generated method stub
	throw new UnimplementedOperationException();
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:7,代码来源:ServerMock.java

示例10: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Override
public HelpMap getHelpMap() {
   throw new UnsupportedOperationException();
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:5,代码来源:FlexServerImpl.java

示例11: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Override
public HelpMap getHelpMap() {
    return null; // TODO: Create help map implementation once commands are done.
}
 
开发者ID:Proximyst,项目名称:Bukkit2Sponge,代码行数:5,代码来源:FakeServer.java

示例12: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Override
public HelpMap getHelpMap() {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:6,代码来源:NetherServer.java

示例13: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@Override
public HelpMap getHelpMap() {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
开发者ID:Pante,项目名称:Karus-Commons,代码行数:5,代码来源:StubServer.java

示例14: getHelpMap

import org.bukkit.help.HelpMap; //导入依赖的package包/类
/**
 * @see Server#getHelpMap()
 */
public static HelpMap getHelpMap() {
    return server.getHelpMap();
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:7,代码来源:Bukkit.java

示例15: execute

import org.bukkit.help.HelpMap; //导入依赖的package包/类
@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;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:78,代码来源:HelpCommand.java


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