Skip to content

Commit

Permalink
Prevent crash by localizing material (GTNewHorizons#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
miozune authored Aug 18, 2024
1 parent c960e83 commit 9277f4d
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/main/java/gregtech/api/enums/Materials.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.IllegalFormatException;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
Expand Down Expand Up @@ -3230,19 +3231,27 @@ public String toString() {
}

public String getDefaultLocalizedNameForItem(String aFormat) {
return String.format(
aFormat.replace("%s", "%temp")
.replace("%material", "%s"),
this.mDefaultLocalName)
.replace("%temp", "%s");
try {
return String.format(
aFormat.replace("%s", "%temp")
.replace("%material", "%s"),
this.mDefaultLocalName)
.replace("%temp", "%s");
} catch (IllegalFormatException ignored) {
return aFormat;
}
}

public String getLocalizedNameForItem(String aFormat) {
return String.format(
aFormat.replace("%s", "%temp")
.replace("%material", "%s"),
this.mLocalizedName)
.replace("%temp", "%s");
try {
return String.format(
aFormat.replace("%s", "%temp")
.replace("%material", "%s"),
this.mLocalizedName)
.replace("%temp", "%s");
} catch (IllegalFormatException ignored) {
return aFormat;
}
}

public boolean hasCorrespondingFluid() {
Expand Down

0 comments on commit 9277f4d

Please sign in to comment.