Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix expression null pointer exception on expressions with null return type #6497

Merged
merged 5 commits into from
Apr 1, 2024

Conversation

TheLimeGlass
Copy link
Contributor

@TheLimeGlass TheLimeGlass commented Mar 16, 2024

Description

If an expression returns null as it's return type, it throws a NullPointerException at parse time. This pull request makes the error a safe SkriptAPIException.

Error this pull fixes:

[02:29:38] [Server thread/ERROR]: #!#! Stack trace:
[02:29:38] [Server thread/ERROR]: #!#! java.lang.NullPointerException
[02:29:38] [Server thread/ERROR]: #!#!     at java.base/java.lang.Class.isAssignableFrom(Native Method)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.SkriptParser.parseSingleExpr(SkriptParser.java:540)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.SkriptParser.parseExpression(SkriptParser.java:752)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.patterns.TypePatternElement.match(TypePatternElement.java:159)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.patterns.PatternElement.matchNext(PatternElement.java:54)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.patterns.LiteralPatternElement.match(LiteralPatternElement.java:65)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.patterns.SkriptPattern.match(SkriptPattern.java:58)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1252)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:227)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:174)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Effect.parse(Effect.java:75)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.command.Commands.handleEffectCommand(Commands.java:190)
[02:29:38] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.command.Commands$2.lambda$onPlayerChat$0(Commands.java:300)
[02:29:38] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftFuture.run(CraftFuture.java:88)
[02:29:38] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[02:29:38] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1479)
[02:29:38] [Server thread/ERROR]: #!#!     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:446)
[02:29:38] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1393)
[02:29:38] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1170)
[02:29:38] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317)
[02:29:38] [Server thread/ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)

Target Minecraft Versions: any
Requirements: none
Related Issues: none

@AyhamAl-Ali AyhamAl-Ali added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Mar 16, 2024
Co-authored-by: Ayham Al Ali <20037329+AyhamAl-Ali@users.noreply.github.com>
src/main/java/ch/njol/skript/lang/SkriptParser.java Outdated Show resolved Hide resolved
@TheLimeGlass TheLimeGlass requested a review from Pikachu920 March 16, 2024 19:19
@AyhamAl-Ali AyhamAl-Ali added the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Mar 29, 2024
@sovdeeth sovdeeth merged commit dfaa66f into SkriptLang:dev/patch Apr 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants