From aaa7a3536a1c78e171fab51c2bba016aacba9637 Mon Sep 17 00:00:00 2001 From: Intelli Date: Mon, 17 Jun 2024 18:49:43 -0600 Subject: [PATCH] Hide item deserialization errors unless using development branch (fixes #550) --- .../database/statement/EntityStatement.java | 2 +- src/main/java/net/coreprotect/utility/Util.java | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/coreprotect/database/statement/EntityStatement.java b/src/main/java/net/coreprotect/database/statement/EntityStatement.java index a3c91ce2..355e8d57 100644 --- a/src/main/java/net/coreprotect/database/statement/EntityStatement.java +++ b/src/main/java/net/coreprotect/database/statement/EntityStatement.java @@ -65,7 +65,7 @@ public static List getData(Statement statement, BlockState block, String resultSet.close(); } - catch (Exception e) { // only display this exception on development branch + catch (Exception e) { // only display exception on development branch if (!ConfigHandler.EDITION_BRANCH.contains("-dev")) { e.printStackTrace(); } diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index 7014d7d4..27faced9 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -586,9 +586,18 @@ public static byte[] convertByteData(Object data) { return result; } - public static ItemMeta deserializeItemMeta(Class itemMetaClass, Map args) { - DelegateDeserialization delegate = itemMetaClass.getAnnotation(DelegateDeserialization.class); - return (ItemMeta) ConfigurationSerialization.deserializeObject(args, delegate.value()); + public static ItemMeta deserializeItemMetax(Class itemMetaClass, Map args) { + try { + DelegateDeserialization delegate = itemMetaClass.getAnnotation(DelegateDeserialization.class); + return (ItemMeta) ConfigurationSerialization.deserializeObject(args, delegate.value()); + } + catch (Exception e) { // only display exception on development branch + if (!ConfigHandler.EDITION_BRANCH.contains("-dev")) { + e.printStackTrace(); + } + } + + return null; } public static > SortedSet> entriesSortedByValues(Map map) {