What is this?

Discussion in 'Plugin Development' started by Chris32, Mar 11, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Chris32

    I'm a new plugin dev. I just exported for the first time, and here's the error I get. Something obvious, I assume?

    Code:
    12:55:44 [SEVERE] Could not load 'plugins\Wisk.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:148)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:287)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:211)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)
            at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:537)
            at org.bukkit.Bukkit.reload(Bukkit.java:182)
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:
    22)
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:16
    6)
            at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:4
    69)
            at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.
    java:465)
            at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:599)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:568)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    Caused by: java.lang.NullPointerException
            at org.bukkit.plugin.PluginLogger.<init>(PluginLogger.java:22)
            at org.bukkit.plugin.java.JavaPlugin.getLogger(JavaPlugin.java:359)
            at chris32.wisk.Wisk.<init>(Wisk.java:8)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
     
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
     
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce)
            at java.lang.reflect.Constructor.newInstance(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:144)
            ... 13 more
    Please help!
    Thanks in advance.
     
  2. Offline

    stelar7

    Code:
    Caused by: java.lang.NullPointerException
    at chris32.wisk.Wisk.<init>(Wisk.java:8)
     
  3. Offline

    Chris32

    That Line:
    Code:
    Logger log = this.getLogger();
     
  4. Offline

    dark navi

    'this' may be null. Check where it is assigned.
     
  5. Offline

    SgtStud

    Code:
    Logger log = this.getLogger();
    
    That is an error It should be Logger log = this.getLogger("Minecraft");
     
  6. Offline

    Chris32

    Thanks so much! I didn't see that in the tutorial... Weird.

    Ah wait... now I have a new error in eclipse.
    This is the code:
    Code:
    Logger log = this.getLogger("Minecraft");
    This is the error:
    Code:
    The method getLogger() in the type JavaPlugin is not applicable for the arguments (String)
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  7. Offline

    stelar7

    Code:
    Logger log = Bukkit.getServer().getLogger();
     
  8. Offline

    Chris32

    THANKS!
     
  9. Offline

    desht

    No, it should not. this.getLogger() is perfectly valid, and gets you a custom logger which automatically pretends your plugin name to your log messages.

    The probable cause of the problem is that it's being called too early (your plugin backtrace suggests that you're calling it from your constructor) - as long as you call it from onEnable() you should be fine.
     
    dillyg10 and nisovin like this.
  10. Offline

    nisovin

    Chris32 The above answer is correct. I just wanted to reiterate it, since there is a lot of misinformation in this thread.
     
Thread Status:
Not open for further replies.

Share This Page