summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-01-29 19:08:30 +0800
committerkeuin <[email protected]>2021-01-29 19:08:30 +0800
commitcc69d50513fa475c4fa053bf8540ccb66a364d27 (patch)
tree6a895fafe959c637d2d6beb887304536b38d69a7 /src/main
parent602fb9e88685041abac73f868cb697123e15865c (diff)
BugFix: `/kb` or `/kb list` does not filter out unrelated files.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/keuin/kbackupfabric/backup/suggestion/BackupNameSuggestionProvider.java8
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) {
}