Multiple config files don't work. Line 16 returning Nullpointer

Discussion in 'Plugin Development' started by stimoze, Dec 16, 2017.

Thread Status:
Not open for further replies.
  1. Hi! Currently i'm trying to clean up my code a little bit, im trying to make separate config files, but this keeps returning a nullpointer exception, and i can't find out why.

    This is the log
    [01:57:12] [Server thread/ERROR]: Error occurred while enabling GoldenHub-PvP v1.0 (Is it up to date?)
        at com.stimonz.pvpsystem.ConfigurationUtil.loadBountyYaml( ~[?:?]
        at com.stimonz.pvpsystem.Main.onEnable( ~[?:?]
        at ~[minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init( [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at [minecraft_server.jar:git-Spigot-db6de12-18fbb24]
        at [?:1.8.0_101]
    This is my class
    public class ConfigurationUtil {
        public static Main m = new Main();
        public static FileConfiguration bounty;
        public static FileConfiguration lifeguard;
        public static FileConfiguration cfgvoid;
        public static void loadBountyYaml(){
              16. line>  bounty = YamlConfiguration.loadConfiguration(new File(m.getDataFolder(), "bounty.yml"));
        public static void loadLifeguardYaml(){
                lifeguard = YamlConfiguration.loadConfiguration(new File(m.getDataFolder(), "lifeguard.yml"));
        public static void loadVoidYaml(){
                cfgvoid = YamlConfiguration.loadConfiguration(new File(m.getDataFolder(), "void.yml"));
        public static FileConfiguration getBountyYaml(){
            return bounty;
        public static FileConfiguration getLifeguardYaml(){
            return lifeguard;   
        public static FileConfiguration getVoidYaml(){
            return cfgvoid;
    Thanks for helping!
  2. Offline


    public static Main m = new Main();
    Never instantiate a new instance of your main class (the one that extends JavaPlugin). This could well be your problem, perhaps 'm' is null.
  3. Offline


    When making an instance of your main class never do "Main m = new Main();", that's only for other classes.

    - The proper way to do it make a static variable in your main class that is set to nothing. Make sure its private.
    - Then make a public static method that returns your variable.
    - After inside of another class, make a variable such as: "Main m = Main.getInstance();", replace "getInstance()" with whatever returns your plugin in your main class.

    Another thing is that do you have any method that creates the files?, Do you have any methods that save your files?
    Try making those methods. If the problem persists, it could be something that it can't load the data file because maybe you hadn't created it yet.
Thread Status:
Not open for further replies.

Share This Page