Skip to content

Commit

Permalink
Remove Legacies
Browse files Browse the repository at this point in the history
  • Loading branch information
isHarryh committed Dec 23, 2023
1 parent abc4743 commit dde8a92
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 84 deletions.
4 changes: 0 additions & 4 deletions core/src/cn/harryh/arkpets/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
Expand Down
10 changes: 3 additions & 7 deletions core/src/cn/harryh/arkpets/assets/AssetItemGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import cn.harryh.arkpets.assets.AssetItem.PropertyExtractor;

import java.io.File;
import java.util.*;
import java.util.function.Predicate;

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
72 changes: 0 additions & 72 deletions core/src/cn/harryh/arkpets/utils/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -97,10 +95,6 @@ public String getHeader() {
};
}

public static String getCurrentLogFilePath() {
return logFilePath;
}

/** Sets a new log level.
* @param level The new level.
*/
Expand Down Expand Up @@ -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<String> 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<File> fileList = getAllLogs(logPrefixName);
maxFileCount = Math.max(1, maxFileCount);
Expand All @@ -242,24 +192,6 @@ private static void deleteButKeep(List<File> fileList, int maxFileCount) {
}
}

@Deprecated
private static void sortByDateStr(String prefixName, List<File> 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<File> fileList) {
if (fileList.isEmpty())
return;
Expand All @@ -272,10 +204,6 @@ private static void sortByModifiedTime(List<File> fileList) {
});
}

private static String getDateStr(String prefixName, File file) {
return file == null ? "" : file.getName().replaceAll(new File(prefixName).getName(), "");
}

private static List<File> getAllLogs(String logPrefixName) {
File file = new File(logPrefixName);
File dir = file.getParentFile() == null ? new File(".") : file.getParentFile();
Expand Down
1 change: 0 additions & 1 deletion desktop/src/cn/harryh/arkpets/controllers/Homepage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand Down

0 comments on commit dde8a92

Please sign in to comment.