display wrong parsed TextComponent exception

This commit is contained in:
Bixilon 2020-12-07 16:30:50 +01:00
parent 19afdf26ef
commit bf238f5ddd
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.data.text; package de.bixilon.minosoft.data.text;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException; import com.google.gson.JsonParseException;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
@ -30,11 +31,13 @@ public abstract class ChatComponent {
if (raw == null) { if (raw == null) {
return new BaseComponent(); return new BaseComponent();
} }
JsonObject json;
try { try {
return new BaseComponent(parent, JsonParser.parseString(raw).getAsJsonObject()); json = JsonParser.parseString(raw).getAsJsonObject();
} catch (JsonParseException | IllegalStateException ignored) { } catch (JsonParseException | IllegalStateException ignored) {
return new BaseComponent(raw);
} }
return new BaseComponent(raw); return new BaseComponent(parent, json);
} }
/** /**