Skip to content

Empty string breaks text color of #8550

@TheLimeGlass

Description

@TheLimeGlass

Skript/Server Version

2.15.0
MC 1.21.5

Bug Description

Using an empty string in the string text of expression throws an exception

Expected Behavior

To not throw an exception

Steps to Reproduce

function test():
  set {_test} to ""
  broadcast string color of colored "<%{_test}%>"

Errors or Screenshots

#!#! Caused by: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#!#!     at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
#!#!     at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
#!#!     at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
#!#!     at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
#!#!     at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
#!#!     at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
#!#!     at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
#!#!     at java.base/java.lang.String.checkIndex(String.java:4822)
#!#!     at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:46)
#!#!     at java.base/java.lang.String.charAt(String.java:1544)
#!#!     at Skript-2.15.0.jar//org.skriptlang.skript.bukkit.text.elements.expressions.ExprStringColor.getColors(ExprStringColor.java:139)
#!#!     at Skript-2.15.0.jar//org.skriptlang.skript.bukkit.text.elements.expressions.ExprStringColor.get(ExprStringColor.java:72)
#!#!     at Skript-2.15.0.jar//org.skriptlang.skript.bukkit.text.elements.expressions.ExprStringColor.get(ExprStringColor.java:29)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.expressions.base.PropertyExpression.get(PropertyExpression.java:196)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:86)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.util.ConvertedExpression.getArray(ConvertedExpression.java:213)
#!#!     at Skript-2.15.0.jar//org.skriptlang.skript.bukkit.text.elements.effects.EffBroadcast.execute(EffBroadcast.java:64)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Effect.run(Effect.java:42)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:40)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:33)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.function.ScriptFunction.execute(ScriptFunction.java:118)
#!#!     at Skript-2.15.0.jar//org.skriptlang.skript.common.function.FunctionReference.execute(FunctionReference.java:170)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.function.ExprFunctionCall.get(ExprFunctionCall.java:54)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.util.SimpleExpression.getArray(SimpleExpression.java:86)
#!#!     at Skript-2.15.0.jar//org.skriptlang.skript.bukkit.text.elements.effects.EffBroadcast.execute(EffBroadcast.java:64)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.Effect.run(Effect.java:42)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:40)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:67)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.command.Commands.handleEffectCommand(Commands.java:192)
#!#!     at Skript-2.15.0.jar//ch.njol.skript.command.Commands$2.lambda$onPlayerChat$1(Commands.java:292)
#!#!     at org.bukkit.craftbukkit.scheduler.CraftFuture.run(CraftFuture.java:88)
#!#!     at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:474)
#!#!     at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1657)
#!#!     at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1527)
#!#!     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1249)
#!#!     at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:308)
#!#!     at java.base/java.lang.Thread.run(Thread.java:1583)

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

    2.15Targeting a 2.15.X version release.PR availableIssues which have a yet-to-be merged PR resolving itbugAn issue that needs to be fixed. Alternatively, a PR fixing an issue.patch-readyA PR/issue that has been approved and is ready to be merged/closed for the next patch version.

    Type

    No type

    Projects

    Status

    Awaiting Merge

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions