Skip to content

Conversation

@TheLimeGlass
Copy link
Contributor

@TheLimeGlass TheLimeGlass commented Jun 10, 2025

Problem

The new AnyNamed causes VariableString values and default variables to have incorrect equal type sizes.

[16:02:16] [Server thread/ERROR]: #!#! Stack trace:
[16:02:16] [Server thread/ERROR]: #!#! Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.VariableString.getDefaultVariableNames(VariableString.java:594)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Variable.getRaw(Variable.java:330)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Variable.get(Variable.java:343)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Variable.getConverted(Variable.java:444)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Variable.getAll(Variable.java:722)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.conditions.CondIsSet.check(CondIsSet.java:58)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.conditions.CondIsSet.check(CondIsSet.java:64)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Condition.evaluate(Condition.java:78)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Condition.evaluate(Condition.java:23)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//org.skriptlang.skript.lang.condition.Conditional.evaluate(Conditional.java:45)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//org.skriptlang.skript.lang.condition.Conditional.evaluateAnd(Conditional.java:105)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//org.skriptlang.skript.lang.condition.CompoundConditional.evaluate(CompoundConditional.java:85)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//org.skriptlang.skript.lang.condition.CompoundConditional.evaluate(CompoundConditional.java:68)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.sections.SecConditional.checkConditions(SecConditional.java:412)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.sections.SecConditional.walk(SecConditional.java:300)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:33)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.function.ScriptFunction.execute(ScriptFunction.java:59)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.function.Function.execute(Function.java:107)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.function.FunctionReference.execute(FunctionReference.java:301)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.function.EffFunctionCall.execute(EffFunctionCall.java:34)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Effect.run(Effect.java:32)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:40)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:33)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.events.EvtPeriodical.execute(EvtPeriodical.java:103)
[16:02:16] [Server thread/ERROR]: #!#!     at Skript.jar//ch.njol.skript.events.EvtPeriodical.lambda$postLoad$0(EvtPeriodical.java:62)
[16:02:16] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78)
[16:02:16] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
[16:02:16] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1657)
[16:02:16] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1527)
[16:02:16] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1249)
[16:02:16] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:308)
[16:02:16] [Server thread/ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:1583)
[16:02:16] [Server thread/ERROR]: #!#! 
[16:02:16] [Server thread/ERROR]: #!#! Skript: 2.11.2 (custom)
[16:02:16] [Server thread/ERROR]: #!#!     Flavor: selfbuilt-unknown
[16:02:16] [Server thread/ERROR]: #!#!     Date: unknown
[16:02:16] [Server thread/ERROR]: #!#! Bukkit: 1.21.5-R0.1-SNAPSHOT
[16:02:16] [Server thread/ERROR]: #!#! Minecraft: 1.21.5
[16:02:16] [Server thread/ERROR]: #!#! Java: 21.0.6 (Java HotSpot(TM) 64-Bit Server VM 21.0.6+8-LTS-188)
[16:02:16] [Server thread/ERROR]: #!#! OS: Windows 10 amd64 10.0
[16:02:16] [Server thread/ERROR]: #!#! 
[16:02:16] [Server thread/ERROR]: #!#! Server platform: Paper
[16:02:16] [Server thread/ERROR]: #!#! 
[16:02:16] [Server thread/ERROR]: #!#! Current node: null
[16:02:16] [Server thread/ERROR]: #!#! Current item: if {hologramlocation::%name of (the world of {_display} (as java.lang.Object) >> ch.njol.skript.lang.util.ConvertedExpression$$Lambda/0x0000014916554210@6e1410b5: 
ConverterInfo{from=interface org.bukkit.World,to=interface ch.njol.skript.lang.util.common.AnyNamed,converter=ch.njol.skript.classes.data.DefaultConverters$$Lambda/0x0000014915f274b0@521b6003,flags=2})%::%loop-number%} (as 
java.lang.Object) is set
[16:02:16] [Server thread/ERROR]: #!#! Current trigger: function test (simple event) (test.sk, line 31)
[16:02:16] [Server thread/ERROR]: #!#! Thread: Server thread
[16:02:16] [Server thread/ERROR]: #!#! Language: english
[16:02:16] [Server thread/ERROR]: #!#! Link parse mode: DISABLED
[16:02:16] [Server thread/ERROR]: #!#! End of Error.
[16:02:16] [Server thread/ERROR]: #!#!

Solution

Avoid the index going over the saved type hints array. The calling code is capable of handling missing types.

Testing Completed

Following script sudo example errors when the variable is not set.

variables:
	{hologramheight1} = 100
	{hologramheight2} = 100
	{hologramscale2} = 7
	{hologramscale1} = 7
	{plots} = 2

function test(empty: boolean = false):
    loop {plots} times:
        set {_display} to first element out of entities in radius 1 around "LimeGlass" parsed as player
        if {hologramlocation::%name of world of {_display}%::%loop-number%} is set:
            ...

every tick:
    test()

After fix, no error.

@TheLimeGlass TheLimeGlass requested review from a team as code owners June 10, 2025 22:46
@TheLimeGlass TheLimeGlass requested review from TheMug06 and UnderscoreTud and removed request for a team June 10, 2025 22:46
@TheLimeGlass
Copy link
Contributor Author

Who is TheMug06? wth?

Copy link
Contributor

@TheMug06 TheMug06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is TheMug06? wth?

One of the guys approving your PR 😉

@SkriptLang SkriptLang deleted a comment from TheMug06 Jun 10, 2025
@sovdeeth sovdeeth added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Jun 11, 2025
@sovdeeth sovdeeth moved this to Awaiting Merge in 2.12 Releases Jun 11, 2025
@sovdeeth sovdeeth added the patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. label Jun 11, 2025
@sovdeeth sovdeeth linked an issue Jun 11, 2025 that may be closed by this pull request
1 task
@Burbulinis Burbulinis merged commit fe4f4a1 into SkriptLang:dev/patch Jun 12, 2025
5 checks passed
@skriptlang-automation skriptlang-automation bot added completed The issue has been fully resolved and the change will be in the next Skript update. and removed patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. labels Jun 12, 2025
@github-project-automation github-project-automation bot moved this from Awaiting Merge to Done in 2.12 Releases Jun 12, 2025
Burbulinis pushed a commit to Burbulinis/Skript that referenced this pull request Jul 9, 2025
…ng#7938)

* Fix index out of bounds on default variables that get converted

* Update aliases

* Update aliases
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. completed The issue has been fully resolved and the change will be in the next Skript update.

Projects

Status: Done - Released

Development

Successfully merging this pull request may close these issues.

ArrayOutOfBoundsException default variables

5 participants