Error When Startup

Discussion in 'Spigot Plugin Development' started by iMedia, Jul 29, 2018.

  1. iMedia

    Supporter

    [16:06:27 ERROR]: Error occurred while enabling oHub v0.3 (Is it up to date?)
    java.lang.NullPointerException
    at me.imedia.ohub.Core.onEnable(Core.java:13) ~[?:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:412) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at org.bukkit.craftbukkit.v1_7_R4.CraftServer.loadPlugin(CraftServer.java:476) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at org.bukkit.craftbukkit.v1_7_R4.CraftServer.enablePlugins(CraftServer.java:394) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at net.minecraft.server.v1_7_R4.MinecraftServer.n(MinecraftServer.java:360) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at net.minecraft.server.v1_7_R4.MinecraftServer.g(MinecraftServer.java:334) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at net.minecraft.server.v1_7_R4.MinecraftServer.a(MinecraftServer.java:290) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at net.minecraft.server.v1_7_R4.DedicatedServer.init(DedicatedServer.java:210) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:458) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]
    at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1.7.9-R0.2-208-ge0f2e95]

    Please tell me how to fix
     
  2. We kinda need to see the code to help you fix it. The oHub plugin is causing this error.
     
  3. iMedia

    Supporter

    I have multiple classes what class do you want to see?
     
  4. iMedia

    Supporter

    [SOILER="MAIN CLASS"]
    package me.imedia.ohub;
    import org.bukkit.plugin.java.JavaPlugin;
    public class Core extends JavaPlugin {

    public static Core plugin;

    public void onEnable() {
    plugin = this;
    getConfig().options().copyDefaults(true);
    saveConfig();
    getServer().getPluginManager().registerEvents(new Listeners(this), this);
    getCommand("help").setExecutor(new Commands(this));
    }
    public void registerEvents() {
    new ScoreboardManager(this);
    }
    }
     
  5. The class that extends the JavaPlugin. On line 13 of the class inside the onEnable() function you should check if that variable or data input is null before trying to work with it.
     
  6. Your error is on line 13 of the Core class. What's on that line?
     
  7. iMedia

    Supporter

    getCommand("help").setExecutor(new Commands(this));

    thats line 13
     
  8. Seems like you haven't registered the command in your plugin.yml, is that right?
     
  9. Strahan

    Benefactor

    ...and use [CODE] tags not spoiler tags for posting code. That way you won't lose indentation.
     
  10. iMedia

    Supporter

    Code (Text):

    name: oHub
    version: 0.3
    main: me.imedia.ohub.Core
    description: ...
    commands:
      help:
      1:
    thats my plugin.yml
     
  11. The syntax is wrong I think check out the article on it.
     
  12. I'd recommend you to change the name of your command, as "help" is already a command. The syntax of your plugin.yml looks good, although I am wondering why you have a command named "1".

    Could you correctly paste every Java class in your plugin (spoiler with file name + Java code tag) ?