mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 16:36:58 -04:00
allow asset aliases, throw FileNotFoundException if asset not found (jar asset)
This commit is contained in:
parent
46671aa1bf
commit
dcea6626a3
@ -71,6 +71,13 @@ public class AssetsManager {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static void initAssetsAliases(JsonObject json) {
|
||||
for (String key : json.keySet()) {
|
||||
String value = json.get(key).getAsString();
|
||||
assets.put(key, assets.get(value));
|
||||
}
|
||||
}
|
||||
|
||||
public static void downloadAllAssets(CountUpAndDownLatch latch) throws IOException {
|
||||
if (assets.size() > 0) {
|
||||
return;
|
||||
@ -83,6 +90,8 @@ public class AssetsManager {
|
||||
}
|
||||
assets.putAll(verifyAssets(AssetsSource.MOJANG, latch, parseAssetsIndex(ASSETS_INDEX_HASH)));
|
||||
assets.putAll(verifyAssets(AssetsSource.MINOSOFT_GIT, latch, parseAssetsIndex(Util.readJsonAsset("mapping/resources.json"))));
|
||||
// aliases
|
||||
initAssetsAliases(Util.readJsonAsset("mapping/assetsAliases.json"));
|
||||
latch.addCount(1); // client jar
|
||||
// download assets
|
||||
generateJarAssets();
|
||||
|
@ -203,8 +203,13 @@ public final class Util {
|
||||
return json;
|
||||
}
|
||||
|
||||
public static InputStreamReader readAsset(String path, Class<?> clazz) {
|
||||
return new InputStreamReader(clazz.getResourceAsStream("/assets/" + path));
|
||||
public static InputStreamReader readAsset(String path, Class<?> clazz) throws FileNotFoundException {
|
||||
path = "/assets/" + path;
|
||||
InputStream stream = clazz.getResourceAsStream(path);
|
||||
if (stream == null) {
|
||||
throw new FileNotFoundException(String.format("Could not load asset %s", path));
|
||||
}
|
||||
return new InputStreamReader(stream);
|
||||
}
|
||||
|
||||
public static JsonObject readJsonFromZip(String fileName, ZipFile zipFile) throws IOException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user