瀏覽代碼

revert the search alg change if it is not ascii

Unknown 6 年之前
父節點
當前提交
ca99703ffa

+ 2 - 2
src/main/java/me/shedaniel/rei/api/PluginDisabler.java

@@ -34,7 +34,7 @@ public interface PluginDisabler {
     /**
      * Disables a function from a plugin
      *
-     * @param plugin    the identifier of the plugin
+     * @param plugin   the identifier of the plugin
      * @param function the function to be disabled
      */
     void disablePluginFunction(Identifier plugin, PluginFunction function);
@@ -42,7 +42,7 @@ public interface PluginDisabler {
     /**
      * Enables a function from a plugin
      *
-     * @param plugin    the identifier of the plugin
+     * @param plugin   the identifier of the plugin
      * @param function the function to be enabled
      */
     void enablePluginFunction(Identifier plugin, PluginFunction function);

+ 7 - 3
src/main/java/me/shedaniel/rei/client/SearchArgument.java

@@ -5,9 +5,10 @@
 
 package me.shedaniel.rei.client;
 
+import com.google.common.base.CharMatcher;
+
 import java.util.Locale;
 import java.util.function.Function;
-import java.util.regex.Pattern;
 
 public class SearchArgument {
     
@@ -17,7 +18,6 @@ public class SearchArgument {
     public final Function<String, Boolean> INCLUDE = s -> search(text, s);
     public final Function<String, Boolean> NOT_INCLUDE = s -> !search(text, s);
     private boolean include;
-    private Pattern pattern;
     
     public SearchArgument(ArgumentType argumentType, String text, boolean include) {
         this(argumentType, text, include, true);
@@ -29,10 +29,14 @@ public class SearchArgument {
         this.include = include;
     }
     
-    public static boolean search(CharSequence pattern, CharSequence text) {
+    public static boolean search(CharSequence pattern, String text) {
         int patternLength = pattern.length();
         if (patternLength == 0)
             return true;
+        if (patternLength > text.length())
+            return false;
+        if (!CharMatcher.ascii().matchesAllOf(text) || !CharMatcher.ascii().matchesAllOf(pattern))
+            return text.contains(pattern);
         int shift[] = new int[256];
         for(int k = 0; k < 256; k++)
             shift[k] = patternLength;