Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7804

Written book serialization broken since Spigot 1.20.5

XMLWordPrintable

    • This server is running CraftBukkit version dev-Spigot-0a642bd-aac911d (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
    • Yes

      Issues:

      • Pages are not serialized as json strings, but the IChatBaseComponents are outputted directly, which does not serialize the actual page data and results in an error during deserialization.
        "pages: - !!net.minecraft.network.chat.IChatMutableComponent {}"
      • For the "resolved" and "generation" properties, the deserialization does not properly handle null / missing values during deserialization (tries to cast null to Generation or bool), instead of using false / Generation.ORIGINAL instead.

      Example plugin code to reproduce the issue(s):

      @Override
      	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
      		try {
      			Player player = (Player) sender;
      
      			ItemStack item = new ItemStack(Material.WRITTEN_BOOK);
      			BookMeta meta = (BookMeta)item.getItemMeta();
      			meta.addPage("Test");
      			item.setItemMeta(meta);
      
      			YamlConfiguration config = new YamlConfiguration();
      			config.set("item", item);
      			String serialized = config.saveToString();
      			player.sendMessage("Serialized: " + serialized);
      
      			config.loadFromString(serialized);
      			ItemStack deserialized = config.getItemStack("item");
      			player.sendMessage("Deserialized: " + config.saveToString());
      
      			player.sendMessage("Deserialized equals original? " + item.isSimilar(deserialized));
      		} catch (Exception e) {
      			sender.sendMessage("Command execution failed: " + e.getMessage());
      			Test.INSTANCE.getLogger().log(Level.SEVERE, "Command execution failed!", e);
      		}
      		return true;
      	}
      

       

            blablubbabc blablubbabc
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: