Getting errors when arrow lands at unloaded chunk

Discussion in 'Plugin Development' started by Minesuchtiiii, Jun 18, 2019.

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

    Minesuchtiiii

    Stacktrace:

    Show Spoiler

    [00:12:32] [Server thread/ERROR]: Could not pass event ProjectileHitEvent to iSe
    rverRecords v1.01
    org.bukkit.event.EventException: null
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:320) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:70) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:520) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:505) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory.callProjectil
    eHitEvent(CraftEventFactory.java:1123) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.EntityArrow.a(EntityArrow.java:273) ~[s
    pigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.EntityArrow.tick(EntityArrow.java:188)
    ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.EntityTippedArrow.tick(EntityTippedArro
    w.java:87) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.WorldServer.entityJoinedWorld(WorldServ
    er.java:570) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.World.a(World.java:745) [spigot.jar:git
    -Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.WorldServer.doTick(WorldServer.java:346
    ) [spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:
    1057) [spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:
    396) [spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:
    956) [spigot.jar:git-Spigot-093165d-ba575a5]
    at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.jav
    a:801) [spigot.jar:git-Spigot-093165d-ba575a5]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_161]
    Caused by: java.lang.NullPointerException
    at listeners.FarthestBowShotListener.onPassiveBowShot(FarthestBowShotLis
    tener.java:41) ~[?:?]
    at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .8.0_161]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_161]
    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:316) ~[spigot.jar:git-Spigot-093165d-ba575a5]
    ... 15 more



    Code:

    Code:
                if(e.getEntity() instanceof Arrow) {
                   
                    Arrow a = (Arrow) e.getEntity();
                   
                    if(e.getEntity().getShooter() instanceof Player) {
                       
                        Player p = (Player) a.getShooter();
                       
                        double tobeat = ######;
                        double close = tobeat * 0.96;
                       
                        if(e.getHitBlock().getLocation().getChunk().isLoaded()) { //line 41
                       
                        Location aloc = e.getHitBlock().getLocation();
                        aloc.getChunk().load(true);
                        Location ploc = this.plugin.playerloc.get(p.getUniqueId());
                       
                        DecimalFormat df = new DecimalFormat("#.##");
                        double distance = aloc.distance(ploc);
     
  2. Offline

    Zombie_Striker

    @Minesuchtiiii
    Try checking to make sure the hit block is not null before checking the location, and then check the chunk to make sure is not null before checking if it is loaded.
     
Thread Status:
Not open for further replies.

Share This Page