From de25096a6b77a788f674b7913823fbaa7f6cb976 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Wed, 8 May 2019 19:12:36 -0700 Subject: [PATCH] Fix non-JSON sign text rendering, such as on 1.7.10. Closes #135 src/format.rs Component from_string() attempts JSON deserialization using serde_json::from_str, and if it fails falls back to a literal text string. Call from_string() instead of deserializing in format::Component read_from() and then from_value(). Note the from_string() comment: // Sometimes mojang sends a literal string, so we should interpret it literally --- src/protocol/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 97423ca..ecd3402 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -277,8 +277,7 @@ impl Serializable for format::Component { let len = VarInt::read_from(buf)?.0; let mut ret = String::new(); buf.take(len as u64).read_to_string(&mut ret)?; - let val: serde_json::Value = serde_json::from_str(&ret[..]).unwrap(); - Result::Ok(Self::from_value(&val)) + Result::Ok(Self::from_string(&ret[..])) } fn write_to(&self, buf: &mut W) -> Result<(), Error> { let val = serde_json::to_string(&self.to_value()).unwrap();