From dde8a927f51e8be23d8b57bc13105e40c3b5511e Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Sat, 23 Dec 2023 20:53:15 +0800 Subject: [PATCH] Remove Legacies --- core/src/cn/harryh/arkpets/Const.java | 4 -- .../harryh/arkpets/assets/AssetItemGroup.java | 10 +-- core/src/cn/harryh/arkpets/utils/Logger.java | 72 ------------------- .../harryh/arkpets/controllers/Homepage.java | 1 - 4 files changed, 3 insertions(+), 84 deletions(-) diff --git a/core/src/cn/harryh/arkpets/Const.java b/core/src/cn/harryh/arkpets/Const.java index 8c62e4bd..75bb2ffd 100644 --- a/core/src/cn/harryh/arkpets/Const.java +++ b/core/src/cn/harryh/arkpets/Const.java @@ -36,9 +36,6 @@ public final class Const { public static final int behaviorBaseWeight = 320; public static final int behaviorWeightLv1 = 32; public static final int behaviorWeightLv2 = 64; - public static final float behaviorMinTimeLv1 = 2.5f; - public static final float behaviorMinTimeLv2 = 5.0f; - public static final float behaviorMinTimeLv3 = 7.5f; public static final float droppedThreshold = 10f; // Duration presets @@ -53,7 +50,6 @@ public final class Const { // Paths of static files and internal files public static final String configExternal = "ArkPetsConfig.json"; public static final String configInternal = "/ArkPetsConfigDefault.json"; - public static final String iconFileIco = "/icons/icon.ico"; public static final String iconFilePng = "/icons/icon.png"; public static final String fontFileRegular = "/fonts/SourceHanSansCN-Regular.otf"; public static final String fontFileBold = "/fonts/SourceHanSansCN-Bold.otf"; diff --git a/core/src/cn/harryh/arkpets/assets/AssetItemGroup.java b/core/src/cn/harryh/arkpets/assets/AssetItemGroup.java index b1dc8c49..5bb469ee 100644 --- a/core/src/cn/harryh/arkpets/assets/AssetItemGroup.java +++ b/core/src/cn/harryh/arkpets/assets/AssetItemGroup.java @@ -5,7 +5,6 @@ import cn.harryh.arkpets.assets.AssetItem.PropertyExtractor; -import java.io.File; import java.util.*; import java.util.function.Predicate; @@ -38,7 +37,7 @@ public AssetItemGroup() { } public AssetItemGroup searchByKeyWords(String keyWords) { - if (keyWords.isEmpty()) + if (keyWords == null || keyWords.isEmpty()) return this; String[] wordList = keyWords.split(" "); AssetItemGroup result = new AssetItemGroup(); @@ -61,11 +60,10 @@ public AssetItemGroup searchByKeyWords(String keyWords) { } public AssetItem searchByRelPath(String relPath) { - if (relPath.isEmpty()) + if (relPath == null || relPath.isEmpty()) return null; - String assetId = new File(relPath).getName(); for (AssetItem asset : this) - if (asset.assetDir.getName().equalsIgnoreCase(assetId)) + if (asset.getLocation().equalsIgnoreCase(relPath)) return asset; return null; } @@ -126,8 +124,6 @@ public void removeDuplicated() { public static class FilterMode { public static final int MATCH_ANY = 0b1; public static final int MATCH_REVERSE = 0b10; - public static final int STRING_IGNORE_CASE = 0b100; - public static final int STRING_PARTIAL = 0b1000; } @Override diff --git a/core/src/cn/harryh/arkpets/utils/Logger.java b/core/src/cn/harryh/arkpets/utils/Logger.java index e38a894d..20af008c 100644 --- a/core/src/cn/harryh/arkpets/utils/Logger.java +++ b/core/src/cn/harryh/arkpets/utils/Logger.java @@ -8,8 +8,6 @@ import org.apache.log4j.varia.LevelRangeFilter; import java.io.*; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -97,10 +95,6 @@ public String getHeader() { }; } - public static String getCurrentLogFilePath() { - return logFilePath; - } - /** Sets a new log level. * @param level The new level. */ @@ -174,51 +168,7 @@ protected static String combine(String tag, String message) { } - public static class RealtimeInspector { - private BufferedReader reader; - private long fileLengthCache; - - public RealtimeInspector(File file) { - initialize(file); - } - - public RealtimeInspector(String filePath) { - initialize(new File(filePath)); - } - - public String[] getNewLines() { - ArrayList newLines = new ArrayList<>(); - if (isAvailable()) { - String line; - try { - while ((line = reader.readLine()) != null) - newLines.add(line); - } catch (IOException ignored) { - } - } - return newLines.toArray(new String[0]); - } - - public boolean isAvailable() { - return reader != null; - } - - private void initialize(File file) { - try { - if (file.exists() && file.canRead()) { - reader = new BufferedReader(new FileReader(file)); - return; - } - } catch (IOException ignored) { - } - reader = null; - } - } - - protected static class Cleaner { - private static final SimpleDateFormat sdf = new SimpleDateFormat(); - public static void cleanByModifiedTime(String logPrefixName, int maxFileCount) { List fileList = getAllLogs(logPrefixName); maxFileCount = Math.max(1, maxFileCount); @@ -242,24 +192,6 @@ private static void deleteButKeep(List fileList, int maxFileCount) { } } - @Deprecated - private static void sortByDateStr(String prefixName, List fileList) { - fileList.sort((o1, o2) -> { - try { - if (getDateStr(prefixName, o1).isEmpty()) - return 1; - if (getDateStr(prefixName, o2).isEmpty()) - return -1; - long t1 = sdf.parse(getDateStr(prefixName, o1)).getTime(); - long t2 = sdf.parse(getDateStr(prefixName, o2)).getTime(); - if (t1 != t2) - return t1 > t2 ? 1 : -1; - } catch (ParseException ignored) { - } - return 0; - }); - } - private static void sortByModifiedTime(List fileList) { if (fileList.isEmpty()) return; @@ -272,10 +204,6 @@ private static void sortByModifiedTime(List fileList) { }); } - private static String getDateStr(String prefixName, File file) { - return file == null ? "" : file.getName().replaceAll(new File(prefixName).getName(), ""); - } - private static List getAllLogs(String logPrefixName) { File file = new File(logPrefixName); File dir = file.getParentFile() == null ? new File(".") : file.getParentFile(); diff --git a/desktop/src/cn/harryh/arkpets/controllers/Homepage.java b/desktop/src/cn/harryh/arkpets/controllers/Homepage.java index 88d6fee0..3293212a 100644 --- a/desktop/src/cn/harryh/arkpets/controllers/Homepage.java +++ b/desktop/src/cn/harryh/arkpets/controllers/Homepage.java @@ -174,7 +174,6 @@ public final class Homepage { private NoticeBar appVersionNotice; private NoticeBar diskFreeSpaceNotice; private NoticeBar datasetIncompatibleNotice; - private Logger.RealtimeInspector inspector = new Logger.RealtimeInspector(Logger.getCurrentLogFilePath()); public Homepage() { }