mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 02:20:57 +00:00
more metapack work
This commit is contained in:
@@ -3,9 +3,12 @@ package com.dfsek.terra.config.pack;
|
||||
import ca.solostudios.strata.version.Version;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
@@ -73,14 +76,27 @@ public class MetaPackImpl implements MetaPack {
|
||||
public MetaPackImpl(Path path, Platform platform, ConfigRegistry configRegistry) throws IOException {
|
||||
long start = System.nanoTime();
|
||||
|
||||
this.rootPath = path;
|
||||
this.platform = platform;
|
||||
if(Files.notExists(path)) throw new FileNotFoundException("Could not load metapack, " + path + " does not exist");
|
||||
|
||||
if(Files.isDirectory(path)) {
|
||||
this.rootPath = path;
|
||||
} else if(Files.isRegularFile(path)) {
|
||||
if(!path.getFileName().toString().endsWith(".zip")) {
|
||||
throw new IOException("Could not load metapack, file " + path + " is not a zip");
|
||||
}
|
||||
FileSystem zipfs = FileSystems.newFileSystem(path);
|
||||
this.rootPath = zipfs.getPath("/");
|
||||
} else {
|
||||
throw new IOException("Could not load metapack from " + path);
|
||||
}
|
||||
|
||||
Path packManifestPath = rootPath.resolve("metapack.yml");
|
||||
if(Files.notExists(packManifestPath)) throw new IOException("No metapack.yml found in " + path);
|
||||
Configuration packManifest = new YamlConfiguration(Files.newInputStream(packManifestPath),
|
||||
packManifestPath.getFileName().toString());
|
||||
|
||||
this.platform = platform;
|
||||
|
||||
register(selfLoader);
|
||||
platform.register(selfLoader);
|
||||
|
||||
@@ -101,6 +117,8 @@ public class MetaPackImpl implements MetaPack {
|
||||
|
||||
this.key = RegistryKey.of(namespace, id);
|
||||
|
||||
logger.info("Loading metapack \"{}:{}\"", id, namespace);
|
||||
|
||||
template.getPacks().forEach((k, v) -> {
|
||||
RegistryKey registryKey = RegistryKey.parse(v);
|
||||
if (configRegistry.contains(registryKey)) {
|
||||
@@ -126,7 +144,6 @@ public class MetaPackImpl implements MetaPack {
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
|
||||
return author;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.dfsek.tectonic.api.config.template.annotations.Value;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
public class MetaPackTemplate implements ConfigTemplate {
|
||||
@Value("id")
|
||||
private String id;
|
||||
|
||||
Reference in New Issue
Block a user