NoClassDefFoundError - 插口插件 java

NoClassDefFoundError - spigot plugin java

出于某种原因,当我尝试使用我的命令时它打印出一个错误:NoClassDefFoundError

(我还是 java 的菜鸟) 我的主文件:

package test;
import org.bukkit.plugin.java.JavaPlugin;
public class plugin extends JavaPlugin {
    @Override
    public void onEnable() {
        getLogger().info("Ready!");
        getCommand("test").setExecutor(new Test(this));
    }
    @Override
    public void onDisable() {
        getLogger().info("Bye!");
    }
}

和命令文件:

package test;
import app.netlify.eggsnham07plugin.Logger;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class Test implements CommandExecutor {
private plugin plugin;
public Test(plugin plugin) {
    this.plugin = plugin;
}
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Logger.info("Command used!"+args.length);
        return true;
    }

}

然后我导入的文件:

//author eggsnham07
package app.netlify.eggsnham07plugin;
public class Logger {
    public static void info(String content) {
        System.out.println("[INFO]: " + content);
    }
    public static void warn(String content) {
        System.out.println("WARN]: "+content);
    }
}

plugin.yml:

name: MyPlugin
main: test.plugin
version: 1.0
api-version: 1.16
commands:
   test:
      usage: /<command>

每次我使用命令 /test arg1 arg2 它都会打印上面的错误,这里是堆栈跟踪:

[10:09:34] [Server thread/WARN]: Unexpected exception while parsing console command "test arg1 arg2"
org.bukkit.command.CommandException: Unhandled exception executing command 'test' in plugin MyPlugin v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:762) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(CraftServer.java:747) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at net.minecraft.server.v1_16_R3.DedicatedServer.handleCommandQueue(DedicatedServer.java:387) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:356) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1008) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:847) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda[=15=](MinecraftServer.java:164) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        at java.lang.Thread.run(Thread.java:832) [?:?]
Caused by: java.lang.NoClassDefFoundError: app/netlify/eggsnham07plugin/Logger
        at test.Test.onCommand(Test.java:13) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-1.16.5.jar:3014-Spigot-73fb609-b7eed25]
        ... 9 more

我尝试搜索类似的问题,但找到了 none, 感谢您的帮助!

编辑:我让它在另一个项目中工作,我通过将它添加到我的 pom.xml 来做到这一点,但它还不适用于我的插件

好吧,我刚刚在我的项目中制作了一个新包 class,它可以正常工作,所以我现在将使用它

编辑:我发现了 Rouge 的意思,我需要将 Logger 项目导出为插件并将其依赖于 plugin.yml