本文整理匯總了Java中cn.nukkit.command.CommandSender.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java CommandSender.getName方法的具體用法?Java CommandSender.getName怎麽用?Java CommandSender.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cn.nukkit.command.CommandSender
的用法示例。
在下文中一共展示了CommandSender.getName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import cn.nukkit.command.CommandSender; //導入方法依賴的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;
}
String name = args[0].toLowerCase();
Player player = sender.getServer().getPlayer(name);
if (player == null) {
sender.sendMessage(new TranslationContainer("commands.generic.player.notFound"));
return true;
}
if (Objects.equals(player, sender)) {
sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.message.sameTarget"));
return true;
}
String msg = "";
for (int i = 1; i < args.length; i++) {
msg += args[i] + " ";
}
if (msg.length() > 0) {
msg = msg.substring(0, msg.length() - 1);
}
String displayName = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName());
sender.sendMessage("[" + sender.getName() + " -> " + player.getDisplayName() + "] " + msg);
player.sendMessage("[" + displayName + " -> " + player.getName() + "] " + msg);
return true;
}
示例2: execute
import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String senderString;
if (sender instanceof Player) {
senderString = ((Player) sender).getDisplayName();
} else if (sender instanceof ConsoleCommandSender) {
senderString = "Server";
} else {
senderString = sender.getName();
}
String msg = "";
for (String arg : args) {
msg += arg + " ";
}
if (msg.length() > 0) {
msg = msg.substring(0, msg.length() - 1);
}
sender.getServer().broadcastMessage(new TranslationContainer(
TextFormat.LIGHT_PURPLE + "%chat.type.announcement",
new String[]{senderString, TextFormat.LIGHT_PURPLE + msg}
));
return true;
}
示例3: execute
import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (args.length == 0) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
String name;
if (sender instanceof Player) {
name = ((Player) sender).getDisplayName();
} else {
name = sender.getName();
}
String msg = "";
for (String arg : args) {
msg += arg + " ";
}
if (msg.length() > 0) {
msg = msg.substring(0, msg.length() - 1);
}
sender.getServer().broadcastMessage(new TranslationContainer("chat.type.emote", new String[]{name, TextFormat.WHITE + msg}));
return true;
}
示例4: execute
import cn.nukkit.command.CommandSender; //導入方法依賴的package包/類
@Override
public boolean execute(CommandSender sender, String s, String[] args){
if(!sender.hasPermission(this.getPermission())){
sender.sendMessage(TextFormat.RED+"You don't have permission.");
return true;
}
if(args.length == 0){
if(plugin.status == 0){
plugin.set = sender.getName();
sender.sendMessage(TextFormat.GREEN+"你已經處於設置狀態下,請先設置一個4(寬)*5(高)的方框");
}else{
sender.sendMessage(TextFormat.RED+"已經設置 或 你處於設置狀態");
}
}else if(args[0].equals("b")){
plugin.status = 0;
plugin.set = "";
plugin.player = null;
plugin.line = null;
plugin.start = null;
plugin.top = null;
plugin.pos1 = null;
plugin.pos2 = null;
plugin.first = 0.0D;
sender.sendMessage(TextFormat.GREEN+"成功退出設置");
}
return true;
}