fix: десериализация Text
This commit is contained in:
@@ -50,6 +50,9 @@ public class StatusServerResponse implements Packet {
|
||||
* "favicon": "data:image/png;base64,<data>"
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>Следует обратить внимание, что <code>"description"</code>
|
||||
* может содержать как JSON объект, так и просто Текст</p>
|
||||
*/
|
||||
private String serverInfo;
|
||||
|
||||
|
||||
@@ -27,40 +27,44 @@ public class TextDeserializer extends StdDeserializer<Text> {
|
||||
|
||||
final JsonNode jsonNode = parser.getCodec().readTree(parser);
|
||||
|
||||
Optional.ofNullable(jsonNode.get("text"))
|
||||
.ifPresent(node -> builder.append(node.asText()));
|
||||
Optional.ofNullable(jsonNode.get("color"))
|
||||
.ifPresent(node -> builder.color(TextColor.valueOfColorName(node.asText())));
|
||||
if (jsonNode.isTextual()) {
|
||||
builder.append(jsonNode.asText());
|
||||
} else {
|
||||
Optional.ofNullable(jsonNode.get("text"))
|
||||
.ifPresent(node -> builder.append(node.asText()));
|
||||
Optional.ofNullable(jsonNode.get("color"))
|
||||
.ifPresent(node -> builder.color(TextColor.valueOfColorName(node.asText())));
|
||||
|
||||
if (jsonNode.get("bold") != null && jsonNode.get("bold").isBoolean()
|
||||
&& jsonNode.get("bold").asBoolean()) {
|
||||
builder.style(TextStyle.BOLD);
|
||||
}
|
||||
if (jsonNode.get("bold") != null && jsonNode.get("bold").isBoolean()
|
||||
&& jsonNode.get("bold").asBoolean()) {
|
||||
builder.style(TextStyle.BOLD);
|
||||
}
|
||||
|
||||
if (jsonNode.get("italic") != null && jsonNode.get("italic").isBoolean()
|
||||
&& jsonNode.get("italic").asBoolean()) {
|
||||
builder.style(TextStyle.ITALIC);
|
||||
}
|
||||
if (jsonNode.get("italic") != null && jsonNode.get("italic").isBoolean()
|
||||
&& jsonNode.get("italic").asBoolean()) {
|
||||
builder.style(TextStyle.ITALIC);
|
||||
}
|
||||
|
||||
if (jsonNode.get("obfuscated") != null && jsonNode.get("obfuscated").isBoolean()
|
||||
&& jsonNode.get("obfuscated").asBoolean()) {
|
||||
builder.style(TextStyle.OBFUSCATED);
|
||||
}
|
||||
if (jsonNode.get("obfuscated") != null && jsonNode.get("obfuscated").isBoolean()
|
||||
&& jsonNode.get("obfuscated").asBoolean()) {
|
||||
builder.style(TextStyle.OBFUSCATED);
|
||||
}
|
||||
|
||||
if (jsonNode.get("strikethrough") != null && jsonNode.get("strikethrough").isBoolean()
|
||||
&& jsonNode.get("strikethrough").asBoolean()) {
|
||||
builder.style(TextStyle.STRIKETHOUGH);
|
||||
}
|
||||
if (jsonNode.get("strikethrough") != null && jsonNode.get("strikethrough").isBoolean()
|
||||
&& jsonNode.get("strikethrough").asBoolean()) {
|
||||
builder.style(TextStyle.STRIKETHOUGH);
|
||||
}
|
||||
|
||||
if (jsonNode.get("underlined") != null && jsonNode.get("underlined").isBoolean()
|
||||
&& jsonNode.get("underlined").asBoolean()) {
|
||||
builder.style(TextStyle.UNDERLINE);
|
||||
}
|
||||
if (jsonNode.get("underlined") != null && jsonNode.get("underlined").isBoolean()
|
||||
&& jsonNode.get("underlined").asBoolean()) {
|
||||
builder.style(TextStyle.UNDERLINE);
|
||||
}
|
||||
|
||||
if (jsonNode.get("extra") != null && jsonNode.get("extra").isArray()) {
|
||||
final JsonNode nodeExtra = jsonNode.get("extra");
|
||||
for (JsonNode node : nodeExtra) {
|
||||
builder.append(parser.getCodec().treeToValue(node, Text.class));
|
||||
if (jsonNode.get("extra") != null && jsonNode.get("extra").isArray()) {
|
||||
final JsonNode nodeExtra = jsonNode.get("extra");
|
||||
for (JsonNode node : nodeExtra) {
|
||||
builder.append(parser.getCodec().treeToValue(node, Text.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user