diff options
author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-18 18:57:04 -0230 |
---|---|---|
committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-18 18:57:04 -0230 |
commit | 3fad694a65c3647d7ac38bc62c8012891766a373 (patch) | |
tree | e188af2b199124bcb6e17335bc80bbcc9b86e78e /src | |
parent | ccbaac36b14d52f072287775ba55bedb1131beb9 (diff) | |
download | SkyblockHud-Death-Defied-3fad694a65c3647d7ac38bc62c8012891766a373.tar.gz SkyblockHud-Death-Defied-3fad694a65c3647d7ac38bc62c8012891766a373.tar.bz2 SkyblockHud-Death-Defied-3fad694a65c3647d7ac38bc62c8012891766a373.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/com/thatgravyboat/skyblockhud/textures/Textures.java | 9 |
1 files changed, 8 insertions, 1 deletions
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); } } |