|
62 | 62 | import org.jackhuang.hmcl.util.io.FileUtils; |
63 | 63 | import org.jackhuang.hmcl.util.io.NetworkUtils; |
64 | 64 | import org.jetbrains.annotations.NotNull; |
| 65 | +import org.jetbrains.annotations.Nullable; |
65 | 66 |
|
66 | 67 | import java.nio.file.FileSystem; |
67 | 68 | import java.nio.file.Files; |
@@ -248,23 +249,30 @@ private void search() { |
248 | 249 | } else { |
249 | 250 | listView.getItems().clear(); |
250 | 251 |
|
251 | | - Predicate<String> predicate; |
| 252 | + Predicate<@Nullable String> predicate; |
252 | 253 | if (queryString.startsWith("regex:")) { |
253 | 254 | try { |
254 | 255 | Pattern pattern = Pattern.compile(queryString.substring("regex:".length())); |
255 | | - predicate = s -> pattern.matcher(s).find(); |
| 256 | + predicate = s -> s != null && pattern.matcher(s).find(); |
256 | 257 | } catch (Throwable e) { |
257 | 258 | LOG.warning("Illegal regular expression", e); |
258 | 259 | return; |
259 | 260 | } |
260 | 261 | } else { |
261 | 262 | String lowerQueryString = queryString.toLowerCase(Locale.ROOT); |
262 | | - predicate = s -> s.toLowerCase(Locale.ROOT).contains(lowerQueryString); |
| 263 | + predicate = s -> s != null && s.toLowerCase(Locale.ROOT).contains(lowerQueryString); |
263 | 264 | } |
264 | 265 |
|
265 | 266 | // Do we need to search in the background thread? |
266 | 267 | for (ModInfoObject item : getSkinnable().getItems()) { |
267 | | - if (predicate.test(item.getModInfo().getFileName())) { |
| 268 | + LocalModFile modInfo = item.getModInfo(); |
| 269 | + if (predicate.test(modInfo.getFileName()) |
| 270 | + || predicate.test(modInfo.getName()) |
| 271 | + || predicate.test(modInfo.getVersion()) |
| 272 | + || predicate.test(modInfo.getGameVersion()) |
| 273 | + || predicate.test(modInfo.getId()) |
| 274 | + || predicate.test(Objects.toString(modInfo.getModLoaderType())) |
| 275 | + || predicate.test((item.getMod() != null ? item.getMod().getDisplayName() : null))) { |
268 | 276 | listView.getItems().add(item); |
269 | 277 | } |
270 | 278 | } |
|
0 commit comments