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