Remove TooltipHelper.getUnformattedDeepText

- Replace it with ITextComponent.getString
This commit is contained in:
PepperBell 2021-06-23 22:32:42 -07:00
parent 1e65e3aee6
commit 8d90137b1a
3 changed files with 5 additions and 14 deletions

View file

@ -26,7 +26,7 @@ public interface IDisplayAssemblyExceptions {
tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(Lang.translate("gui.assembly.exception").formatted(TextFormatting.GOLD)));
String text = TooltipHelper.getUnformattedDeepText(e.component);
String text = e.component.getString();
Arrays.stream(text.split("\n"))
.forEach(l -> TooltipHelper.cutStringTextComponent(l, GRAY, WHITE)
.forEach(c -> tooltip.add(IHaveGoggleInformation.componentSpacing.copy().append(c))));
@ -35,4 +35,5 @@ public interface IDisplayAssemblyExceptions {
}
AssemblyException getLastAssemblyException();
}

View file

@ -212,10 +212,8 @@ public class ItemDescription {
boolean hasControls = !linesOnCtrl.isEmpty();
if (hasDescription || hasControls) {
String[] holdDesc = TooltipHelper.getUnformattedDeepText(Lang.translate("tooltip.holdForDescription", "$"))
.split("\\$");
String[] holdCtrl = TooltipHelper.getUnformattedDeepText(Lang.translate("tooltip.holdForControls", "$"))
.split("\\$");
String[] holdDesc = Lang.translate("tooltip.holdForDescription", "$").getString().split("\\$");
String[] holdCtrl = Lang.translate("tooltip.holdForControls", "$").getString().split("\\$");
IFormattableTextComponent keyShift = Lang.translate("tooltip.keyShift");
IFormattableTextComponent keyCtrl = Lang.translate("tooltip.keyCtrl");
for (List<ITextComponent> list : Arrays.asList(lines, linesOnShift, linesOnCtrl)) {

View file

@ -124,7 +124,7 @@ public class TooltipHelper {
public static List<ITextComponent> cutTextComponent(ITextComponent c, TextFormatting defaultColor,
TextFormatting highlightColor, int indent) {
String s = getUnformattedDeepText(c);
String s = c.getString();
// Apply markup
String markedUp = s;// .replaceAll("_([^_]+)_", highlightColor + "$1" + defaultColor);
@ -330,12 +330,4 @@ public class TooltipHelper {
// return l.get();
// }
public static String getUnformattedDeepText(ITextComponent component) {
StringBuilder b = new StringBuilder();
b.append(component.getString());
component.getSiblings()
.forEach(c -> b.append(getUnformattedDeepText(c)));
return b.toString();
}
}