From e725da5745c7717ce38139ec6961214e391d6727 Mon Sep 17 00:00:00 2001 From: cwisniew Date: Mon, 2 Oct 2023 20:20:46 +1030 Subject: [PATCH 1/2] apply compat fix for json.path.set and json.path.delete as well --- .../client/functions/json/JSONMacroFunctions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java b/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java index c6d9f30c04..1a3c5a9779 100644 --- a/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/json/JSONMacroFunctions.java @@ -872,7 +872,12 @@ private JsonElement shallowCopy(JsonElement jsonElement) { * @return The resulting json data. */ private JsonElement jsonPathDelete(JsonElement json, String path) { - return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json(); + try { + return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).delete(path).json(); + } catch (PathNotFoundException ex) { + // Return original json, this is to preserve backwards compatability pre library update + return json; + } } /** @@ -906,7 +911,12 @@ private JsonElement jsonPathPut(JsonElement json, String path, String key, Objec private JsonElement jsonPathSet(JsonElement json, String path, Object info) { Object value = asJsonElement(info); - return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json(); + try { + return JsonPath.using(jaywayConfig).parse(shallowCopy(json)).set(path, value).json(); + } catch (PathNotFoundException ex) { + // Return original json, this is to preserve backwards compatability pre library update + return json; + } } /** From 8583bb408a8275a5678d5b4a90cbe408c7f42c05 Mon Sep 17 00:00:00 2001 From: Kenneth VanderLinde Date: Wed, 18 Oct 2023 17:08:34 -0700 Subject: [PATCH 2/2] Disable developer options by default Also store developer options in a separate preference node to keep them separate from regular application preferences. This should make testing and fixups a little easier. --- .../java/net/rptools/maptool/client/DeveloperOptions.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/rptools/maptool/client/DeveloperOptions.java b/src/main/java/net/rptools/maptool/client/DeveloperOptions.java index ec695af7dc..2d97e90d6d 100644 --- a/src/main/java/net/rptools/maptool/client/DeveloperOptions.java +++ b/src/main/java/net/rptools/maptool/client/DeveloperOptions.java @@ -18,13 +18,10 @@ import java.util.List; import java.util.prefs.Preferences; import net.rptools.maptool.language.I18N; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; public class DeveloperOptions { - private static final Logger log = LogManager.getLogger(DeveloperOptions.class); private static final Preferences prefs = - Preferences.userRoot().node(AppConstants.APP_NAME + "/prefs"); + Preferences.userRoot().node(AppConstants.APP_NAME + "/dev"); public enum Toggle { /** @@ -57,7 +54,7 @@ public String getKey() { } public boolean isEnabled() { - return prefs.getBoolean(key, true); + return prefs.getBoolean(key, false); } public void setEnabled(boolean enabled) {