* 修复生成option.txt与YOSBR模组的冲突

* only search 1 layer
This commit is contained in:
Chikage0o0
2022-09-02 11:36:58 +08:00
committed by GitHub
parent 058a8e2335
commit 837939e27c

View File

@@ -59,8 +59,13 @@ public final class HMCLGameLauncher extends DefaultLauncher {
private void generateOptionsTxt() { private void generateOptionsTxt() {
File optionsFile = new File(repository.getRunDirectory(version.getId()), "options.txt"); File optionsFile = new File(repository.getRunDirectory(version.getId()), "options.txt");
File configFolder = new File(repository.getRunDirectory(version.getId()), "config");
if (optionsFile.exists()) if (optionsFile.exists())
return; return;
if (configFolder.isDirectory())
if (findFiles(configFolder, "options.txt"))
return;
try { try {
// TODO: Dirty implementation here // TODO: Dirty implementation here
if (I18n.getCurrentLocale().getLocale() == Locale.CHINA) if (I18n.getCurrentLocale().getLocale() == Locale.CHINA)
@@ -70,6 +75,20 @@ public final class HMCLGameLauncher extends DefaultLauncher {
} }
} }
private boolean findFiles(File folder, String fileName) {
File[] fs = folder.listFiles();
if (fs != null) {
for (File f : fs) {
if (f.isDirectory())
if (f.listFiles((dir, name) -> name.equals(fileName)) != null)
return true;
if (f.getName().equals(fileName))
return true;
}
}
return false;
}
@Override @Override
public ManagedProcess launch() throws IOException, InterruptedException { public ManagedProcess launch() throws IOException, InterruptedException {
generateOptionsTxt(); generateOptionsTxt();