From 0d1c20f61b4072e8ca88173c583e89cd4547671b Mon Sep 17 00:00:00 2001 From: ATATC Date: Sun, 13 Aug 2023 19:08:51 +0800 Subject: [PATCH] Bug fixed: `java.lang.StringIndexOutOfBoundsException` when parsing an empty `MultiComponent`. --- .../java/com/atatctech/hephaestus/component/MultiComponent.java | 1 + src/main/java/com/atatctech/hephaestus/component/Ref.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/atatctech/hephaestus/component/MultiComponent.java b/src/main/java/com/atatctech/hephaestus/component/MultiComponent.java index e9aa19f..5d4d6a8 100644 --- a/src/main/java/com/atatctech/hephaestus/component/MultiComponent.java +++ b/src/main/java/com/atatctech/hephaestus/component/MultiComponent.java @@ -13,6 +13,7 @@ @ComponentConfig(tagName = "mc") public class MultiComponent extends Component implements Collection { public static @NotNull Parser PARSER = expr -> { + if (expr.isEmpty()) return new MultiComponent(); char open = expr.charAt(0); Text.IndexPair indexes = Text.matchBrackets(expr, open, Text.pairBracket(open)); int endIndex = indexes.end(); diff --git a/src/main/java/com/atatctech/hephaestus/component/Ref.java b/src/main/java/com/atatctech/hephaestus/component/Ref.java index 18a849e..87687f9 100644 --- a/src/main/java/com/atatctech/hephaestus/component/Ref.java +++ b/src/main/java/com/atatctech/hephaestus/component/Ref.java @@ -11,6 +11,7 @@ public class Ref extends Component { static { PARSER = Ref::new; } + protected @Nullable Component to; public Ref(@Nullable String id) {