From cc69d50513fa475c4fa053bf8540ccb66a364d27 Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 29 Jan 2021 19:08:30 +0800 Subject: BugFix: `/kb` or `/kb list` does not filter out unrelated files. --- .../backup/suggestion/BackupNameSuggestionProvider.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/java') 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) s -> s.toLowerCase().endsWith(".zip")) + .or(s -> s.toLowerCase().endsWith(".kbi")) + ).forEach(candidateCacheList::add); cacheUpdateTime = (int) System.currentTimeMillis(); } catch (NullPointerException ignored) { } -- cgit v1.2.3