commit
115dfc0dce
|
@ -48,6 +48,10 @@ public final class AssetIndex {
|
||||||
return virtual || mapToResources;
|
return virtual || mapToResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean needMapToResources() {
|
||||||
|
return mapToResources;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, AssetObject> getObjects() {
|
public Map<String, AssetObject> getObjects() {
|
||||||
return Collections.unmodifiableMap(objects);
|
return Collections.unmodifiableMap(objects);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,7 @@ import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.tungsten.fclcore.download.MaintainTask;
|
import com.tungsten.fclcore.download.MaintainTask;
|
||||||
import com.tungsten.fclcore.download.game.VersionJsonSaveTask;
|
import com.tungsten.fclcore.download.game.VersionJsonSaveTask;
|
||||||
import com.tungsten.fclcore.event.Event;
|
import com.tungsten.fclcore.event.*;
|
||||||
import com.tungsten.fclcore.event.EventBus;
|
|
||||||
import com.tungsten.fclcore.event.GameJsonParseFailedEvent;
|
|
||||||
import com.tungsten.fclcore.event.LoadedOneVersionEvent;
|
|
||||||
import com.tungsten.fclcore.event.RefreshedVersionsEvent;
|
|
||||||
import com.tungsten.fclcore.event.RefreshingVersionsEvent;
|
|
||||||
import com.tungsten.fclcore.event.RemoveVersionEvent;
|
|
||||||
import com.tungsten.fclcore.event.RenameVersionEvent;
|
|
||||||
import com.tungsten.fclcore.game.tlauncher.TLauncherVersion;
|
import com.tungsten.fclcore.game.tlauncher.TLauncherVersion;
|
||||||
import com.tungsten.fclcore.mod.ModManager;
|
import com.tungsten.fclcore.mod.ModManager;
|
||||||
import com.tungsten.fclcore.mod.ModpackConfiguration;
|
import com.tungsten.fclcore.mod.ModpackConfiguration;
|
||||||
|
@ -47,13 +40,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.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
@ -125,9 +112,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -448,6 +438,8 @@ public class DefaultGameRepository implements GameRepository {
|
||||||
return assetsDir;
|
return assetsDir;
|
||||||
|
|
||||||
if (index.isVirtual()) {
|
if (index.isVirtual()) {
|
||||||
|
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();
|
||||||
for (Map.Entry<String, AssetObject> entry : index.getObjects().entrySet()) {
|
for (Map.Entry<String, AssetObject> entry : index.getObjects().entrySet()) {
|
||||||
|
@ -457,6 +449,12 @@ public class DefaultGameRepository implements GameRepository {
|
||||||
cnt++;
|
cnt++;
|
||||||
if (!Files.isRegularFile(target))
|
if (!Files.isRegularFile(target))
|
||||||
FileUtils.copyFile(original, target);
|
FileUtils.copyFile(original, target);
|
||||||
|
|
||||||
|
if (index.needMapToResources()) {
|
||||||
|
target = resourcesDir.resolve(entry.getKey());
|
||||||
|
if (!Files.isRegularFile(target))
|
||||||
|
FileUtils.copyFile(original, target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,18 +487,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…
Reference in New Issue