NullPointerException onEnable

Discussion in 'Spigot Plugin Development' started by optischTV, Mar 30, 2019.

  1. [EssentialsRelPlus] Laden von EssentialsRelPlus v1.0
    [17:24:08 INFO]: [EssentialsRelPlus] Aktivieren von EssentialsRelPlus v1.0
    [17:24:08 INFO]: ------------------------------------- -------------------------------------
    [17:24:08 INFO]: Das Essentials- System wurde erfolgreich aktiviert!
    [17:24:08 INFO]: Autor: ByGoalZ
    [17:24:08 INFO]: YouTube: ByGoalZ
    [17:24:08 INFO]: ------------------------------------- ------------------------------------------
    [17:24:08 FEHLER]: Beim Aktivieren von EssentialsRelPlus v1.0 ist ein Fehler aufgetreten (Ist es auf dem neuesten Stand?)
    java.lang.NullPointerException
    at de.bygoalz.main.Main.onEnable (Main.java:59) ~ [?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled (JavaPlugin.java:321) ~ [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin (JavaPluginLoader.java:340) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin (SimplePluginManager.java:405) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin (CraftServer.java:357) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins (CraftServer.java:317) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload (CraftServer.java:741) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.Bukkit.reload (Bukkit.java:535) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.command.defaults.ReloadCommand.execute (ReloadCommand.java:25) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run (MinecraftServer.java:557) [spigot.jar: git-Spigot-db6de12-18fbb24]
    at java.lang.Thread.run (unbekannte Quelle) [?: 1.8.0_201]
    [17:24:08 INFO]: Die Server-Berechtigungsdatei permissions.yml ist leer und ignoriert sie
    [17:24:08 INFO]: CONSOLE: Nachladen abgeschlossen.
     
    #1 optischTV, Mar 30, 2019
    Last edited: Mar 30, 2019
  2. You used /reload. If the plugin has any static instances inside the main class, there WILL be issues when using reload. Restart the server entirely in all cases if you can.
     
  3. You marked this as solved within 30 seconds of posting it.. So I'll just assume you figured it out. If not, your on-enable method has an issue, or the reload broke something.
     
  4. Thanks, but my problem has no solution. Its the same error when I restart the server.

    Heres my Main class:

    Code (Java):
    package de.bygoalz.main;



    import org.bukkit.Bukkit;

    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    import de.bygoalz.commands.TphereCommand;
    import de.bygoalz.commands.TptoggleCommand;
    import de.bygoalz.commands.cmd_chatclear;
    import de.bygoalz.commands.cmd_clear;
    import de.bygoalz.commands.cmd_craft;
    import de.bygoalz.commands.cmd_day;
    import de.bygoalz.commands.cmd_enderchest;
    import de.bygoalz.commands.cmd_feed;
    import de.bygoalz.commands.cmd_fly;
    import de.bygoalz.commands.cmd_gamemode;
    import de.bygoalz.commands.cmd_heal;
    import de.bygoalz.commands.cmd_invsee;
    import de.bygoalz.commands.cmd_item;
    import de.bygoalz.commands.cmd_night;
    import de.bygoalz.commands.cmd_ping;
    import de.bygoalz.commands.cmd_repair;
    import de.bygoalz.commands.cmd_tp;
    import de.bygoalz.commands.cmd_tpall;
    import de.bygoalz.listeners.JoinListener;
    import de.bygoalz.listeners.QuitListener;
    public class Main extends JavaPlugin {
     
     
         
     
        public static String prefix = "§7[§6System§7]";
     
        public void onEnable() {
         
         
         
            Bukkit.getConsoleSender().sendMessage("§7----------------------------------------------------------------------------------");
            Bukkit.getConsoleSender().sendMessage("§7Das §6Essentials§7- §6System §7wurde erfolgreich §aaktiviert§7!");
            Bukkit.getConsoleSender().sendMessage("§cAutor: ByGoalZ");
            Bukkit.getConsoleSender().sendMessage("§5YouTube: ByGoalZ");
            Bukkit.getConsoleSender().sendMessage("§7-----------------------------------------------------------------------------------");
     
     
        getCommand("heal").setExecutor(new cmd_heal());
        getCommand("feed").setExecutor(new cmd_feed());
        getCommand("fly").setExecutor(new cmd_fly());
        getCommand("gamemode").setExecutor(new cmd_gamemode());
        getCommand("gm").setExecutor(new cmd_gamemode());
        getCommand("item").setExecutor(new cmd_item());
        getCommand("day").setExecutor(new cmd_day());
        getCommand("night").setExecutor(new cmd_night());
        getCommand("ping").setExecutor(new cmd_ping());
        getCommand("clear").setExecutor(new cmd_clear());
        getCommand("clearchat").setExecutor(new cmd_chatclear());
        getCommand("invsee").setExecutor(new cmd_invsee());
        getCommand("tp").setExecutor(new cmd_tp());
        getCommand("tptoggle").setExecutor(new TptoggleCommand());
        getCommand("tphere").setExecutor(new TphereCommand());
        getCommand("craft").setExecutor(new cmd_craft());
        getCommand("tpall").setExecutor(new cmd_tpall());
        getCommand("repair").setExecutor(new cmd_repair());
        getCommand("enderchest").setExecutor(new cmd_enderchest());
        PluginManager pm = Bukkit.getPluginManager();
        pm.registerEvents(new JoinListener(), this);
        pm.registerEvents(new QuitListener(), this);
     
         
        }
     
     
     
     
     
     
     

                       public void onDisable(){
                           Bukkit.getConsoleSender().sendMessage("§7----------------------------------------------------------------------------------");
                          Bukkit.getConsoleSender().sendMessage("§7Das §6Essentials§7- §6System §7wurde erfolgreich §cdeaktiviert§7!");
                          Bukkit.getConsoleSender().sendMessage("§cAutor: ByGoalZ");
                          Bukkit.getConsoleSender().sendMessage("§5YouTube: ByGoalZ");
                          Bukkit.getConsoleSender().sendMessage("§7-----------------------------------------------------------------------------------");
    }
                         
                       }
     
  5. PLEASE use Code tags and PLEASE post the exact line that is giving the issue (Line 59)
     
  6. Choco

    Moderator

    In the future, surround your code with [CODE=java][/CODE] tags so it's actually readable. I've done it for you already. The reason you're getting an NPE is because one of your commands is not registered in the plugin.yml. If not listed there, #getCommand() returns null.
     
  7. We really need like a button that just says you’re on your own because your code is so crappy that we can’t be bothered to read it.

    Also this post went from solved to resource, please make it go to neither.

    What’s on line 59 of Main? Looks like a command isn’t registered in your plugin.yml
     
    • Funny Funny x 1
  8. the commands are registered. Show my plugin.yml:
    [CODE = Java]
    name: EssentialsRelPlus
    version: 1.0
    main: de.bygoalz.main.Main
    author: ByGoalZ

    commands:
    heal:
    feed:
    fly:
    gm:
    gamemode:
    item:
    aliases:
    day:
    aliases: [tag]
    night:
    aliases: [nacht]
    ping:
    clear:
    clearchat:
    aliases: [cc]
    tp:
    tptoggle:
    tphere:
    tpall:
    repair:
    enderchest:
    aliases: [ec]

    [/ CODE]
     
  9. You're missing invsee from the yml.
     
  10. i have the solution. Thanks MSWS. I'm so silly. Sorry!