Errors on startup - SOLVED (Noob mistake) :P

Discussion in 'Plugin Development' started by CRAZYxMUNK3Y, Dec 24, 2011.

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

    CRAZYxMUNK3Y

    Hi all,

    To start off with, i did do some reasearch about this problem but came up empty handed.

    That aside, I recently made a small plugin for my server that i am on to stop griefers. It has no errors in the code or in the YML.

    It was made with the 1.0.1 RB and JRE6 and the server is using the same.

    What is this error and how can it be fixed?

    Code:
    2011-12-25 16:22:48 [SEVERE] Error occurred while enabling StopTheGriefer v0.7 (Is it up to date?): null
    java.lang.NullPointerException
        at me.ben.StopTheGriefer.StopTheGriefer.onEnable(StopTheGriefer.java:33)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:188)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:968)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:280)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:186)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:169)
        at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:348)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:335)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:165)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    2011-12-25 16:22:48 [INFO] Server permissions file permissions.yml is empty, ignoring it
    2011-12-25 16:22:48 [INFO] Done (0.119s)! For help, type "help" or "?"
    Thanks
     
  2. Offline

    Razorcane

    What's line 33 in your main class say? Most likely it's a command that you forgot to add to plugin.yml, but show me that line anyway.
     
  3. Offline

    CRAZYxMUNK3Y

    Code:java
    1. public void onEnable() {
    2. PluginManager pm = this.getServer().getPluginManager();
    3. log.info(pdfFile.getName() + " has been enabled with version " + pdfFile.getVersion()); /* Line 33 */
    4. pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
    5. }
    6.  
     
  4. Offline

    Razorcane

    EDIT: Nevermind.

    Did you declare your pdffile before onEnable? you should declare 'public PluginDescriptionFile pdffile;' at the top, and then in onEnable(), you declare pdffile = getDescription().
     
  5. Offline

    CRAZYxMUNK3Y

    Nevermind sorry, i had it as;

    Code:java
    1.  
    2. public class StopTheGriefer extends JavaPlugin {
    3.  
    4. PluginDescriptionFile pdfFile = this.getDescription();
    5.  
    6. Logger log = Logger.getLogger("Minecraft");
    7.  
    8. private final StopTheGrieferBlockListener blockListener = new StopTheGrieferBlockListener(this);
    9.  
    10. public ArrayList<String> ActivePlayers = new ArrayList<String>();
    11.  
    12.  
    13.  
    14. public void onEnable() {
    15. PluginManager pm = this.getServer().getPluginManager();
    16. log.info(pdfFile.getName() + " has been enabled with version " + pdfFile.getVersion());
    17. pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
    18. }
    19.  
    20. public void onDisable() {
    21. log.info(pdfFile.getName() + " has been disbaled");
    22. }
    23.  


    instead of

    Code:java
    1.  
    2. public class StopTheGriefer extends JavaPlugin {
    3.  
    4.  
    5.  
    6. Logger log = Logger.getLogger("Minecraft");
    7.  
    8. private final StopTheGrieferBlockListener blockListener = new StopTheGrieferBlockListener(this);
    9.  
    10. public ArrayList<String> ActivePlayers = new ArrayList<String>();
    11.  
    12.  
    13.  
    14. public void onEnable() {
    15. PluginDescriptionFile pdfFile = this.getDescription();
    16. PluginManager pm = this.getServer().getPluginManager();
    17. log.info(pdfFile.getName() + " has been enabled with version " + pdfFile.getVersion());
    18. pm.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Priority.Normal, this);
    19. }
    20.  
    21. public void onDisable() {
    22. PluginDescriptionFile pdfFile = this.getDescription();
    23. log.info(pdfFile.getName() + " has been disbaled");
    24. }
    25.  


    Nooby mistake :S
     
  6. Offline

    Razorcane

    Yea that'll about do it for you :p
     
Thread Status:
Not open for further replies.

Share This Page