소스 검색

fix potion matching for non-english locales Fixes #5174

nossr50 6 일 전
부모
커밋
ce7461f459
3개의 변경된 파일12개의 추가작업 그리고 10개의 파일을 삭제
  1. 3 0
      Changelog.txt
  2. 1 1
      pom.xml
  3. 8 9
      src/main/java/com/gmail/nossr50/util/PotionUtil.java

+ 3 - 0
Changelog.txt

@@ -1,3 +1,6 @@
+Version 2.2.038
+    Fix potion match failing for non-english locales
+
 Version 2.2.037
 Version 2.2.037
     Fixed bug where Alchemy was not matching potions correctly and producing incorrect results (Thanks TheBentoBox)
     Fixed bug where Alchemy was not matching potions correctly and producing incorrect results (Thanks TheBentoBox)
 
 

+ 1 - 1
pom.xml

@@ -2,7 +2,7 @@
     <modelVersion>4.0.0</modelVersion>
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <groupId>com.gmail.nossr50.mcMMO</groupId>
     <artifactId>mcMMO</artifactId>
     <artifactId>mcMMO</artifactId>
-    <version>2.2.037</version>
+    <version>2.2.038-SNAPSHOT</version>
     <name>mcMMO</name>
     <name>mcMMO</name>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <url>https://github.com/mcMMO-Dev/mcMMO</url>
     <scm>
     <scm>

+ 8 - 9
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.InvocationTargetException;
 import java.lang.reflect.Method;
 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 {
 public class PotionUtil {
     // Some of the old potion types got renamed, our configs can still contain these old names
     // 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
      * @return The potion type
      */
      */
     public static PotionType matchPotionType(String partialName, boolean isUpgraded, boolean isExtended) {
     public static PotionType matchPotionType(String partialName, boolean isUpgraded, boolean isExtended) {
-        // updatedName = convertUpgradedOrExtended(updatedName, isUpgraded, isExtended);
         if (COMPATIBILITY_MODE == PotionCompatibilityType.PRE_1_20_5) {
         if (COMPATIBILITY_MODE == PotionCompatibilityType.PRE_1_20_5) {
             return matchLegacyPotionType(partialName);
             return matchLegacyPotionType(partialName);
         } else {
         } else {
-            String updatedName = convertLegacyNames(partialName).toUpperCase();
+            final String updatedName = convertLegacyNames(partialName).toUpperCase(Locale.ENGLISH);
             return Arrays.stream(PotionType.values())
             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);
                     .findAny().orElse(null);
         }
         }
     }
     }