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


Java HelpTopic.canSee方法代码示例

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


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

示例1: canSee

import org.bukkit.help.HelpTopic; //导入方法依赖的package包/类
@Override
public boolean canSee(CommandSender commandSender) {
    if (amendedPermission == null) {
        HelpTopic aliasForTopic = helpMap.getHelpTopic(aliasFor);
        if (aliasForTopic != null) {
            return aliasForTopic.canSee(commandSender);
        } else {
            return false;
        }
    } else {
        return commandSender.hasPermission(amendedPermission);
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:14,代码来源:CommandAliasHelpTopic.java

示例2: canSee

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

示例3: execute

import org.bukkit.help.HelpTopic; //导入方法依赖的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.HelpTopic.canSee方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。