Add workaround for pairs of ' being stripped (#8074)

Backport of #8050
This commit is contained in:
sciwhiz12 authored and GitHub committed 2021-10-03 18:51:40 +02:00
1 parent acf871f934
commit 9ef34a9f1a
1 file changed
+13 -1
@@ -28,7 +28,19 @@ import java.util.List;
public class TextComponentMessageFormatHandler {
public static int handle(final TranslationTextComponent parent, final List<ITextProperties> children, final Object[] formatArgs, final String format) {
try {
StringTextComponent component = new StringTextComponent(ForgeI18n.parseFormat(format, formatArgs));
final String formattedString = ForgeI18n.parseFormat(format, formatArgs);
// See MinecraftForge/MinecraftForge#7396
if (format.indexOf('\'') != -1) {
final boolean onlyMissingQuotes = format.chars()
.filter(ch -> formattedString.indexOf((char) ch) == -1)
.allMatch(ch -> ch == '\'');
if (onlyMissingQuotes) {
return 0;
}
}
StringTextComponent component = new StringTextComponent(formattedString);
component.getStyle().applyTo(parent.getStyle());
children.add(component);
return format.length();