diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-06-26 20:53:14 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-06-26 20:53:14 +0800 |
| commit | 4365c54c8bf9914007db9a17e0d5c2dbeb0a2847 (patch) | |
| tree | 2f53ab30cbdf8406f7b9c6aa77cd3e1d87605638 | |
| parent | 431cfdf77ba306f5e147c7b2d70e15c4b3c729a6 (diff) | |
| download | RoughlyEnoughItems-4365c54c8bf9914007db9a17e0d5c2dbeb0a2847.tar.gz RoughlyEnoughItems-4365c54c8bf9914007db9a17e0d5c2dbeb0a2847.tar.bz2 RoughlyEnoughItems-4365c54c8bf9914007db9a17e0d5c2dbeb0a2847.zip | |
revert the search alg change if it is not ascii
| -rw-r--r-- | src/main/java/me/shedaniel/rei/api/PluginDisabler.java | 4 | ||||
| -rw-r--r-- | src/main/java/me/shedaniel/rei/client/SearchArgument.java | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java b/src/main/java/me/shedaniel/rei/api/PluginDisabler.java index ed4f8638c..231db17ad 100644 --- a/src/main/java/me/shedaniel/rei/api/PluginDisabler.java +++ b/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); diff --git a/src/main/java/me/shedaniel/rei/client/SearchArgument.java b/src/main/java/me/shedaniel/rei/client/SearchArgument.java index cf0a5317c..c71ed8913 100644 --- a/src/main/java/me/shedaniel/rei/client/SearchArgument.java +++ b/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; |
