@@ -248,15 +248,22 @@ private void updateUglyJson(final CompoundTag componentsTag, final UserConnectio
248248 final String loreKey = TagUtil .getNamespacedTagKey (componentsTag , "lore" );
249249 final ListTag <StringTag > lore = componentsTag .getListTag (loreKey , StringTag .class );
250250 if (lore != null ) {
251- componentsTag .put (loreKey , updateComponentList (connection , lore ));
251+ componentsTag .put (loreKey , updateComponentList (connection , lore , false ));
252252 }
253253 }
254254
255- public ListTag <CompoundTag > updateComponentList (final UserConnection connection , final ListTag <StringTag > messages ) {
255+ public ListTag <CompoundTag > updateComponentList (final UserConnection connection , final ListTag <StringTag > messages , final boolean skipInvalid ) {
256256 final ListTag <CompoundTag > updatedMessages = new ListTag <>(CompoundTag .class );
257257 for (final StringTag message : messages ) {
258258 // Convert and make sure they're all of the same type
259- final Tag output = uglyJsonToTag (connection , message .getValue ());
259+ final Tag output ;
260+ try {
261+ output = skipInvalid ? uglyJsonToTagUncaught (connection , message .getValue ()) : uglyJsonToTag (connection , message .getValue ());
262+ } catch (final Exception e ) {
263+ // Signs ignore invalid data...
264+ continue ;
265+ }
266+
260267 final CompoundTag wrappedComponent = new CompoundTag ();
261268 wrappedComponent .putString ("text" , "" );
262269 wrappedComponent .put ("extra" , new ListTag <>(List .of (output )));
@@ -300,20 +307,22 @@ private void updateShowEntityHover(final UserConnection connection, final Compou
300307 }
301308 }
302309
303- public Tag uglyJsonToTag (final UserConnection connection , final String value ) {
310+ public Tag uglyJsonToTagUncaught (final UserConnection connection , final String value ) {
304311 // Use the same version for deserializing and serializing, as we handle the remaining changes ourselves
305- final Tag contents ;
312+ final Tag contents = SerializerVersion .V1_21_4 .toTag (SerializerVersion .V1_21_4 .toComponent (value ));
313+ processTag (connection , contents );
314+ return contents ;
315+ }
316+
317+ public Tag uglyJsonToTag (final UserConnection connection , final String value ) {
306318 try {
307- contents = SerializerVersion . V1_21_4 . toTag ( SerializerVersion . V1_21_4 . toComponent ( value ) );
319+ return uglyJsonToTagUncaught ( connection , value );
308320 } catch (final Exception e ) {
309321 if (!Via .getConfig ().isSuppressConversionWarnings ()) {
310322 Via .getPlatform ().getLogger ().log (Level .SEVERE , "Error converting json text component: " + value , e );
311323 }
312324 return new StringTag ("<error>" );
313325 }
314-
315- processTag (connection , contents );
316- return contents ;
317326 }
318327
319328 @ Override
0 commit comments