From 2252a5397dff7590120386d0895e443fb5e70036 Mon Sep 17 00:00:00 2001 From: Keir Date: Thu, 24 Dec 2015 21:25:55 +0000 Subject: [PATCH] Fix file filter and reduce it down to 1 line. --- .../mineplex/chatsnap/ChatSnapFileFilter.java | 34 ------------------- .../src/mineplex/chatsnap/PurgeTask.java | 2 +- 2 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/ChatSnapFileFilter.java diff --git a/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/ChatSnapFileFilter.java b/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/ChatSnapFileFilter.java deleted file mode 100644 index b17334ba1..000000000 --- a/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/ChatSnapFileFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -package mineplex.chatsnap; - -import java.io.File; -import java.io.FileFilter; -import java.util.UUID; - -/** - * @author iKeirNez - */ -public class ChatSnapFileFilter implements FileFilter -{ - private static final String FILE_EXTENSION = ".json"; - - @Override - public boolean accept(File file) - { - String fileName = file.getName(); - - if (file.isFile() && fileName.endsWith(FILE_EXTENSION)) - { - String uuid = fileName.substring(0, fileName.length() - FILE_EXTENSION.length()); - - try - { - // this will trigger the catch block if invalid - UUID.fromString(uuid); - return true; - } - catch (IllegalArgumentException e) {} - } - - return false; - } -} diff --git a/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/PurgeTask.java b/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/PurgeTask.java index 1aaf85d5c..200e232a1 100644 --- a/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/PurgeTask.java +++ b/Plugins/Mineplex.ChatSnapManager/src/mineplex/chatsnap/PurgeTask.java @@ -10,7 +10,7 @@ import java.util.logging.Logger; */ public class PurgeTask implements Runnable { - private static final FileFilter FILE_FILTER = new ChatSnapFileFilter(); + private static final FileFilter FILE_FILTER = file -> file.isFile() && file.getName().endsWith(".json"); private final File _dataDir; private final Logger _logger;