use of betterquesting.api.client.themes.IThemeLoader in project BetterQuesting by Funwayguy.
the class ThemeRegistry method reloadThemes.
@Override
public void reloadThemes() {
resThemes.clear();
IResourceManager resManager = Minecraft.getMinecraft().getResourceManager();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
Iterator<String> iterator = resManager.getResourceDomains().iterator();
while (iterator.hasNext()) {
String domain = iterator.next();
try {
ResourceLocation res = new ResourceLocation(domain, "bq_themes.json");
List<IResource> list = resManager.getAllResources(res);
Iterator<IResource> iterator1 = list.iterator();
while (iterator1.hasNext()) {
IResource iresource = (IResource) iterator1.next();
try {
InputStreamReader isr = new InputStreamReader(iresource.getInputStream());
JsonArray jAry = gson.fromJson(isr, JsonArray.class);
isr.close();
for (JsonElement je : jAry) {
if (je == null || !je.isJsonObject()) {
BetterQuesting.logger.log(Level.WARN, "Invalid theme in " + domain);
continue;
}
JsonObject jThm = je.getAsJsonObject();
ResourceLocation loadID = new ResourceLocation(JsonHelper.GetString(jThm, "themeType", "betterquesting:standard"));
IThemeLoader loader = getLoader(loadID);
if (loader == null) {
continue;
}
ITheme theme = loader.loadTheme(jThm, domain);
if (theme != null) {
resThemes.put(theme.getThemeID(), theme);
}
}
} catch (Exception e) {
BetterQuesting.logger.log(Level.ERROR, "Error reading bq_themes.json from " + domain, e);
}
}
} catch (Exception e) {
}
}
}
Aggregations