當前位置: 首頁>>代碼示例>>Java>>正文


Java Player.resetTitleSettings方法代碼示例

本文整理匯總了Java中cn.nukkit.Player.resetTitleSettings方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.resetTitleSettings方法的具體用法?Java Player.resetTitleSettings怎麽用?Java Player.resetTitleSettings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cn.nukkit.Player的用法示例。


在下文中一共展示了Player.resetTitleSettings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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:Rsplwe,項目名稱:Nukkit-Java9,代碼行數:71,代碼來源:TitleCommand.java

示例2: 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.resetTitleSettings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。