From 3fad694a65c3647d7ac38bc62c8012891766a373 Mon Sep 17 00:00:00 2001 From: ThatGravyBoat Date: Sun, 18 Jul 2021 18:57:04 -0230 Subject: Added option to change name for default style. Fixed bug where if the texture was removed it wouldn't change the textures and could possibly crash. --- .../java/com/thatgravyboat/skyblockhud/textures/Textures.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/java/com/thatgravyboat/skyblockhud/textures/Textures.java b/src/main/java/com/thatgravyboat/skyblockhud/textures/Textures.java index 871c145..b92a871 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/textures/Textures.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/textures/Textures.java @@ -36,14 +36,21 @@ public class Textures implements IResourceManagerReloadListener { public void onResourceManagerReload(IResourceManager resourceManager) { styles.clear(); styles.add(DEFAULT_TEXTURE); + DEFAULT_TEXTURE.displayName = "Default"; try { ResourceLocation stylesData = new ResourceLocation("skyblockhud:data/styles.json"); InputStream is = resourceManager.getResource(stylesData).getInputStream(); try (BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { - for (JsonElement json : gson.fromJson(reader, JsonObject.class).getAsJsonArray("styles")) { + JsonObject jsonObject = gson.fromJson(reader, JsonObject.class); + for (JsonElement json : jsonObject.getAsJsonArray("styles")) { styles.add(TextureObject.decode((JsonObject) json)); } + if (jsonObject.has("defaultDisplayName") && jsonObject.get("defaultDisplayName").isJsonPrimitive()){ + DEFAULT_TEXTURE.displayName = jsonObject.get("defaultDisplayName").getAsString(); + } } } catch (Exception ignored) {} + + if (SkyblockHud.config != null) setTexture(SkyblockHud.config.misc.style); } } -- cgit