diff --git a/src/main/java/mc/protocol/status/server/StatusServerResponse.java b/src/main/java/mc/protocol/status/server/StatusServerResponse.java index 9d2c513..2c8eac7 100644 --- a/src/main/java/mc/protocol/status/server/StatusServerResponse.java +++ b/src/main/java/mc/protocol/status/server/StatusServerResponse.java @@ -50,6 +50,9 @@ public class StatusServerResponse implements Packet { * "favicon": "data:image/png;base64," * } * + * + *

Следует обратить внимание, что "description" + * может содержать как JSON объект, так и просто Текст

*/ private String serverInfo; diff --git a/src/main/java/mc/protocol/utils/json/serializer/TextDeserializer.java b/src/main/java/mc/protocol/utils/json/serializer/TextDeserializer.java index f46cdef..8eeb51c 100644 --- a/src/main/java/mc/protocol/utils/json/serializer/TextDeserializer.java +++ b/src/main/java/mc/protocol/utils/json/serializer/TextDeserializer.java @@ -27,40 +27,44 @@ public class TextDeserializer extends StdDeserializer { 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)); + } } }