Plugin broken: "Could not load plugin/iBooks.jar in folder plugins"

Discussion in 'Plugin Development' started by MrRump, Jun 18, 2011.

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

    MrRump

    Hey :)

    I've been working on my first plugin for a while, but yesterday I've broken my plugin, and I don't know why. I had a few problems with SQL commands, so yesterday I rewrote some parts of my plugin. Now my plugin cannot be loaded anymore, but I don't know why, because I didn't change anything in the declaring process of the PlayerListener (which seems to make the error).

    Here is the console output:
    Show Spoiler

    Code:
    Could not load 'plugins/iBooks.jar' in folder 'plugins':
    java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:172)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:194)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:117)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:109)
        at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:232)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:219)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:146)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:283)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
    Caused by: java.lang.NullPointerException
        at com.robinrump.iBooks.iBooksPlayerListener.<init>(iBooksPlayerListener.java:23)
        at com.robinrump.iBooks.iBooks.<init>(iBooks.java:18)
        ... 13 more
    


    Here is the head of the iBooks.jar file:
    Show Spoiler

    Code:
    package com.robinrump.iBooks;
    
    import java.io.File;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.logging.Logger;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import com.alta189.sqlLibrary.SQLite.sqlCore;
    
    public class iBooks extends JavaPlugin {
        private final iBooksPlayerListener playerListener = new iBooksPlayerListener(this);
        Logger log = Logger.getLogger("Minecraft");
        public File pFolder = new File("plugins" + File.separator + "iBooks");
        public sqlCore manageSQLite;
        public String logPrefix = "[iBooks] ";
        public static Map<Player, Integer> mode = new HashMap<Player, Integer>();
        public static Map<Player, Integer> workingSlot = new HashMap<Player, Integer>();
    
        public void onEnable(){
            // ....


    And here the header of the iBooksPlayerListener.jar
    Show Spoiler

    Code:
    package com.robinrump.iBooks;
    
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.Map;
    import java.util.logging.Logger;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.event.player.PlayerListener;
     
    public class iBooksPlayerListener extends PlayerListener {
        public static iBooks plugin; public iBooksPlayerListener(iBooks instance) {
            plugin = instance;
     }
    
        Logger log = Logger.getLogger("Minecraft");
        String logPrefix = iBooksPlayerListener.plugin.logPrefix;
        Map<Player, Integer> mode = iBooks.mode;
    
        public void onPlayerInteract(PlayerInteractEvent event){
        // ...





    Thanks for everyone who tries to help me! :) Really really thanks.
     
  2. The error comes from line 23 in iBooksPlayerListener.java, which is
    Code:
        Map<Player, Integer> mode = iBooks.mode;
    
     
  3. Offline

    MrRump

    Could you tell me what's wrong about it?
     
  4. Offline

    Mak

    maybe make it like this:
    Map<Player, Integer> mode = new HashMap<Player, Integer>();
    mode = iBooks.mode;
     
  5. Offline

    MrRump

    I don't think it's this line. I deleted the whole line - there error is the same.
     
  6. Offline

    nisovin

    Pretty sure it's this line:
    Code:
    String logPrefix = iBooksPlayerListener.plugin.logPrefix;
    I believe any code you write outside of any class method gets called before the constructor gets called. It doesn't matter that it is located after the constructor, it will still get called first. Thus, when you try to access iBooksPlayerListener.plugin, it is still null.
     
  7. Offline

    MrRump

    You are definitely god. <3 Thank you ! :)
     
Thread Status:
Not open for further replies.

Share This Page