I am getting this error when I try to enable my plugin (I did not get it before adding the configuration): Spoiler (Move your mouse to the spoiler area to reveal the content) Show Spoiler Hide Spoiler Code: 2012-01-10 16:43:14 [SEVERE] Error occurred while enabling ExpBank v0.3 (Is it up to date?): null java.lang.NullPointerException at me.hayden.expbank.ExpBank.onEnable(ExpBank.java:78) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:228) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:970) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:186) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:169) at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:348) at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:335) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:165) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399) at net.minecraft.server.ThreadServerApplication.run(SourceFile:457) Here is the configuration related stuff from my main class (made with this tutorial): Spoiler (Move your mouse to the spoiler area to reveal the content) Show Spoiler Hide Spoiler Code: FileConfiguration ExpBankConfig; public double config_bankxcoord = 0; public double config_bankycoord = 64; public double config_bankzcoord = 0; public String config_bankworld = "world"; @Override public void onEnable(){ ExpBankConfig.options().header("Set your Bank Location"); ExpBankConfig.addDefault("Bank Location.X", 0); ExpBankConfig.addDefault("Bank Location.Y", 64); ExpBankConfig.addDefault("Bank Location.Z", 0); ExpBankConfig.options().copyDefaults(true); saveConfig(); config_bankxcoord = (Double) ExpBankConfig.get("Bank Location.X"); config_bankycoord = (Double) ExpBankConfig.get("Bank Location.Y"); config_bankzcoord = (Double) ExpBankConfig.get("Bank Location.Z"); }
What specifically is line 78? Add this to your onEnable Code:java FileConfiguration ExpBankConfig = this.getConfig(); Because i do believe you never actually set what ExpBankConfig was referring to EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I think I can guess where line 78 is - the first line inside onEnable(). You've declared your FileConfiguration object, but you haven't actually initialised it to anything. So it's null when you come to use it.
lol sorry yes @desht guessed right, I didn't know objects needed to be initialised, thanks everyone. Edit: now I'm getting another error: Code: 2012-01-10 17:10:34 [SEVERE] Error occurred while enabling ExpBank v0.3 (Is it up to date?): java.lang.Integer cannot be cast to java.lang.Double java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double at me.hayden.expbank.ExpBank.onEnable(ExpBank.java:84) at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:228) at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:970) at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280) at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:186) at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:169) at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:348) at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:335) at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:165) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399) at net.minecraft.server.ThreadServerApplication.run(SourceFile:457) I'm always completely lost when I try to convert data types...
Code: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double at me.hayden.expbank.ExpBank.onEnable(ExpBank.java:84) Check over the Int/Doubles you are using on this line?
it apears that all entries in the config are objects not ints ot Doubles BUMP EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Well, why are you tring to use doubles in the first place? Presumably your "bank" co-ordinates are those of a block (not an entity), so integers are all you need here. You've even supplied integers (0, 64, 0) for the co-ordinate defaults. (You're getting the class cast exception because the FileConfiguration get() method is returning Integer objects to you, and those cannot be cast directly to Double).
Oh, thanks, I was being a bit (very) stupid. The Double thing is a remnant of an old failed attempt at doing something related.