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