From 1ca41f88d7729d9279df71cd186ff86f22e7d515 Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Fri, 6 May 2022 16:13:36 +0200 Subject: Item Shop Recipes (#118) * first draft of item shop PR * add teleporter navigation because i can * fix teleporter navigation because apparently i cant * navigation gui basics * :pushpin: and removed some unused shit and added myself to devtest command * track / untrack + ery texture Co-Authored-By: RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> * consoom the event * fix crash in ItemShopRecipe.java + fetch repository * i am so sorry jani * on second thought, this entire thing was a bit untested * more recipe stuff * make navigation actually good * make pins dissapear if you not a waypoint * npc parsing * save file * different file saving * remove message * Warping... (to deez nuts) * move shit around Co-authored-by: jani270 Co-authored-by: RayDeeUx <51521765+RayDeeUx@users.noreply.github.com> Co-authored-by: Lulonaut --- .../moulberry/notenoughupdates/util/JsonUtils.java | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/JsonUtils.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/JsonUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/JsonUtils.java index 916631b7..b4193c88 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/JsonUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/JsonUtils.java @@ -5,7 +5,9 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -16,11 +18,18 @@ public class JsonUtils { return StreamSupport.stream(array.spliterator(), false); } - public static List transformJsonArrayToList(JsonArray array, Function mapper) { + public static List transformJsonArrayToList( + JsonArray array, + Function mapper + ) { return getJsonArrayAsStream(array).map(mapper).collect(Collectors.toList()); } - public static List getJsonArrayOrEmpty(JsonObject rootObject, String name, Function mapper) { + public static List getJsonArrayOrEmpty( + JsonObject rootObject, + String name, + Function mapper + ) { if (!rootObject.has(name)) { return Collections.emptyList(); } @@ -31,7 +40,10 @@ public class JsonUtils { return Collections.emptyList(); } - public static JsonArray transformListToJsonArray(List things, Function mapper) { + public static JsonArray transformListToJsonArray( + List things, + Function mapper + ) { JsonArray array = new JsonArray(); for (T t : things) { array.add(mapper.apply(t)); @@ -39,4 +51,15 @@ public class JsonUtils { return array; } + public static Map transformJsonObjectToMap( + JsonObject object, + Function mapper + ) { + Map map = new HashMap<>(); + for (Map.Entry entry : object.entrySet()) { + map.put(entry.getKey(), mapper.apply(entry.getValue())); + } + return map; + } + } -- cgit