adventure
adventure copied to clipboard
Ability to find and replace across component and its children
Currently, if you do this:
Component component = Component.text()
.append(Component.text("Hello! I like ")
.append(Component.text("App").color(NamedTextColor.AQUA))
.append(Component.text("les").color(NamedTextColor.YELLOW)).asComponent();
component = component.replaceText(TextReplacementConfig.builder().match("Apples").replacement(Component.text("Bananas").color(NamedTextColor.YELLOW)).build());
System.out.println(GsonComponentSerializer.gson().serialize(component));
This would be the output
{"extra":[{"text":"Hello! I like "},{"color":"aqua","text":"App"},{"color":"yellow","text":"les"}],"text":""}
This is working as intended, tho it makes find and replacing text with different colors/style not possible with api as they must be span across multiple components.
It would be useful if the above code could produce a result like this:
{"extra":[{"text":"Hello! I like "},{"color":"yellow","text":"Bananas"}],"text":""}