所以我试图为我的世界创建一个插件。第一个版本工作正常,它只有/愈合和/ h现在我已经添加了/ day和/ weed并且它不再起作用了。当我在游戏中输入/ pl时,它没有显示" kBase"
插件类:
@Override
public void onEnable() {
System.out.println("kBase has been enabled");
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("heal") || cmd.getName().equalsIgnoreCase("h")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player.hasPermission("kbase.heal")) {
if(args.length == 0){
((Damageable) sender).setHealth(20);
sender.sendMessage(ChatColor.GREEN + "You have been healed!");
} else if(args.length == 1){
String playerName = args[0];
Player selected = Bukkit.getServer().getPlayer(playerName);
if (selected == null) {
sender.sendMessage(ChatColor.RED + "The player" + ChatColor.GOLD + playerName + ChatColor.RED + "Is not online");
} else {
selected.setHealth(20.0);
selected.sendMessage(ChatColor.GREEN + "You have been healed");
sender.sendMessage(ChatColor.GREEN + "You have healed" + ChatColor.GOLD + playerName);
}
}
} else {
player.sendMessage(ChatColor.RED + "You do not have enough permissions");
}
}else if (cmd.getName().equalsIgnoreCase("day")) {
if (sender instanceof Player) {
Player player = (Player) sender;
World world = player.getWorld();
if (player.hasPermission("kbase.day")) {
world.setTime(0);
player.sendMessage(ChatColor.GREEN + "LET THERE BE LIGHT!");
} else {
player.sendMessage(ChatColor.RED + "You do not have enough permissions");
}
}else if (cmd.getName().equalsIgnoreCase("weed")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player.hasPermission("kbase.weed")) {
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 100, 1));
} else {
player.sendMessage(ChatColor.RED + "You do not have enough permissions");
}
}
}
}
}
return false;
}
此课程中没有任何错误
plugins.yml:
name: kBase
main: pw.klassic.kbase.kBase
version: 1.0
commands:
heal:
description: Heals yourself or someone else
h:
description: Heals yourself or someone else
day:
description: Makes the time day
weed:
description: Smoke weed everyday
permissions:
kbase.heal:
default: op
kbase.day:
default: op
kbase.weed
default: op
控制台日志:
~Klassic
答案 0 :(得分:1)
在plugin.yml
文件中,行kbase.weed
最后没有:
。