diff options
author | Keuin <[email protected]> | 2021-01-29 19:08:30 +0800 |
---|---|---|
committer | keuin <[email protected]> | 2021-01-29 19:08:30 +0800 |
commit | cc69d50513fa475c4fa053bf8540ccb66a364d27 (patch) | |
tree | 6a895fafe959c637d2d6beb887304536b38d69a7 /src/main/java/com/keuin/kbackupfabric/backup/suggestion | |
parent | 602fb9e88685041abac73f868cb697123e15865c (diff) |
BugFix: `/kb` or `/kb list` does not filter out unrelated files.
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/backup/suggestion')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/backup/suggestion/BackupNameSuggestionProvider.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/backup/suggestion/BackupNameSuggestionProvider.java b/src/main/java/com/keuin/kbackupfabric/backup/suggestion/BackupNameSuggestionProvider.java index 72b5c73..9c0c1c2 100644 --- a/src/main/java/com/keuin/kbackupfabric/backup/suggestion/BackupNameSuggestionProvider.java +++ b/src/main/java/com/keuin/kbackupfabric/backup/suggestion/BackupNameSuggestionProvider.java @@ -6,7 +6,9 @@ import net.minecraft.server.command.ServerCommandSource; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.function.Predicate; public class BackupNameSuggestionProvider { @@ -34,8 +36,10 @@ public class BackupNameSuggestionProvider { File[] files = file.listFiles(); if (files == null) return; - for (File f : files) - candidateCacheList.add(f.getName()); + Arrays.stream(files).map(File::getName).filter( + ((Predicate<String>) s -> s.toLowerCase().endsWith(".zip")) + .or(s -> s.toLowerCase().endsWith(".kbi")) + ).forEach(candidateCacheList::add); cacheUpdateTime = (int) System.currentTimeMillis(); } catch (NullPointerException ignored) { } |