Solved Error really needs help :(

Discussion in 'Plugin Development' started by glassbillen, Feb 16, 2014.

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

    glassbillen

    Im getting this error when i use my plugins (a teleporting bow) and in startup!!! here is the error
    Code:
    17:22:41  [Server thread/ERROR]: Could not pass event ProjectileHitEvent to TeleportBow v2.0
    17:22:41 org.bukkit.event.EventException
    17:22:41 at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectileHitEvent(CraftEventFactory.java:603) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.EntityArrow.h(EntityArrow.java:209) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1338) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1319) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1207) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.java:480) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:637) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 Caused by: java.lang.NullPointerException
    17:22:41 at me.Glassbillen.TeleportBow.TeleportBow.onProjectileHitEvent(TeleportBow.java:51) ~[?:?]
    17:22:41 at sun.reflect.GeneratedMethodAccessor1217.invoke(Unknown Source) ~[?:?]
    17:22:41 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
    17:22:41 at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
    17:22:41 at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:41 ... 14 more
    17:22:42  [Server thread/ERROR]: Could not pass event ProjectileHitEvent to TeleportBow v2.0
    17:22:42 org.bukkit.event.EventException
    17:22:42 at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectileHitEvent(CraftEventFactory.java:603) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.EntityArrow.h(EntityArrow.java:209) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1338) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1319) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1207) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.java:480) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:637) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 Caused by: java.lang.NullPointerException
    17:22:42 at me.Glassbillen.TeleportBow.TeleportBow.onProjectileHitEvent(TeleportBow.java:51) ~[?:?]
    17:22:42 at sun.reflect.GeneratedMethodAccessor1217.invoke(Unknown Source) ~[?:?]
    17:22:42 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
    17:22:42 at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
    17:22:42 at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 ... 14 more
    17:22:42  [Server thread/ERROR]: Could not pass event ProjectileHitEvent to TeleportBow v2.0
    17:22:42 org.bukkit.event.EventException
    17:22:42 at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:481) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:466) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at org.bukkit.craftbukkit.v1_7_R1.event.CraftEventFactory.callProjectileHitEvent(CraftEventFactory.java:603) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.EntityArrow.h(EntityArrow.java:209) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.World.entityJoinedWorld(World.java:1338) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.World.playerJoinedWorld(World.java:1319) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.World.tickEntities(World.java:1207) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.WorldServer.tickEntities(WorldServer.java:480) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:637) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 Caused by: java.lang.NullPointerException
    17:22:42 at me.Glassbillen.TeleportBow.TeleportBow.onProjectileHitEvent(TeleportBow.java:51) ~[?:?]
    17:22:42 at sun.reflect.GeneratedMethodAccessor1217.invoke(Unknown Source) ~[?:?]
    17:22:42 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
    17:22:42 at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
    17:22:42 at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:318) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-3-g530fcb7-b2982jnks]
    17:22:42 ... 14 more
    How do i fix this!!!
    Here is my main class:
    Code:
    package me.Glassbillen.TeleportBow;
     
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Arrow;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Projectile;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.ProjectileHitEvent;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class TeleportBow extends JavaPlugin implements Listener {
        public final Logger logger = Logger.getLogger("Minecraft");
        public static TeleportBow plugin;
       
        SettingsManager settings = SettingsManager.getInstance();
     
        @Override
        public void onDisable() {
            getLogger().info("TeleportBow has been disabled!");
        }
       
        @Override
        public void onEnable() {
            getLogger().info("TeleportBow has been enabled!");
            Bukkit.getPluginManager().registerEvents(this, this);
            settings.setup(this);
        }
       
        @EventHandler
        public void onProjectileHitEvent(ProjectileHitEvent event) {
     
        if (!(event.getEntity().getShooter() instanceof Player)) return;
     
        if (event.getEntity() instanceof Arrow) {
     
        Player player = (Player) event.getEntity().getShooter();
        Projectile proj = event.getEntity();
     
        if (player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase("TPBow")) {
     
        player.teleport(proj.getLocation());
        }
        }
        }
     
  2. Offline

    clienthax

    player.getIteminHand can be null, therefor calling any submethod without adequate checking = null pointer
     
  3. Offline

    glassbillen

    How do i fix that clienthax ? (i hope i dont need to remove TPBow name beacus i dont want all bows to be tpbows
     
  4. Offline

    Gater12

    glassbillen
    Add a null check. If it's null then return.
    Also check if the item has an ItemMeta
     
  5. Offline

    glassbillen

  6. Offline

    Gater12

    glassbillen
    It's very simple.
    Code:java
    1. if(p.getItemInHand() == null) return;
    2. if(!p.getItemInHand().hasItemMeta()) return;

    Null checks are basically: if this is null, then return or if this isn't null continue.
     
  7. Offline

    glassbillen

    And where should i put that? Gater12

    Bump, anyone knows where i should put the Null check and ItemData check

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  8. Offline

    _Filip

  9. Offline

    glassbillen

    nvm, i got it fixed
     
Thread Status:
Not open for further replies.

Share This Page