Fix serialization

Fix the serialization code in https://github.com/Bukkit/Bukkit/pull/1077