尝试激活我的Spigot插件时,我总是遇到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.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;
}
}
感谢您的反馈。 (GitHub回购:http://github.com/NexAdn/unitedshops/)
答案 0 :(得分:1)
看起来sec
为空。你有可能犯了一些错别字。