Skip to content

Commit

Permalink
Fixes that children get replaced twice if colors are included in repl…
Browse files Browse the repository at this point in the history
…acements
  • Loading branch information
Phoenix616 committed Jan 16, 2022
1 parent 3605778 commit 110f941
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/de/themoep/minedown/adventure/Replacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,13 @@ public Component replaceIn(Component component) {
component = ((TextComponent) component).content("");
List<Component> children = new ArrayList<>();
children.add(replacedComponent);
children.addAll(component.children());
children.addAll(replaceIn(component.children()));
component = component.children(children);
} else {
component = ((TextComponent) component).content(replaced);
component = ((TextComponent) component).content(replaced).children(replaceIn(component.children()));
}
} else if (!component.children().isEmpty()) {
component = component.children(replaceIn(component.children()));
}
if (component instanceof TranslatableComponent) {
component = ((TranslatableComponent) component).key(replaceIn(((TranslatableComponent) component).key()));
Expand Down Expand Up @@ -259,8 +261,6 @@ public Component replaceIn(Component component) {
}
}

component = component.children(replaceIn(component.children()));

// Component replacements
List<Component> replacedComponents = new ArrayList<>();
replacedComponents.add(component);
Expand Down

0 comments on commit 110f941

Please sign in to comment.