CitizensDev / Citizens2

Citizens - the premier plugin and API for creating server-side NPCs in Minecraft.
https://citizensnpcs.co
Open Software License 3.0
589 stars 313 forks source link

Error in logs with Citizens after setting a pose #2520

Closed Th3BlxckCxt closed 3 years ago

Th3BlxckCxt commented 3 years ago

it's not flooding anymore but I will post the issue anyways. When setting a pose for an NPC my console log was flooding and spamming with this: [INFO] [Citizens] Exception while updating 26: null.

[WARNING] java.lang.NullPointerException

[WARNING] at org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity.hasLineOfSight(CraftLivingEntity.java:489)

[WARNING] at net.citizensnpcs.trait.LookClose.canSee(LookClose.java:58)

[WARNING] at net.citizensnpcs.trait.LookClose.canSeeTarget(LookClose.java:67)

[WARNING] at net.citizensnpcs.trait.Poses.run(Poses.java:133)

[WARNING] at net.citizensnpcs.api.npc.AbstractNPC.update(AbstractNPC.java:480)

[WARNING] at net.citizensnpcs.npc.CitizensNPC.update(CitizensNPC.java:350)

[WARNING] at net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC.tick(EntityHumanNPC.java:463)

[WARNING] at net.minecraft.server.v1_16_R3.WorldServer.entityJoinedWorld(WorldServer.java:772)

[WARNING] at net.minecraft.server.v1_16_R3.World.a(World.java:769)

[WARNING] at net.minecraft.server.v1_16_R3.WorldServer.doTick(WorldServer.java:507)

[WARNING] at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1214)

[WARNING] at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:394)

[WARNING] at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1117)

[WARNING] at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:956)

[WARNING] at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273)

I dont have a server log link since its been a day. But here is a link to my citizens config: https://paste.helpch.at/udidevovar.coffeescript Server version is CraftBukkit version 3029-Spigot-79d53c2-e9ad7ob 9MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT) Citizens version is 2.0.27-SNAPSHOT 9build 22690

mcmonkey4eva commented 3 years ago

This appears to be:

This line was called: https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/Poses.java#L133

Which translates to this method: https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/LookClose.java#L67

Which uses the lookingAt field, which can be null: https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/LookClose.java#L40

so when this is reached: https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/LookClose.java#L58

It's passing that null value along, and thus throwing an NPE.

The solution should be as simple as: add a null check to canSeeTarget

Th3BlxckCxt commented 3 years ago

Sorry Im not the brightest. Im not sure what that means

On Sat, 3 Apr 2021 at 21:20, mcmonkey4eva @.***> wrote:

This appears to be:

This line was called:

https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/Poses.java#L133

Which translates to this method:

https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/LookClose.java#L67

Which uses the lookingAt field, which can be null:

https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/LookClose.java#L40

so when this is reached:

https://github.com/CitizensDev/Citizens2/blob/48a2763a1b68d9c76f576265b07a1c8df748d52f/main/src/main/java/net/citizensnpcs/trait/LookClose.java#L58

It's passing that null value along, and thus throwing an NPE.

The solution should be as simple as: add a null check to canSeeTarget

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CitizensDev/Citizens2/issues/2520#issuecomment-812952913, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATQYGRCB7P6WCO5WMIKZLBLTG65FPANCNFSM42K2ND6Q .

mcmonkey4eva commented 3 years ago

That was a quick technical analysis of why the error happened. You don't need to understand it, it's mainly for fullwall's reference so he can very quickly and easily fix it when he sees this post.

Th3BlxckCxt commented 3 years ago

oh haha alright

On Sat, 3 Apr 2021 at 21:26, mcmonkey4eva @.***> wrote:

That was a quick technical analysis of why the error happened. You don't need to understand it, it's mainly for fullwall's reference so he can very quickly and easily fix it when he sees this post.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CitizensDev/Citizens2/issues/2520#issuecomment-812953449, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATQYGREGP2LGOCJL5SQWSVLTG653BANCNFSM42K2ND6Q .

mcmonkey4eva commented 3 years ago

Should be fixed by https://github.com/CitizensDev/Citizens2/commit/74839e9843ed7a222f46e5db027ae3e57e2307ee in build 2282+ from https://ci.citizensnpcs.co/job/Citizens2/