Skip to content

Commit 7ebcc2d

Browse files
committed
add string with formatting and number method to KeyUtil
don't use lang for basic string formatting
1 parent 28a888b commit 7ebcc2d

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ public Builder addEnergyUsageLine(IEnergyContainer energyContainer) {
471471

472472
IKey bodyText = KeyUtil.lang(TextFormatting.GRAY,
473473
"gregtech.multiblock.max_energy_per_tick",
474-
TextFormattingUtil.formatNumbers(maxVoltage),
475-
GTValues.VOCNF[GTUtility.getFloorTierByVoltage(maxVoltage)]);
474+
KeyUtil.number(maxVoltage),
475+
KeyUtil.string(GTValues.VOCNF[GTUtility.getFloorTierByVoltage(maxVoltage)]));
476476

477477
var hoverText = KeyUtil.lang(TextFormatting.GRAY,
478478
"gregtech.multiblock.max_energy_per_tick_hover");

src/main/java/gregtech/api/util/KeyUtil.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,19 @@ public static IKey string(TextFormatting formatting, String string) {
2828
return IKey.str(string).style(formatting);
2929
}
3030

31+
public static IKey string(TextFormatting formatting, String string, Object... args) {
32+
if (string == null) return IKey.EMPTY;
33+
return IKey.str(string, args).style(formatting);
34+
}
35+
3136
public static IKey string(TextFormatting formatting, Supplier<String> stringSupplier) {
3237
return IKey.dynamic(stringSupplier).style(formatting);
3338
}
3439

40+
public static IKey string(TextFormatting formatting, Supplier<String> stringSupplier, Supplier<Object[]> argSupplier) {
41+
return IKey.dynamic(() -> String.format(stringSupplier.get(), argSupplier.get())).style(formatting);
42+
}
43+
3544
public static IKey string(Supplier<TextFormatting> formatting, String s) {
3645
return IKey.dynamic(() -> IKey.str(s).style(formatting.get()).getFormatted());
3746
}
@@ -56,8 +65,12 @@ public static IKey lang(Supplier<TextFormatting> formatting, String lang, Suppli
5665
return IKey.dynamic(() -> lang(lang, argSupplier.get()).style(formatting.get()).getFormatted());
5766
}
5867

68+
public static IKey number(long number) {
69+
return string(TextFormattingUtil.formatNumbers(number));
70+
}
71+
5972
public static IKey number(TextFormatting formatting, long number) {
60-
return string(formatting, TextFormattingUtil.formatNumbers(number));
73+
return number(number).style(formatting);
6174
}
6275

6376
public static IKey number(TextFormatting formatting, long number, String suffix) {

src/main/java/gregtech/common/metatileentities/multi/electric/MetaTileEntityProcessingArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ protected void configureDisplayText(MultiblockUIFactory.Builder builder) {
208208
String key = logic.getMachineStack().getTranslationKey();
209209
IKey mapText = KeyUtil.lang(TextFormatting.DARK_PURPLE,
210210
key + ".name");
211-
mapText = KeyUtil.lang(
211+
mapText = KeyUtil.string(
212212
TextFormatting.DARK_PURPLE,
213213
"%sx %s",
214214
logic.getParallelLimit(), mapText);

0 commit comments

Comments
 (0)