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