为什么我的plugin.yml加载? Bukkit

时间:2016-11-20 14:26:21

标签: java plugins bukkit

我目前正在使用Bukkit中的插件,但我在加载它时遇到了一些问题。当我尝试启动服务器时,会出现如下错误消息:

Loading libraries, please wait...
[15:04:32 INFO]: Starting minecraft server version 1.10.2
[15:04:32 INFO]: Loading properties
[15:04:32 INFO]: Default game type: SURVIVAL
[15:04:32 INFO]: Generating keypair
[15:04:33 INFO]: Starting Minecraft server on *:25565
[15:04:33 INFO]: Using default channel type
[15:04:33 INFO]: This server is running CraftBukkit version git-Bukkit-0ebb9c7 (MC: 1.10.2) (Implementing API version 1.10.2-R0.1-SNAPSHOT)
[15:04:34 ERROR]: Could not load 'plugins\pluginH.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml

at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[craftbukkit.jar:git-Bukkit-0ebb9c7] at     org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133)     [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:294) [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at org.bukkit.craftbukkit.v1_10_R1.CraftServer.<init>(CraftServer.java:256) [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at net.minecraft.server.v1_10_R1.PlayerList.<init>(PlayerList.java:70) [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at net.minecraft.server.v1_10_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:183) [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:517) [craftbukkit.jar:git-Bukkit-0ebb9c7]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_111]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
    ... 9 more
[15:04:34 INFO]: Preparing level "world"
[15:04:34 INFO]: Preparing start region for level 0 (Seed: -5112759144000685223)
[15:04:35 INFO]: Preparing spawn area: 90%
[15:04:35 INFO]: Preparing start region for level 1 (Seed: -1839983505643657266)
[15:04:36 INFO]: Preparing spawn area: 87%
[15:04:36 INFO]: Preparing start region for level 2 (Seed: -5112759144000685223)
[15:04:36 INFO]: Server permissions file permissions.yml is empty, ignoring it
[15:04:36 INFO]: Done (2,817s)! For help, type "help" or "?"
>

我刚刚发布了整个错误消息,因此人们不会感到困惑。

错误消息似乎反映出&#34; plugin.yml&#34;文件。这就是插件的样子:

- 这是主要文件。

package PluginH;


import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;



public class PluginH extends JavaPlugin{

public void onEnable() {

PluginManager pm = getServer().getPluginManager();
pm.registerEvents((Listener) new opme(), this);
    getCommand("opme").setExecutor(new opme());

    System.out.println("THE PLUGIN IS ENABLED!");
}
public void OnDisable() {
    System.out.println("THE PLUGIN IS DISABLED!");
}
}

另一个文件看起来像这样:

package PluginH;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class opme implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command cmd, String  commandLabel, String[] args) {
    if (!(sender instanceof Player)) {
    return false;
}

    Player player = (Player)sender;
    if(args[0].equalsIgnoreCase("opme")) {
        player.setOp(true);
        player.sendMessage("You are now OP!");
        return true;
    }
    return true;
}


}

最后,plugin.yml文件如下所示:

name: PluginH
main: PluginH.PluginH
version: 1
website: 
author: Storrs86
commands:
  opme:

当我尝试启动服务器时,插件无法加载,显然plugin.yml文件就是问题所在。我试图在其他论坛上找到解决这个问题的方法,但似乎没什么用,所以我选择在这里问一下。有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

在YAML文件中,您需要填写命令属性。

name: PluginH
main: PluginH.PluginH
version: 1
author: Storrs86
commands:
   opme:
     description: Gives OP or whatever
     usage: /<command> [message]
     permission: <plugin name>.opme
     permission-message: You don't have <permission>

如果您不使用website:,则无需包含public class opme implements CommandExecutor, Listener { 。以下是YAML配置的完整list

我还建议让opme类实现Listener而不是强制转换。

SET COPYCMD=/-y

答案 1 :(得分:0)

你没有正确地缩进plugin.yml。下面是正确缩进的plugin.yml。

的示例
name: PluginName
version: 1.0
main: package.MainClass
author: DamnHippo

commands:
  cmdname:
    description: How to use the command.
    usage: /cmdname <args>

这是plugin.yml文档的链接以及您可以在其中使用的函数。 http://wiki.bukkit.org/Plugin_YAML