Skip to content

Commit

Permalink
Fixed root component args not being iterated
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenni0451 committed Apr 5, 2024
1 parent 2616a41 commit 7a41b95
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,15 @@ public static ATextComponent replace(final ATextComponent component, final Funct
ATextComponent out = component.copy();
out.getSiblings().clear();
out = replaceFunction.apply(out);
for (ATextComponent sibling : component.getSiblings()) {
ATextComponent replace = replace(sibling, replaceFunction);
if (replace instanceof TranslationComponent) {
TranslationComponent translationComponent = (TranslationComponent) replace;
Object[] args = translationComponent.getArgs();
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof ATextComponent) {
args[i] = replace((ATextComponent) args[i], replaceFunction);
}
if (out instanceof TranslationComponent) {
Object[] args = ((TranslationComponent) out).getArgs();
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof ATextComponent) {
args[i] = replace((ATextComponent) args[i], replaceFunction);
}
}
out.append(replace);
}
for (ATextComponent sibling : component.getSiblings()) out.append(replace(sibling, replaceFunction));
return out;
}

Expand Down

0 comments on commit 7a41b95

Please sign in to comment.