You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// MiniMessage NOT required to reproduce but used for readabilityfinalComponentcomponent = MiniMessage.miniMessage().deserialize("<gradient:red:blue>This is a test, {player}").replaceText(b -> b.matchLiteral("{player}").replacement("Demo"));
System.out.println("Demo: " + PlainTextComponentSerializer.plainText().serialize(component));
The way this is implemented (by the way, MiniMessage is NOT required to reproduce, simply chain letters with different colors to do so) the Component turns into {"extra":[{"color":"red","text":"T"},{"color":"#F8555C","text":"h"},{"color":"#F05564","text":"i"},{"color":"#E9556B","text":"s"},{"color":"#E15573","text":" "},{"color":"#DA557A","text":"i"},{"color":"#D35581","text":"s"},{"color":"#CB5589","text":" "},{"color":"#C45590","text":"a"},{"color":"#BC5598","text":" "},{"color":"#B5559F","text":"t"},{"color":"#AE55A6","text":"e"},{"color":"#A655AE","text":"s"},{"color":"#9F55B5","text":"t"},{"color":"#9855BC","text":","},{"color":"#9055C4","text":" "},{"color":"#8955CB","text":"{"},{"color":"#8155D3","text":"p"},{"color":"#7A55DA","text":"l"},{"color":"#7355E1","text":"a"},{"color":"#6B55E9","text":"y"},{"color":"#6455F0","text":"e"},{"color":"#5C55F8","text":"r"},{"color":"blue","text":"}"}],"text":""} and the replaceText() method is unable to find the letters.
The only way we "fixed" it so far is to replace variables on the raw message before parsing it.
Thanks
Matej
The text was updated successfully, but these errors were encountered:
Unfortunately this is a limitation of replaceText, it doesn't look for matches across component boundaries. It's possible to redesign the replacement logic to not have this limitation, but we haven't figured out a way to do it without significantly increasing the complexity of the API.
zml2008
changed the title
Gradients break Component#replaceText()
Component#replaceText() does not match across component boundaries
Dec 1, 2024
Code:
The way this is implemented (by the way, MiniMessage is NOT required to reproduce, simply chain letters with different colors to do so) the Component turns into
{"extra":[{"color":"red","text":"T"},{"color":"#F8555C","text":"h"},{"color":"#F05564","text":"i"},{"color":"#E9556B","text":"s"},{"color":"#E15573","text":" "},{"color":"#DA557A","text":"i"},{"color":"#D35581","text":"s"},{"color":"#CB5589","text":" "},{"color":"#C45590","text":"a"},{"color":"#BC5598","text":" "},{"color":"#B5559F","text":"t"},{"color":"#AE55A6","text":"e"},{"color":"#A655AE","text":"s"},{"color":"#9F55B5","text":"t"},{"color":"#9855BC","text":","},{"color":"#9055C4","text":" "},{"color":"#8955CB","text":"{"},{"color":"#8155D3","text":"p"},{"color":"#7A55DA","text":"l"},{"color":"#7355E1","text":"a"},{"color":"#6B55E9","text":"y"},{"color":"#6455F0","text":"e"},{"color":"#5C55F8","text":"r"},{"color":"blue","text":"}"}],"text":""}
and the replaceText() method is unable to find the letters.The only way we "fixed" it so far is to replace variables on the raw message before parsing it.
Thanks
Matej
The text was updated successfully, but these errors were encountered: