Java Minecraft 插件命令无效

Java Minecraft Plugin command not working

我刚刚开始 Minecraft 插件开发,希望得到一些帮助,了解为什么我的插件不能 100% 工作。我的意思是,“/help MyFirstPluginYay”之类的东西正在工作,但实际命令“/hello”不是,所以我相信它可能是我的代码。 (它可能是我的插件之一,但对此表示怀疑) 插件加载正常,没有任何错误,并在启动时向控制台发送消息。

我正在使用 Craftbukkit 1.8 快照。
请其他人测试我的代码,或指出任何明显的错误。

这是我的插件源代码

package me.MorrisKid.myfirstplugin;

import java.util.logging.Logger;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;

public class main extends JavaPlugin {
    public Logger logger = Logger.getLogger("Minecraft");
    public void onEnable(){
        PluginDescriptionFile pdffile = this.getDescription();
        this.logger.info(pdffile.getName() + " Has been enabled");
    }
    public void onDisable(){
        PluginDescriptionFile pdffile = this.getDescription();
        this.logger.info(pdffile + " Has been disabled");
    }
    public boolean onCommand(Command cmd, CommandSender sender, String label, String[] args){
        if(label.equalsIgnoreCase("hello")){
            Player p = (Player) sender;
            p.sendMessage("Hello!");
        }   
        return true;
    }
}

如果需要,您可以获得插件文件的副本,and/or 为插件编译的 Jar

here
下载编译好的jar 从 here

下载完整目录

您必须有一个 plugin.yml 文件 - 这样 bukkit 就会知道哪个插件负责该命令。如果你没有,那显然是行不通的。它可能看起来像这样:(确保名称中没有 space)

name: MorrisKid's_plugin
main: me.MorrisKid.myfirstplugin.main
version: 1.0.0
load: startup
description: this is my first plugin
commands:
  hello:
    description: greeting the player!
    usage: /<command>

*我没有测试这个 yml,所以请检查它是否正确并且没有语法 errors.Check 这个 youtuber 的视频: https://www.youtube.com/watch?v=_EUPVpqwvZw 他解释了 plugin.yml 文件。