From ce7461f4596754a029b5468e27c8ace3754422e3 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 26 May 2025 13:05:07 -0700 Subject: [PATCH] fix potion matching for non-english locales Fixes #5174 --- Changelog.txt | 3 +++ pom.xml | 2 +- .../java/com/gmail/nossr50/util/PotionUtil.java | 17 ++++++++--------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 68d362dfd..144a86617 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,6 @@ +Version 2.2.038 + Fix potion match failing for non-english locales + Version 2.2.037 Fixed bug where Alchemy was not matching potions correctly and producing incorrect results (Thanks TheBentoBox) diff --git a/pom.xml b/pom.xml index 4a356a6b7..04bc57fcb 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.2.037 + 2.2.038-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/util/PotionUtil.java b/src/main/java/com/gmail/nossr50/util/PotionUtil.java index 96809637c..6ca19618b 100644 --- a/src/main/java/com/gmail/nossr50/util/PotionUtil.java +++ b/src/main/java/com/gmail/nossr50/util/PotionUtil.java @@ -10,10 +10,7 @@ import org.jetbrains.annotations.Nullable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class PotionUtil { // Some of the old potion types got renamed, our configs can still contain these old names @@ -72,15 +69,17 @@ public class PotionUtil { * @return The potion type */ public static PotionType matchPotionType(String partialName, boolean isUpgraded, boolean isExtended) { - // updatedName = convertUpgradedOrExtended(updatedName, isUpgraded, isExtended); if (COMPATIBILITY_MODE == PotionCompatibilityType.PRE_1_20_5) { return matchLegacyPotionType(partialName); } else { - String updatedName = convertLegacyNames(partialName).toUpperCase(); + final String updatedName = convertLegacyNames(partialName).toUpperCase(Locale.ENGLISH); return Arrays.stream(PotionType.values()) - .filter(potionType -> getKeyGetKey(potionType).toUpperCase().contains(updatedName)) - .filter(potionType -> isUpgraded == potionType.name().toUpperCase().startsWith(STRONG + "_")) - .filter(potionType -> isExtended == potionType.name().toUpperCase().startsWith(LONG + "_")) + .filter(potionType -> getKeyGetKey(potionType) + .toUpperCase(Locale.ENGLISH).contains(updatedName)) + .filter(potionType -> isUpgraded == potionType.name() + .toUpperCase(Locale.ENGLISH).startsWith(STRONG + "_")) + .filter(potionType -> isExtended == potionType.name() + .toUpperCase(Locale.ENGLISH).startsWith(LONG + "_")) .findAny().orElse(null); } }