Solved Could not pass event BlockBreakEvent

Discussion in 'Plugin Development' started by WannabeAProGamer, May 18, 2016.

Thread Status:
Not open for further replies.
  1. I got the following error in my plugin after breaking a block to test it:
    [17:05:43 ERROR]: Could not pass event BlockBreakEvent to SpecPick v1.0
            at$1.execute( ~[craftbukkit-1.8.jar:git-Bukkit-7019900]
            at org.bukkit.plugin.RegisteredListener.callEvent( ~[craftbukkit-1.8.jar:git-Bukkit-7019900]
            at org.bukkit.plugin.SimplePluginManager.fireEvent( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at org.bukkit.plugin.SimplePluginManager.callEvent( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.PlayerInteractManager.breakBlock( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.PlayerInteractManager.a( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.PlayerConnection.a( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.PacketPlayInBlockDig.a(SourceFile:40) [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.PacketPlayInBlockDig.a(SourceFile:10) [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at java.util.concurrent.Executors$ [?:1.8.0_72]
            at [?:1.8.0_72]
            at net.minecraft.server.v1_8_R1.MinecraftServer.z( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.DedicatedServer.z( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at net.minecraft.server.v1_8_R1.MinecraftServer.y( [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at [craftbukkit-1.8.jar:git-Bukkit-7019900]
            at [?:1.8.0_72]
    Caused by: java.lang.NullPointerException
            at me.wannabeaprogamer.MiningListener.veinPickModifier( ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_72]
            at sun.reflect.NativeMethodAccessorImpl.invoke( ~[?:1.8.0_72]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke( ~[?:1.8.0_72]
            at java.lang.reflect.Method.invoke( ~[?:1.8.0_72]
            at$1.execute( ~[craftbukkit-1.8.jar:git-Bukkit-7019900]
            ... 16 more
    I don't know what my mistake is, and no, I didn't forget to do
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
  2. Offline


    You have a NPE on the 27 line of your class MiningListerner.
    If you could give me your class i would apreciate.
    Also, you should learn by your own how to troubleshot your own erros, so you wouldnt need any help on this -
  3. This is the MiningListener class:
    Show Spoiler

    package me.wannabeaprogamer;
    import java.util.List;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    public class MiningListener implements Listener
        public MiningListener(VeinMinerPicks plugin)
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        public void veinPickModifier(BlockBreakEvent e)
            ItemStack is = e.getPlayer().getItemInHand();
            ItemMeta im = is.getItemMeta();
            List<String> lore = im.getLore();
            Block broken = e.getBlock();
            Location center = broken.getLocation();
            World world = broken.getWorld();
            if(lore.contains(ChatColor.GOLD + "Special pickaxe,"))
                for(String loreString : lore)
                    String ench = loreString.substring(0, loreString.indexOf(" "));
                    int value = Integer.parseInt(loreString.substring(loreString.indexOf(" ") + 1, loreString.length()));
                    case "§7Veinmining":
                        Location vein1 = center;
                        vein1.setX(vein1.getX() + value);
                        vein1.setY(vein1.getY() + value);
                        vein1.setZ(vein1.getZ() + value);
                        Location vein2 = center;
                        vein2.setX(vein2.getX() - value);
                        vein2.setY(vein2.getY() - value);
                        vein2.setZ(vein2.getZ() - value);
                        Location vein3;
                        for(double x = vein1.getX(); x <= vein2.getX(); x++) {
                            for(double y = vein1.getY(); y <= vein2.getY(); y++) {
                                for(double z = vein1.getZ(); z <= vein2.getZ(); z++) {
                                    vein3 = new Location(world, x, y, z);
                    case "§7Flatvein":
                        Location flat1 = center;
                        flat1.setX(flat1.getX() + value);
                        flat1.setZ(flat1.getZ() + value);
                        Location flat2 = center;
                        flat2.setX(flat2.getX() - value);
                        flat2.setZ(flat2.getZ() - value);
                        Location flat3;
                        for(double x = flat1.getX(); x <= flat2.getX(); x++) {
                            for(double z = flat1.getZ(); z <= flat2.getZ(); z++) {
                                flat3 = new Location(world, x, center.getY(), z);
  4. Offline

    I Al Istannen

    1. Find Java file. Check.

    2. Find error line. Check:
    Line 27: "List<String> lore = im.getLore();".​

    3. Look at error:
    Null pointer exception ==> Something is null and a method was called on this null object​

    4. Thinking:
    What do you think can be null here?​

    EDIT: Not meant to be offensive, just want you to go through the troubleshooting steps with me ;)
  5. Offline


    I think you forgot to set the item meta of the item.
  6. I understand that :)
    I fixed it after reading the post @Gonmarte linked...
    THIS error at least... now I'm trying to fix another
    Thank you both for helping!
  7. Offline

    I Al Istannen

  8. Fortunately there are not more bugs in the code...

    Just more the code can reach:p

    Oh, and they are not little bugs... they stop the entire plugin from working:mad:
Thread Status:
Not open for further replies.

Share This Page