Minecraft插件加载失败: java.lang.IllegalArgumentException

huangapple go评论137阅读模式
英文:

Minecraft plugin load failed: java.lang.IllegalArgumentException

问题

我用 Spigot 制作了一个基本的 1.19 插件,并且用 Paper 加载它。但是它显示加载失败。这是异常:

[20:50:56 ERROR]: [DirectoryProviderSource] Error loading plugin: File 'plugins\Real_Craft.jar' failed to load!
java.lang.RuntimeException: File 'plugins\Real_Craft.jar' failed to load!
        at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:59) ~[paper-1.19.4.jar:git-Paper-483]
        ...
        ...
Caused by: java.lang.IllegalArgumentException: File 'plugins\Real_Craft.jar' is not a valid plugin file, cannot load a plugin from it!
        at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:54) ~[paper-1.19.4.jar:git-Paper-483]
        ... 20 more

我尝试从一些方法修复它,我遵循的教程链接是 https://www.youtube.com/watch?v=WcFb0GO14zY,并且我在我的代码中找不到错误。下面是我的 plugin.yml 文件和主脚本:

name: RealCraft
version: 1.0.0
author: knowscratcher
main: com.knowscratcher.realcraft.RealCraft
api-version: 1.19

我的主脚本是

package com.knowscratcher.realcraft;

import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

public class RealCraft extends JavaPlugin {

    @Override
    public void onEnable() {
        getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE+"[RealCraft]:Plugin is enabled");
    }

    @Override
    public void onDisable() {
        getServer().getConsoleSender().sendMessage(ChatColor.RED+"[RealCraft]:Plugin is disabled");
    }

}
英文:

I made a basic 1.19 plugin using spigot, and load it with paper. But it says load fail. This is the exception:

[20:50:56 ERROR]: [DirectoryProviderSource] Error loading plugin: File 'plugins\Real_Craft.jar' failed to load!
java.lang.RuntimeException: File 'plugins\Real_Craft.jar' failed to load!
        at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:59) ~[paper-1.19.4.jar:git-Paper-483]
        at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.lambda$registerProviders$2(DirectoryProviderSource.java:32) ~[paper-1.19.4.jar:git-Paper-483]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
        at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?]
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
        at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.registerProviders(DirectoryProviderSource.java:30) ~[paper-1.19.4.jar:git-Paper-483]
        at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.registerProviders(DirectoryProviderSource.java:14) ~[paper-1.19.4.jar:git-Paper-483]
        at io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(EntrypointUtil.java:14) ~[paper-1.19.4.jar:git-Paper-483]
        at io.papermc.paper.plugin.PluginInitializerManager.load(PluginInitializerManager.java:100) ~[paper-1.19.4.jar:git-Paper-483]
        at net.minecraft.server.Main.main(Main.java:126) ~[paper-1.19.4.jar:git-Paper-483]
        at org.bukkit.craftbukkit.Main.main(Main.java:309) ~[paper-1.19.4.jar:git-Paper-483]
        at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42) ~[app:?]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalArgumentException: File 'plugins\Real_Craft.jar' is not a valid plugin file, cannot load a plugin from it!
        at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:54) ~[paper-1.19.4.jar:git-Paper-483]
        ... 20 more

I tried to fix it from some ways to fix it, the tutorial I followed is https://www.youtube.com/watch?v=WcFb0GO14zY, and I can't find errors in my code. here's my plugin.yml and main script

name: RealCraft
version: 1.0.0
author: knowscratcher
main: com.knowscratcher.realcraft.RealCraft
api-version: 1.19

and my main script is

package com.knowscratcher.realcraft;

import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

public class RealCraft extends JavaPlugin {

    @Override
    public void onEnable() {
        getServer().getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE+"[RealCraft]:Plugin is enabled");
    }

    @Override
    public void onDisable() {
        getServer().getConsoleSender().sendMessage(ChatColor.RED+"[RealCraft]:Plugin is disabled");
    }

}

答案1

得分: 0

如果 plugin.yml 文件不在 jar 包中,bukkit、spigot 和 paper 就无法加载插件。确保在最终的 jar 包中包含它。你可以手动操作,但我不建议这样做。

你应该使用项目管理器来自动包含 plugin.yml。

在这里你可以看到一个使用 Maven 的极简插件的示例:https://github.com/OnyxianSoul/SendConsoleMessage。

如果你按照相同的方式设置文件夹结构和 pom.xml,并使用 Maven 构建你的 jar 包,你的插件 jar 包将包含必要的文件,并正确加载。

祝好运

英文:

If the plugin.yml file isn't on the jar, bukkit, spigot and paper cannot load the plugin. You need to make sure to include it in the final jar. You can do it manually, but I don't recommend it.

You should use a project manager to make the plugin.yml automatically included.

Here you can see an example of an extremely simple plugin that uses Maven: https://github.com/OnyxianSoul/SendConsoleMessage .

If you set up your folder structure and pom.xml in the same way, and use maven to build your jar, your plugin jar will include the necessairy files, and will be loaded correctly.

Good luck

答案2

得分: -1

尝试在Intellij上使用Minecraft开发插件,它会设置工作空间。根据您的错误信息,似乎您的插件没有包含必要的文件,以便被正确识别。https://plugins.jetbrains.com/plugin/8327-minecraft-development
总的来说,这也更容易使用。

英文:

Try using the Minecraft Development plugin on Intellij, it sets up the workspace. According to your error it seems like your plugin doesn't contain the files for it to be properly recognized. https://plugins.jetbrains.com/plugin/8327-minecraft-development
It's also just a lot easier to use in general.

huangapple
  • 本文由 发表于 2023年3月31日 21:03:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75898880.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定