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


Java Player.sendActionBarTitle方法代码示例

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


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

示例1: execute

import cn.nukkit.Player; //导入方法依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!this.testPermission(sender)) {
        return true;
    }
    if (args.length < 2) {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    Player player = Server.getInstance().getPlayerExact(args[0]);
    if (player == null) {
        sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
        return true;
    }

    if (args.length == 2) {
        switch (args[1].toLowerCase()) {
            case "clear":
                player.clearTitle();
                sender.sendMessage(new TranslationContainer("nukkit.command.title.clear", player.getName()));
                break;
            case "reset":
                player.resetTitleSettings();
                sender.sendMessage(new TranslationContainer("nukkit.command.title.reset", player.getName()));
                break;
            default:
                sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
                return false;
        }
    } else if (args.length == 3){
        switch (args[1].toLowerCase()) {
            case "title":
                player.sendTitle(args[2]);
                sender.sendMessage(new TranslationContainer("nukkit.command.title.title", new String[]{TextFormat.clean(args[2]), player.getName()}));
                break;
            case "subtitle":
                player.setSubtitle(args[2]);
                sender.sendMessage(new TranslationContainer("nukkit.command.title.subtitle", new String[]{TextFormat.clean(args[2]), player.getName()}));
                break;
            case "actionbar":
                player.sendActionBarTitle(args[2]);
                sender.sendMessage(new TranslationContainer("nukkit.command.title.actionbar", new String[]{TextFormat.clean(args[2]), player.getName()}));
                break;
            default:
                sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
                return false;
        }
    } else if (args.length == 5) {
        if (args[1].toLowerCase().equals("times")) {
            try {
                player.setTitleAnimationTimes(Integer.valueOf(args[2]), //fadeIn
                        Integer.valueOf(args[3]), //stay
                        Integer.valueOf(args[4])); //fadeOut
                sender.sendMessage(new TranslationContainer("nukkit.command.title.times.success", new String[]{
                        args[2], args[3], args[4], player.getName()}));
            } catch (NumberFormatException exception) {
                sender.sendMessage(new TranslationContainer(TextFormat.RED + "%nukkit.command.title.times.fail"));
            }
        } else {
            sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
            return false;
        }
    } else {
        sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
        return false;
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:71,代码来源:TitleCommand.java


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