mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-04 03:46:57 -04:00
parent
6b78f56298
commit
35ce95857a
@ -33,6 +33,7 @@ import org.jackhuang.hmcl.event.EventBus;
|
|||||||
import org.jackhuang.hmcl.event.EventPriority;
|
import org.jackhuang.hmcl.event.EventPriority;
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
||||||
import org.jackhuang.hmcl.game.GameRepository;
|
import org.jackhuang.hmcl.game.GameRepository;
|
||||||
|
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.SVG;
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
@ -164,9 +165,11 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearAssets() {
|
private void clearAssets() {
|
||||||
File baseDirectory = getProfile().getRepository().getBaseDirectory();
|
HMCLGameRepository baseDirectory = getProfile().getRepository();
|
||||||
FileUtils.deleteDirectoryQuietly(new File(baseDirectory, "assets"));
|
FileUtils.deleteDirectoryQuietly(new File(baseDirectory.getBaseDirectory(), "assets"));
|
||||||
FileUtils.deleteDirectoryQuietly(new File(baseDirectory, "resources"));
|
if (version.get() != null) {
|
||||||
|
FileUtils.deleteDirectoryQuietly(new File(baseDirectory.getRunDirectory(version.get().getVersion()), "resources"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearJunkFiles() {
|
private void clearJunkFiles() {
|
||||||
|
@ -21,14 +21,7 @@ import com.google.gson.JsonParseException;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import org.jackhuang.hmcl.download.MaintainTask;
|
import org.jackhuang.hmcl.download.MaintainTask;
|
||||||
import org.jackhuang.hmcl.download.game.VersionJsonSaveTask;
|
import org.jackhuang.hmcl.download.game.VersionJsonSaveTask;
|
||||||
import org.jackhuang.hmcl.event.Event;
|
import org.jackhuang.hmcl.event.*;
|
||||||
import org.jackhuang.hmcl.event.EventBus;
|
|
||||||
import org.jackhuang.hmcl.event.GameJsonParseFailedEvent;
|
|
||||||
import org.jackhuang.hmcl.event.LoadedOneVersionEvent;
|
|
||||||
import org.jackhuang.hmcl.event.RefreshedVersionsEvent;
|
|
||||||
import org.jackhuang.hmcl.event.RefreshingVersionsEvent;
|
|
||||||
import org.jackhuang.hmcl.event.RemoveVersionEvent;
|
|
||||||
import org.jackhuang.hmcl.event.RenameVersionEvent;
|
|
||||||
import org.jackhuang.hmcl.game.tlauncher.TLauncherVersion;
|
import org.jackhuang.hmcl.game.tlauncher.TLauncherVersion;
|
||||||
import org.jackhuang.hmcl.mod.ModManager;
|
import org.jackhuang.hmcl.mod.ModManager;
|
||||||
import org.jackhuang.hmcl.mod.ModpackConfiguration;
|
import org.jackhuang.hmcl.mod.ModpackConfiguration;
|
||||||
@ -45,13 +38,7 @@ import java.io.IOException;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.InvalidPathException;
|
import java.nio.file.InvalidPathException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -126,9 +113,12 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
@Override
|
@Override
|
||||||
public File getRunDirectory(String id) {
|
public File getRunDirectory(String id) {
|
||||||
switch (getGameDirectoryType(id)) {
|
switch (getGameDirectoryType(id)) {
|
||||||
case VERSION_FOLDER: return getVersionRoot(id);
|
case VERSION_FOLDER:
|
||||||
case ROOT_FOLDER: return getBaseDirectory();
|
return getVersionRoot(id);
|
||||||
default: throw new IllegalStateException();
|
case ROOT_FOLDER:
|
||||||
|
return getBaseDirectory();
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +448,7 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
return assetsDir;
|
return assetsDir;
|
||||||
|
|
||||||
if (index.isVirtual()) {
|
if (index.isVirtual()) {
|
||||||
Path resourcesDir = getBaseDirectory().toPath().resolve("resources");
|
Path resourcesDir = getRunDirectory(version).toPath().resolve("resources");
|
||||||
|
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
int tot = index.getObjects().entrySet().size();
|
int tot = index.getObjects().entrySet().size();
|
||||||
@ -507,18 +497,20 @@ public class DefaultGameRepository implements GameRepository {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* read modpack configuration for a version.
|
* read modpack configuration for a version.
|
||||||
|
*
|
||||||
* @param version version installed as modpack
|
* @param version version installed as modpack
|
||||||
* @param <M> manifest type of ModpackConfiguration
|
* @param <M> manifest type of ModpackConfiguration
|
||||||
* @return modpack configuration object, or null if this version is not a modpack.
|
* @return modpack configuration object, or null if this version is not a modpack.
|
||||||
* @throws VersionNotFoundException if version does not exist.
|
* @throws VersionNotFoundException if version does not exist.
|
||||||
* @throws IOException if an i/o error occurs.
|
* @throws IOException if an i/o error occurs.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public <M> ModpackConfiguration<M> readModpackConfiguration(String version) throws IOException, VersionNotFoundException {
|
public <M> ModpackConfiguration<M> readModpackConfiguration(String version) throws IOException, VersionNotFoundException {
|
||||||
if (!hasVersion(version)) throw new VersionNotFoundException(version);
|
if (!hasVersion(version)) throw new VersionNotFoundException(version);
|
||||||
File file = getModpackConfiguration(version);
|
File file = getModpackConfiguration(version);
|
||||||
if (!file.exists()) return null;
|
if (!file.exists()) return null;
|
||||||
return JsonUtils.GSON.fromJson(FileUtils.readText(file), new TypeToken<ModpackConfiguration<M>>(){}.getType());
|
return JsonUtils.GSON.fromJson(FileUtils.readText(file), new TypeToken<ModpackConfiguration<M>>() {
|
||||||
|
}.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isModpack(String version) {
|
public boolean isModpack(String version) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user