Why Wont this work

Discussion in 'Plugin Development' started by sebastian97, Apr 16, 2012.

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

    sebastian97

    This is my source
    Code:
     package ca.live.csearle.demoPlugin;
    import java.util.logging.Logger;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class demoPlugin extends JavaPlugin {
     
    Logger log = this.getLogger();
     
    public void onEnable(){
    log.info("Your plugin has been fucking enabled.");
    }
     
    public void onDisable(){
    log.info("Your shit has been disabled");
    }
    }
    
    ERROR IT THROWS:

    Code:
    [LIST=1]
    [*][COLOR=#000000]2012-04-16 19:45:01 [SEVERE] Could not load 'plugins\demoPlugin.jar' in folder 'plugins'[/COLOR]
    [*][COLOR=#000000]org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:148)[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:207)[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.craftbukkit.CraftServer.<init>(CraftServer.java:183)[/COLOR]
    [*][COLOR=#000000]        at net.minecraft.server.ServerConfigurationManager.<init>(ServerConfigurationManager.java:53)[/COLOR]
    [*][COLOR=#000000]        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:156)[/COLOR]
    [*][COLOR=#000000]        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:422)[/COLOR]
    [*][COLOR=#000000]        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)[/COLOR]
    [*][COLOR=#000000]Caused by: java.lang.NullPointerException[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.plugin.PluginLogger.<init>(PluginLogger.java:22)[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.plugin.java.JavaPlugin.getLogger(JavaPlugin.java:359)[/COLOR]
    [*][COLOR=#000000]        at ca.live.csearle.demoPlugin.demoPlugin.<init>(demoPlugin.java:7)[/COLOR]
    [*][COLOR=#000000]        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[/COLOR]
    [*][COLOR=#000000]        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)[/COLOR]
    [*][COLOR=#000000]        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)[/COLOR]
    [*][COLOR=#000000]        at java.lang.reflect.Constructor.newInstance(Unknown Source)[/COLOR]
    [*][COLOR=#000000]        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)[/COLOR]
    [COLOR=#000000]
    [/COLOR]
    HELP! THANK YOU
    [/LIST]

    BUMP I NEED HELP COMPUTING

    PLEASE HELP ME I NOT GOOD WITH C+

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  2. Offline

    r0306

    Code:
    package ca.live.csearle.demoPlugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class demoPlugin extends JavaPlugin {
     
    public void onEnable(){
    System.out.println("Your plugin has been enabled.");
    }
     
    public void onDisable(){
    System.out.println("Your plugin has been disabled");
    }
    }
    Make sure you've imported the right JavaPlugin and also defined the build path to the craftbukkit development api.
     
  3. Offline

    sebastian97

    IS GOOD THANK U, HOW DO I FIX
     
  4. Offline

    CRAZYxMUNK3Y

    Try changing;

    Code:java
    1.  
    2. Logger log = this.getLogger();
    3.  


    to

    Code:java
    1.  
    2. public Logger log = Logger.getLogger("Minecraft");
    3.  
     
  5. Offline

    sebastian97

    I HAVE FIX IT BY NOT WORKING MY BONER SO HARD, TY EVRY1
     
  6. Offline

    Sagacious_Zed Bukkit Docs

    CRAZYxMUNK3Y works but technically they are different loggers.

    sebastian97 change
    Code:
    Logger log = this.getLogger()
    to
    Code:
    Logger log;
    then in your onEnable method insert into the method before you use log
    Code:
    this.log = this.getLogger()
    the reason why you cannot use getLogger() outside of onEnable is that the object it references is not defined until slightly before onEnabled is called by bukkit.
     
Thread Status:
Not open for further replies.

Share This Page