Skip to content

NullPointerException in PropertyExpression.getAll() when tags of event-block is evaluated on entity right-click #8494

@Xgabi86

Description

@Xgabi86

Skript/Server Version

[16:07:44 INFO]: [Skript] Server Version: 1.21.8-60-29c8822 (MC: 1.21.8)
[16:07:44 INFO]: [Skript] Skript Version: 2.14.3 (skriptlang-github)
[16:07:44 INFO]: [Skript] Installed Skript Addons: 
[16:07:44 INFO]: [Skript]  - RiftoriaPlugin v1.2.1
[16:07:44 INFO]: [Skript]  - SkBee v3.17.1 (https://github.com/ShaneBeee/SkBee)
[16:07:44 INFO]: [Skript] Installed dependencies: 
[16:07:44 INFO]: [Skript]  - WorldGuard v7.0.14+2339-43997ec

Bug Description

PropertyExpression.getAll() throws a NullPointerException when evaluating if tags of event-block contain ... during a right-click on an entity (not a block). The result array is null because event-block returns null when the interaction target is an entity, and tags of null is not handled gracefully.

Expected Behavior

When event-block is null (e.g. player clicked an entity instead of a block), tags of event-block should return an empty array or null safely instead of throwing a NullPointerException.

Steps to Reproduce

on right click:
    if tags of event-block contain paper tag "beds":
        cancel event
  1. Place the above script
  2. Right-click any entity (not a block)
  3. Error is thrown

Errors or Screenshots

[16:01:28 ERROR]: #!#! 
[16:01:28 ERROR]: #!#! [Skript] Severe Error:
[16:01:28 ERROR]: #!#! 
[16:01:28 ERROR]: #!#! An unexpected error occurred with Skript. This issue is likely not your fault.
[16:01:28 ERROR]: #!#! You are using some plugins that alter how Skript works (addons).
[16:01:28 ERROR]: #!#! Full list of addons:
[16:01:28 ERROR]: #!#! SkBee v3.17.1 (https://github.com/ShaneBeee/SkBee)
[16:01:28 ERROR]: #!#! RiftoriaPlugin v1.2.1
[16:01:28 ERROR]: #!#! We could not identify related addons, it might also be a Skript issue.
[16:01:28 ERROR]: #!#! Try temporarily removing the listed plugins one by one to identify the cause.
[16:01:28 ERROR]: #!#! If removing a plugin resolves the issue, please report the problem to the plugin developer.
[16:01:28 ERROR]: #!#! 
[16:01:28 ERROR]: #!#! Stack trace:
[16:01:28 ERROR]: #!#! Caused by: java.lang.NullPointerException: Cannot read the array length because "result" is null
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.expressions.base.PropertyExpression.getAll(PropertyExpression.java:197)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//org.skriptlang.skript.common.properties.conditions.PropCondContains.check(PropCondContains.java:201)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.lang.Condition.evaluate(Condition.java:92)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.lang.Condition.evaluate(Condition.java:23)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//org.skriptlang.skript.lang.condition.Conditional.evaluate(Conditional.java:45)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//org.skriptlang.skript.lang.condition.Conditional.evaluateAnd(Conditional.java:105)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//org.skriptlang.skript.lang.condition.CompoundConditional.evaluate(CompoundConditional.java:85)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//org.skriptlang.skript.lang.condition.CompoundConditional.evaluate(CompoundConditional.java:68)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.sections.SecConditional.checkConditions(SecConditional.java:415)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.sections.SecConditional.walk(SecConditional.java:304)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:33)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.SkriptEventHandler.lambda$execute$2(SkriptEventHandler.java:165)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.SkriptEventHandler.lambda$execute$3(SkriptEventHandler.java:176)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.util.Task.callSync(Task.java:212)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.util.Task.callSync(Task.java:196)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.SkriptEventHandler.execute(SkriptEventHandler.java:174)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:120)
[16:01:28 ERROR]: #!#!     at Skript-2.14.3.jar//ch.njol.skript.SkriptEventHandler$PriorityListener.lambda$new$0(SkriptEventHandler.java:46)
[16:01:28 ERROR]: #!#!     at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[16:01:28 ERROR]: #!#!     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:71)
[16:01:28 ERROR]: #!#!     at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54)
[16:01:28 ERROR]: #!#!     at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131)
[16:01:28 ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.network.ServerGamePacketListenerImpl$1.performInteraction(ServerGamePacketListenerImpl.java:2773)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.network.ServerGamePacketListenerImpl$1.onInteraction(ServerGamePacketListenerImpl.java:2821)
[16:01:28 ERROR]: #!#!     at net.minecraft.network.protocol.game.ServerboundInteractPacket$InteractionAction.dispatch(ServerboundInteractPacket.java:140)
[16:01:28 ERROR]: #!#!     at net.minecraft.network.protocol.game.ServerboundInteractPacket.dispatch(ServerboundInteractPacket.java:91)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.network.ServerGamePacketListenerImpl.handleInteract(ServerGamePacketListenerImpl.java:2763)
[16:01:28 ERROR]: #!#!     at net.minecraft.network.protocol.game.ServerboundInteractPacket.handle(ServerboundInteractPacket.java:78)
[16:01:28 ERROR]: #!#!     at net.minecraft.network.protocol.game.ServerboundInteractPacket.handle(ServerboundInteractPacket.java:14)
[16:01:28 ERROR]: #!#!     at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:29)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.TickTask.run(TickTask.java:18)
[16:01:28 ERROR]: #!#!     at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:155)
[16:01:28 ERROR]: #!#!     at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1450)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:176)
[16:01:28 ERROR]: #!#!     at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:129)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1430)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1424)
[16:01:28 ERROR]: #!#!     at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:139)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1381)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1389)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1266)
[16:01:28 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:310)
[16:01:28 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:1583)
[16:01:28 ERROR]: #!#! 
[16:01:28 ERROR]: #!#! Skript: 2.14.3 (latest)
[16:01:28 ERROR]: #!#!     Flavor: skriptlang-github
[16:01:28 ERROR]: #!#!     Date: 21:17:31.758996
[16:01:28 ERROR]: #!#! Bukkit: 1.21.8-R0.1-SNAPSHOT
[16:01:28 ERROR]: #!#! Minecraft: 1.21.8
[16:01:28 ERROR]: #!#! Java: 21.0.10 (OpenJDK 64-Bit Server VM 21.0.10+7-LTS)
[16:01:28 ERROR]: #!#! OS: Linux amd64 6.1.0-43-amd64
[16:01:28 ERROR]: #!#! 
[16:01:28 ERROR]: #!#! Server platform: Paper
[16:01:28 ERROR]: #!#! 
[16:01:28 ERROR]: #!#! Current node: null
[16:01:28 ERROR]: #!#! Current item: if all
[16:01:28 ERROR]: #!#! Current trigger: right click (rightclick) (custom/resources/event/nightmare.sk, line 93)
[16:01:28 ERROR]: #!#! Thread: Server thread
[16:01:28 ERROR]: #!#! Language: english
[16:01:28 ERROR]: #!#! Link parse mode: DISABLED
[16:01:28 ERROR]: #!#! End of Error.
[16:01:28 ERROR]: #!#! 

Other

No response

Agreement

  • I have read the guidelines above and affirm I am following them with this report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn issue that needs to be fixed. Alternatively, a PR fixing an issue.completedThe issue has been fully resolved and the change will be in the next Skript update.priority: mediumIssues that are detrimental to user experience (prohibitive bugs or lack of useful implementation).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions