你好命令
在下面的程式碼中,你可以看到如何向外掛新增命令。
MainClass.java
package yourpackage;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public class MainClass extends JavaPlugin {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("hello")) {
sender.sendMessage("Hey!");
}
return false;
}
}
Plugin.yml
name: HelloCommand
main: yourpackage.MainClass
version: 1.0
commands:
hello:
description: Hello