【发布时间】:2021-05-16 21:05:41
【问题描述】:
按照 YouTube 教程,但是当我运行插件时,Minecraft 根本没有注册它。 该插件旨在返回“嗨!”当播放 /hello 或 /hi 时。 当我将插件放在我的服务器上时,甚至没有在 /plugins 中注册
代码: Main.java:
package me.Cheese_Echidna.helloworld;
import me.Cheese_Echidna.helloworld.commands.HelloCommand;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
new HelloCommand(this);
}
}
HelloCommand.java:
package me.Cheese_Echidna.helloworld.commands;
import me.Cheese_Echidna.helloworld.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class HelloCommand implements CommandExecutor {
@SuppressWarnings("unused")
private Main plugin;
public HelloCommand(Main plugin) {
this.plugin = plugin;
plugin.getCommand("hello").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players may execute this command!");
return true;
}
Player p = (Player) sender;
if (p.hasPermission("hello.use")) {
p.sendMessage("Hi!");
return true;
} else {
p.sendMessage("You do not have permission to execute this command!");
}
return false;
}
}
plugin.yml:
name: HelloWorld
version: 1.0
author: Cheese_Echidna
main: me.Cheese_Echidna.helloworld.main
description: My first Bukkit plugin
commands:
hello:
aliases: [hi]
description: This is the hello command!
YT 教程: https://www.youtube.com/watch?v=XaU8JKQW0Ao
任何帮助将不胜感激。
【问题讨论】:
-
您是否正在以任何方式构建
.jar文件?写完代码后做什么?你是怎么把它放在你的服务器上的? -
我只是导出到 .jar
-
您好!您能否在启动时发布服务器控制台的输出?