无效的plugin.yml bukkit插件错误 [英] invalid plugin.yml bukkit plugin error

查看:753
本文介绍了无效的plugin.yml bukkit插件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,所以我在发布此消息之前确实在多个站点上查找了此问题,并且一切都正确,但是当我尝试加载插件时仍然出现此错误,它说错误无法 无效的plugin.yml,然后只给出一堆代码行和其他内容(我假设是从bukkit文件中的代码中获取的,什么都没有,是的,我的plugin.yml保存在src文件夹中而不是程序包中,当我导出它我确实将其导出为.jar,无论如何这是我的plugin.yml文件

name: ProtHome
main: com.yahoo.m1kesanders.ProtHome.ProtHome 
version: 1.0.0
Description: A simple /home plugin 

commands:


  sethome:
    Description: sets players home

  home:
    Description: teleports player to their home

我也确实使用了4个空格,并且在命令后的两个空格中没有使用制表键:每个命令后的另外两个空格

这是我在eclipse中插件的代码,以防万一您只需要检查名称而无需检查

package com.yahoo.m1kesanders.ProtHome;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

public class ProtHome extends JavaPlugin{

    public static ProtHome plugin;

    public File folder = plugin.getDataFolder();
    public static File file = new File("Homes.yml");
    public static YamlConfiguration Homes = new YamlConfiguration();

    public void onEnable(){

        if(!folder.exists()){

            folder.mkdir();
        }

        if(!file.exists()){

            file.mkdir();
        }

        try {
            Homes.load(file);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public boolean onCommand(CommandSender cmdsender, Command cmd, Player player) throws FileNotFoundException, IOException, InvalidConfigurationException{

        if(cmdsender.equals("sethome")){

            ProtHome.Homes.load(ProtHome.file);

            Homes.set(player.getName() + ".x", player.getLocation().getBlockX());
            Homes.set(player.getName() + ".y", player.getLocation().getBlockY());
            Homes.set(player.getName() + ".z", player.getLocation().getBlockZ());
            Homes.set(player.getName() + ".world", player.getWorld().getName());

            ProtHome.Homes.save(ProtHome.file);
        }

        else if(cmdsender.equals("home")){

            int x = (int) Homes.get(player.getName() + ".x");
            int y = (int) Homes.get(player.getName() + ".y");
            int z = (int) Homes.get(player.getName() + ".z");

            String world = (String) Homes.get(player.getName() + ".world");

            World realworld = Bukkit.getServer().getWorld(world);

            Location loc = new Location(realworld,x,y,z);

            player.teleport(loc);

        }

        return false;

    }

}

如果你们能帮助我,那将非常感谢您阅读

解决方案

部分问题可能是在bukkit示例plugin.yml中,所有键均为小写时,您将Description:中的D大写. >

尝试使用小写的d导出,尽管这可能不是问题,但始终有助于使用正确的编码语法. Bukkit的Yaml分析器非常挑剔.

此外,为了将来参考,软件包名称通常不包含大写字母,而仅包含类.

您的包裹com.yahoo.m1kesanders.ProtHome

大多数软件包com.yahoo.m1kesanders.prothome

我不确定,但是通常特别建议bukkit插件遵循此一般规则.我不知道bukkit的类加载器是如何工作的,但是这个大写的软件包名称肯定没有帮助.

Hey so I did look this issue up on multiple sites before I posted this and I did everything correct, but I still get this error when I try to load my plugin, it says error could not invalid plugin.yml, and then just gives a bunch of code lines and stuff (i'm assuming from the code in the bukkit files and whatnot, and yes my plugin.yml is saved in the src folder not a package, and when I export it I do export it as a .jar, anyway here's my plugin.yml file

name: ProtHome
main: com.yahoo.m1kesanders.ProtHome.ProtHome 
version: 1.0.0
Description: A simple /home plugin 

commands:


  sethome:
    Description: sets players home

  home:
    Description: teleports player to their home

and I also did use the 4 spaces and no tab keys were used two spaces after commands: and another two after each command

and here's my code for the plugin in eclipse in case you need it just to check name and what not

package com.yahoo.m1kesanders.ProtHome;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

public class ProtHome extends JavaPlugin{

    public static ProtHome plugin;

    public File folder = plugin.getDataFolder();
    public static File file = new File("Homes.yml");
    public static YamlConfiguration Homes = new YamlConfiguration();

    public void onEnable(){

        if(!folder.exists()){

            folder.mkdir();
        }

        if(!file.exists()){

            file.mkdir();
        }

        try {
            Homes.load(file);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    public boolean onCommand(CommandSender cmdsender, Command cmd, Player player) throws FileNotFoundException, IOException, InvalidConfigurationException{

        if(cmdsender.equals("sethome")){

            ProtHome.Homes.load(ProtHome.file);

            Homes.set(player.getName() + ".x", player.getLocation().getBlockX());
            Homes.set(player.getName() + ".y", player.getLocation().getBlockY());
            Homes.set(player.getName() + ".z", player.getLocation().getBlockZ());
            Homes.set(player.getName() + ".world", player.getWorld().getName());

            ProtHome.Homes.save(ProtHome.file);
        }

        else if(cmdsender.equals("home")){

            int x = (int) Homes.get(player.getName() + ".x");
            int y = (int) Homes.get(player.getName() + ".y");
            int z = (int) Homes.get(player.getName() + ".z");

            String world = (String) Homes.get(player.getName() + ".world");

            World realworld = Bukkit.getServer().getWorld(world);

            Location loc = new Location(realworld,x,y,z);

            player.teleport(loc);

        }

        return false;

    }

}

if you guys can help me out it will mean a lot thanks for reading

解决方案

Part of the problem could be that you capitalized the D in Description: when in the bukkit example plugin.yml, all keys are lowercase.

Try exporting with a lowercase d although this may not be the problem, it always helps to use proper coding grammar. Bukkit is very knit picky with it's yaml parser.

Also, for future reference, usually packagenames do not have capital letters, only classes.

Your package com.yahoo.m1kesanders.ProtHome

Most packages com.yahoo.m1kesanders.prothome

I cannot be certain, but it is usually especially recommended for bukkit plugins to follow this general rule. I do not know how bukkit's class loader works, but this capitalized package name surely doesn't help.

这篇关于无效的plugin.yml bukkit插件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆