package com.yolp900.itsjustacharm.util; import com.mojang.realmsclient.gui.ChatFormatting; import net.minecraft.client.resources.I18n; import java.util.ArrayList; import java.util.List; public class TextHelper { public static String translateToLocal(String unlocalizedText, Object... params) { return I18n.format(unlocalizedText, params); } public static List<String> getLinedText(String localizedText) { String[] lines = localizedText.split("/line/"); List<String> ret = new ArrayList<>(lines.length); for (int i = 0; i < lines.length; i++) { ret.add(i, lines[i]); } return ret; } public static String getFormattedText(String localizedText) { for (ChatFormatting format : ChatFormatting.values()) { localizedText = localizedText.replace(format.toString(), ""+format); } return localizedText; } public static List<String> getLinedFormattedText(String localizedText) { List<String> linedText = getLinedText(localizedText); List<String> ret = new ArrayList<String>(linedText.size()); for (String line : linedText) { ret.add(getFormattedText(line)); } return ret; } }