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
This commit is contained in:
ice_iix 2019-05-08 19:12:36 -07:00
parent 06cab07ae6
commit de25096a6b
1 changed files with 1 additions and 2 deletions

View File

@ -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<W: io::Write>(&self, buf: &mut W) -> Result<(), Error> {
let val = serde_json::to_string(&self.to_value()).unwrap();