@@ -62,6 +62,7 @@ import org.jackhuang.hmcl.util.io.CompressingUtils;
|
|||||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.nio.file.FileSystem;
|
import java.nio.file.FileSystem;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -248,23 +249,30 @@ class ModListPageSkin extends SkinBase<ModListPage> {
|
|||||||
} else {
|
} else {
|
||||||
listView.getItems().clear();
|
listView.getItems().clear();
|
||||||
|
|
||||||
Predicate<String> predicate;
|
Predicate<@Nullable String> predicate;
|
||||||
if (queryString.startsWith("regex:")) {
|
if (queryString.startsWith("regex:")) {
|
||||||
try {
|
try {
|
||||||
Pattern pattern = Pattern.compile(queryString.substring("regex:".length()));
|
Pattern pattern = Pattern.compile(queryString.substring("regex:".length()));
|
||||||
predicate = s -> pattern.matcher(s).find();
|
predicate = s -> s != null && pattern.matcher(s).find();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
LOG.warning("Illegal regular expression", e);
|
LOG.warning("Illegal regular expression", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String lowerQueryString = queryString.toLowerCase(Locale.ROOT);
|
String lowerQueryString = queryString.toLowerCase(Locale.ROOT);
|
||||||
predicate = s -> s.toLowerCase(Locale.ROOT).contains(lowerQueryString);
|
predicate = s -> s != null && s.toLowerCase(Locale.ROOT).contains(lowerQueryString);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we need to search in the background thread?
|
// Do we need to search in the background thread?
|
||||||
for (ModInfoObject item : getSkinnable().getItems()) {
|
for (ModInfoObject item : getSkinnable().getItems()) {
|
||||||
if (predicate.test(item.getModInfo().getFileName())) {
|
LocalModFile modInfo = item.getModInfo();
|
||||||
|
if (predicate.test(modInfo.getFileName())
|
||||||
|
|| predicate.test(modInfo.getName())
|
||||||
|
|| predicate.test(modInfo.getVersion())
|
||||||
|
|| predicate.test(modInfo.getGameVersion())
|
||||||
|
|| predicate.test(modInfo.getId())
|
||||||
|
|| predicate.test(Objects.toString(modInfo.getModLoaderType()))
|
||||||
|
|| predicate.test((item.getMod() != null ? item.getMod().getDisplayName() : null))) {
|
||||||
listView.getItems().add(item);
|
listView.getItems().add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user