From df9c1b29f0ca35f97e1c74910f6d0e01c2ca6ccb Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Tue, 23 Apr 2024 20:18:43 -0400 Subject: Refactor usages of Optional's orElseThrow to getOrThrow Mojang's method is more concise and provides far superior error messages incase the value isn't present (like why it happened) whereas with Optionals its just the standard value not present message. --- .../hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/test/java/de/hysky/skyblocker/skyblock/item') diff --git a/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java b/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java index 2709aba4..5c52c3ad 100644 --- a/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java +++ b/src/test/java/de/hysky/skyblocker/skyblock/item/ArmorTrimIdSerializationTest.java @@ -15,7 +15,7 @@ public class ArmorTrimIdSerializationTest { @Test void serialize() { ArmorTrimId armorTrimId = new ArmorTrimId(new Identifier("material_id"), new Identifier("pattern_id")); - JsonElement json = ArmorTrimId.CODEC.encodeStart(JsonOps.INSTANCE, armorTrimId).result().orElseThrow(); + JsonElement json = ArmorTrimId.CODEC.encodeStart(JsonOps.INSTANCE, armorTrimId).getOrThrow(); String expectedJson = "{\"material\":\"minecraft:material_id\",\"pattern\":\"minecraft:pattern_id\"}"; Assertions.assertEquals(expectedJson, json.toString()); @@ -24,7 +24,7 @@ public class ArmorTrimIdSerializationTest { @Test void deserialize() { String json = "{\"material\":\"minecraft:material_id\",\"pattern\":\"minecraft:pattern_id\"}"; - ArmorTrimId armorTrimId = ArmorTrimId.CODEC.parse(JsonOps.INSTANCE, gson.fromJson(json, JsonElement.class)).result().orElseThrow(); + ArmorTrimId armorTrimId = ArmorTrimId.CODEC.parse(JsonOps.INSTANCE, gson.fromJson(json, JsonElement.class)).getOrThrow(); ArmorTrimId expectedArmorTrimId = new ArmorTrimId(new Identifier("material_id"), new Identifier("pattern_id")); Assertions.assertEquals(expectedArmorTrimId, armorTrimId); -- cgit