Java 带有Maven的Bukkit 1.8插件中存在未知错误
当我试图激活我的插口插件时,我总是得到一个java.lang.NullPointerException。我没有发现任何错误,但也许你能帮我。 服务器输出:Java 带有Maven的Bukkit 1.8插件中存在未知错误,java,maven,nullpointerexception,bukkit,Java,Maven,Nullpointerexception,Bukkit,当我试图激活我的插口插件时,我总是得到一个java.lang.NullPointerException。我没有发现任何错误,但也许你能帮我。 服务器输出: [13:36:25] [Server thread/ERROR]: Error occurred while enabling UnitedShops v0.0.3 (Is it up to date?) java.lang.NullPointerException at io.github.nexadn.unitedshops.co
[13:36:25] [Server thread/ERROR]: Error occurred while enabling UnitedShops v0.0.3 (Is it up to date?)
java.lang.NullPointerException
at io.github.nexadn.unitedshops.config.ConfigShopMain.parseConfig(ConfigShopMain.java:45) ~[?:?]
at io.github.nexadn.unitedshops.shop.GUIContainer.initGUI(GUIContainer.java:25) ~[?:?]
at io.github.nexadn.unitedshops.UnitedShops.onEnable(UnitedShops.java:41) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-f94fe8f-2642f9b]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:356) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:316) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:524) [spigot.jar:git-Spigot-f94fe8f-2642f9b]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_85]
ConfigShopMain.java:
// imports, package, etc...
public class ConfigShopMain extends ConfigBase {
private HashMap<String, ShopInventory> menus; // Menu container
public ConfigShopMain(File file) {
super(file);
menus = new HashMap<String, ShopInventory>();
}
public ConfigShopMain(File file, String mainTag)
{
super(file, mainTag);
menus = new HashMap<String, ShopInventory>();
}
// parse the Config File
public void parseConfig()
{
Set<String> kies = super.getSubKeys();
for( String s:kies )
{
String title = super.getMainSection().getString(s + ".title"); // shops.[key].title
Material icon = Material.getMaterial(super.getMainSection().getString(s + ".iconitem")); // shops.[key].iconitem
this.menus.put(s, new ShopInventory(title, new ItemStack(icon, 1)) );
String sect = super.getWorkKey() + "." + s + "." + "items";
Set<String> subkies = super.getConf().getConfigurationSection(sect).getKeys(false);
for( String sub:subkies ) // shops.[key].items.[key2]
{
ConfigurationSection sec = super.getConf().getConfigurationSection(sub);
Material mat = Material.getMaterial(sec.getString("item")); // shops.[key].items.[key2].item // ERROR ??? //
ShopObject cont = new ShopObject(mat, sec.getDouble("buy"), sec.getDouble("sell")); // Shop Contents
this.menus.get(s).addContent(cont);
}
}
}
public List<ShopInventory> getMenus()
{
List<ShopInventory> temp = null;
Collection<ShopInventory> inv = this.menus.values();
temp = (List<ShopInventory>) inv;
return temp;
}
}
//导入、打包等。。。
公共类ConfigShopMain扩展了ConfigBase{
私有HashMap菜单;//菜单容器
公共ConfigShopMain(文件){
超级(文件);
菜单=新HashMap();
}
公共ConfigShopMain(文件文件,字符串mainTag)
{
超级(文件,主标签);
菜单=新HashMap();
}
//解析配置文件
public void parseConfig()
{
Set kies=super.getSubKeys();
用于(字符串s:kies)
{
字符串title=super.getMainSection().getString(s+“.title”);//商店[key].title
Material icon=Material.getMaterial(super.getMainSection().getString(s+“.iconitem”);//商店[key].iconitem
this.menus.put(s,new ShopInventory(标题,new ItemStack(图标,1));
String sect=super.getWorkKey()+“+s+”+“items”;
Set subkies=super.getConf().getConfigurationSection(sect).getKeys(false);
for(String sub:subkies)//shops.[key].items.[key2]
{
ConfigurationSection sec=super.getConf().getConfigurationSection(sub);
Material mat=Material.getMaterial(sec.getString(“item”);//商店。[key]。项目。[key2]。项目//错误//
ShopObject cont=新的ShopObject(mat,sec.getDouble(“购买”),sec.getDouble(“出售”);//商店内容
这个.menus.get(s).addContent(cont);
}
}
}
公共列表getMenus()
{
列表温度=空;
Collection inv=this.menus.values();
临时=(列表)库存;
返回温度;
}
}
谢谢你的反馈。(GitHub repo:)看起来
sec
为空。可能是您输入了一些错误。谢谢,配置部分不太好用。我用路径字符串替换了它,并用super.getConf()和路径替换了所有sec调用。@NexAdn没问题!很高兴我帮了忙!:)可能重复的