Solved 1.8.9 onEnable error with commands

Discussion in 'Plugin Development' started by JakeBaxter, May 28, 2020.

  1. Offline

    JakeBaxter

    Hello,

    I'm currently in the middle of developing a plugin, I'm using spiggot 1.8.9 (using bukkit imports) but every time the code runs the follow error appears:

    Code:
    [11:08:33 INFO]: [server] Loading server v1
    [11:08:33 INFO]: [server] Enabling server v1
    [11:08:33 ERROR]: Error occurred while enabling server v1 (Is it up to date?)
    java.lang.NullPointerException
            at me.JakeBaxter.mcserverplugin.main.onEnable(main.java:14) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.reload(Bukkit.java:535) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [server.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [server.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [server.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [server.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [server.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [server.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
    I have viewed the thread of readint trace error stacks, but its not seeming to help and it's like 7 years old now, and one of the links dont work. The following code is in my main:

    Code:
    public class main extends JavaPlugin {
    
       private Commands commands = new Commands();
       
       public String prefix = ChatColor.RED+"MCSERVERPLUGIN"+ChatColor.BOLD+ChatColor.GREEN+">>"+ChatColor.RESET;
       
       @Override
       public void onEnable(){
         getCommand(commands.ban).setExecutor(commands); //Line 14, the one having problems
         getCommand(commands.van).setExecutor(commands);
         getConfig().options().copyDefaults(true);
         saveConfig();
       }
    
       @Override
       public void onDisable() {
    
       }
    }
    Theres more imports and stuff, but left it out.
    Help appreciated, thanks
     
  2. Offline

    timtower Moderator Moderator

    @JakeBaxter Did you specify the commands in your plugin.yml?
     
  3. Offline

    JakeBaxter

    @timtower yes it works now, thanks! i was stupid not to think of that haha
     

Share This Page