Restore spaces in string that might be already be shortened (Fixes #558)

This commit is contained in:
Phoenix616 2023-06-21 18:32:47 +01:00
parent 3a1885e2f3
commit 3ef02d05cd
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
1 changed files with 2 additions and 0 deletions

View File

@ -292,6 +292,8 @@ public class MaterialUtil {
* @return The name shortened to the max length * @return The name shortened to the max length
*/ */
public static String getShortenedName(String itemName, int maxWidth) { public static String getShortenedName(String itemName, int maxWidth) {
// Restore spaces in string that might be already be shortened
itemName = itemName.replaceAll("([a-z])([A-Z1-9])", "$1 $2");
itemName = StringUtil.capitalizeFirstLetter(itemName.replace('_', ' '), ' '); itemName = StringUtil.capitalizeFirstLetter(itemName.replace('_', ' '), ' ');
int width = getMinecraftStringWidth(itemName); int width = getMinecraftStringWidth(itemName);
if (width <= maxWidth) { if (width <= maxWidth) {