Mc bukkit heal 插件提供 /usage 而不是命令
Mc bukkit heal plugin gives /usage instead of command
我正在学习创建 MC 插件并且正在尝试创建一个治疗插件。当我测试它时,它给出了用法命令而不是给我治疗。
package com.test.test;
// import and package extends JavaPlugin
public void onEnabled() {
getLogger().info(getDescription().getName() + " has been enabled!!!!");
}
public void onDisabled() {
getLogger().info(getDescription().getName() + " has been disabled!!!!");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (label.equalsIgnoreCase("full-life")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length == 0){
player.setHealth(player.getMaxHealth());
player.sendMessage("You have been healed!");
} else if(Bukkit.getPlayer(args[0] )!= null) {
Player target = Bukkit.getPlayer(args[0]);
target.setHealth(target.getMaxHealth());
player.sendMessage("The player" + target.getName() + "has been healed!");
target.sendMessage("Player" + player.getName() + "has healed you!");
}
} else {
}
}
return true;
}
Plugin.yml:
name: Test
main: com.test.test.Test
author: TheAsher
version: 1.0
commands:
full-life:
description: Get full lives
usage: /<commmand> <player>
我没有导入 onCommand,而是导入命令块...
我正在学习创建 MC 插件并且正在尝试创建一个治疗插件。当我测试它时,它给出了用法命令而不是给我治疗。
package com.test.test;
// import and package extends JavaPlugin
public void onEnabled() {
getLogger().info(getDescription().getName() + " has been enabled!!!!");
}
public void onDisabled() {
getLogger().info(getDescription().getName() + " has been disabled!!!!");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (label.equalsIgnoreCase("full-life")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if(args.length == 0){
player.setHealth(player.getMaxHealth());
player.sendMessage("You have been healed!");
} else if(Bukkit.getPlayer(args[0] )!= null) {
Player target = Bukkit.getPlayer(args[0]);
target.setHealth(target.getMaxHealth());
player.sendMessage("The player" + target.getName() + "has been healed!");
target.sendMessage("Player" + player.getName() + "has healed you!");
}
} else {
}
}
return true;
}
Plugin.yml:
name: Test
main: com.test.test.Test
author: TheAsher
version: 1.0
commands:
full-life:
description: Get full lives
usage: /<commmand> <player>
我没有导入 onCommand,而是导入命令块...