From 51d07c1c5050fa715b9adc56e22e169c5b10a72c Mon Sep 17 00:00:00 2001 From: KennyTV Date: Tue, 18 May 2021 09:40:22 +0200 Subject: [PATCH] Print bad component on deserialization fail --- .../chat/TranslatableRewriter1_16.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/chat/TranslatableRewriter1_16.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/chat/TranslatableRewriter1_16.java index 0d12ac10..ef991ec9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/chat/TranslatableRewriter1_16.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_15_2to1_16/chat/TranslatableRewriter1_16.java @@ -17,6 +17,7 @@ */ package com.viaversion.viabackwards.protocol.protocol1_15_2to1_16.chat; +import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter; import com.viaversion.viaversion.libs.gson.JsonElement; @@ -72,12 +73,17 @@ public class TranslatableRewriter1_16 extends TranslatableRewriter { // show_text as chat component // show_entity and show_item serialized as nbt // Let adventure handle all of that - Component component = ChatRewriter.HOVER_GSON_SERIALIZER.deserializeFromTree(object); - JsonObject processedHoverEvent = ((JsonObject) ChatRewriter.HOVER_GSON_SERIALIZER.serializeToTree(component)).getAsJsonObject("hoverEvent"); + try { + Component component = ChatRewriter.HOVER_GSON_SERIALIZER.deserializeFromTree(object); + JsonObject processedHoverEvent = ((JsonObject) ChatRewriter.HOVER_GSON_SERIALIZER.serializeToTree(component)).getAsJsonObject("hoverEvent"); - // Remove new format - processedHoverEvent.remove("contents"); - object.add("hoverEvent", processedHoverEvent); + // Remove new format + processedHoverEvent.remove("contents"); + object.add("hoverEvent", processedHoverEvent); + } catch (Exception e) { + ViaBackwards.getPlatform().getLogger().severe("Error converting hover event component: " + object); + e.printStackTrace(); + } } }