我正在学习创建MC插件,我正在尝试创建一个heal插件。当我测试它时,它给出了使用命令,而不是治愈我。
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>
答案 0 :(得分:0)
我没有导入onCommand但是Commandblocks ......