Config returns null

Discussion in 'Spigot Help' started by sd_master92, May 26, 2018.

  1. This is a part of my code:

    Code (Text):
    package server.main;
    import java.util.logging.Logger;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginManager;
    public class Main extends JavaPlugin {
        public void onEnable() {
            PluginDescriptionFile pdf = this.getDescription();
            Logger logger = Logger.getLogger("Minecraft");
   + " v" + pdf.getVersion() + " has been enabled.");
        public void onDisable() {
            PluginDescriptionFile pdf = this.getDescription();
            Logger logger = Logger.getLogger("Minecraft");
   + " v" + pdf.getVersion() + " has been disabled.");
        private void registerConfig() {
        private void registerListeners() {
            PluginManager pm = this.getServer().getPluginManager();
            pm.registerEvents(new EventManager(this), this);

    Code (Text):
    package server.main;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
    public class EventManager implements Listener {
        private Main plugin;
        public EventManager(Main pl) {
            this.plugin = pl;
        FileConfiguration conf = plugin.getConfig(); // this gives me a null
        public void onPlayerLogin(AsyncPlayerPreLoginEvent event) {

    Code (Text):
    [19:06:37 ERROR]: Error occurred while enabling ServerComplete v1.0.1 (Is it up to date?)
    java.lang.NullPointerException: null
            at server.main.EventManager.<init>( ~[?:?]
            at server.main.Main.registerListeners( ~[?:?]
            at server.main.Main.onEnable( ~[?:?]
            at ~[spigot.jar:git-Spigot-2086bb0-d0a3620]
            at [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.MinecraftServer.t( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.MinecraftServer.l( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.MinecraftServer.a( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at net.minecraft.server.v1_12_R1.DedicatedServer.init( [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at [spigot.jar:git-Spigot-2086bb0-d0a3620]
            at Source) [?:1.8.0_171]
    #1 sd_master92, May 26, 2018
    Last edited: May 26, 2018
  2. Strahan


    Is your console showing "players.yml loaded" when the server starts and it inits your plugin?
  3. It is loaded when the plugin enables.
  4. Now I have completely simplified the classes, and as you can see, the error STILL comes when trying to retreive the config.yml from the EventsManager class. What can I do?