如何在 Minecraft 中制作自定义操作命令
how to make a custom op command in Minecraft
我想知道如何在 .jar 插件中创建自定义命令,以提供指定的播放器操作员状态。
创建插件,如 official spigot wiki or here
中所述
创建一个新命令,如 official spigot wiki
中所述
当玩家运行命令时,使用player.setOp(true);
完整命令示例(必须 运行ned 作为控制台):
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof ConsoleCommandSender) { // only for console
if(args.length == 0 || Bukkit.getPlayer(args[0]) == null) { // don't give player or unknow name
sender.sendMessage("Unknow given player");
} else {
Player cible = Bukkit.getPlayer(args[0]);
cible.setOp(true);
sender.sendMessage(cible.getName() + " is now OP");
}
} else {
sender.sendMessage("You are not allowed to do this");
}
return false;
}
我想知道如何在 .jar 插件中创建自定义命令,以提供指定的播放器操作员状态。
创建插件,如 official spigot wiki or here
中所述创建一个新命令,如 official spigot wiki
中所述当玩家运行命令时,使用
player.setOp(true);
完整命令示例(必须 运行ned 作为控制台):
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof ConsoleCommandSender) { // only for console
if(args.length == 0 || Bukkit.getPlayer(args[0]) == null) { // don't give player or unknow name
sender.sendMessage("Unknow given player");
} else {
Player cible = Bukkit.getPlayer(args[0]);
cible.setOp(true);
sender.sendMessage(cible.getName() + " is now OP");
}
} else {
sender.sendMessage("You are not allowed to do this");
}
return false;
}