use of org.lanternpowered.server.asset.json.AssetRepositoryJsonDeserializer in project LanternServer by LanternPowered.
the class LanternModule method provideAssetManager.
@Exposed
@Provides
@Singleton
private LanternAssetManager provideAssetManager(@Option({ "asset-repository-config", "asset-repo-config" }) @Nullable Path repoConfig, LanternPluginManager pluginManager) {
final Gson gson = new GsonBuilder().registerTypeAdapter(AssetRepository.class, new AssetRepositoryJsonDeserializer(pluginManager)).create();
try {
URL url;
if (repoConfig != null) {
url = PathUtils.toURL(repoConfig);
} else {
url = getClass().getClassLoader().getResource("assets_repo.json");
checkNotNull(url);
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
return new LanternAssetManager(gson.fromJson(reader, AssetRepository.class));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
Aggregations