Maybe I was accessing hull storage incorrectly? Definitely didn't double check it.
Possibly? I think that's a difficult way to go for this anyway because it's hard (or rather, impossible) to find all possible storage - when one includes the possibility of a mod creating some arbitrary form of it.
I tested WeakHashMap a little more thoroughly than the ID->data map since it was my first idea and I wanted it to work so much, but I just couldn't get any data in it to persist through loading the save. (I did check that it was serializing out the entries into the save.) I wonder if sector memory gets loaded before fleet members, and that breaks the reference long enough for it to get garbage collected? Also entirely possible I wrote it wrong somehow- difficult to check at this point anyway.
Ah, an idea comes to mind - I've seen xstream use the wrong class for a map before if you don't specify the right class in the declaration. For example:
public Map<String,String> map = new LinkedHashMap<>()
If you save and then load, map would end up being a regular HashMap, because there's not enough info in the savefile to tell it was a LinkedHashMap originally. But if you declare it as:
public LinkedHashMap<String,String> map
Then it would deserialize it properly. I wonder if something similar might not be going on for WeakHashMap.
Regardless, I've got a system working at this point- I stringify my data object and store it in the variant tags, and do some screwing around with the variant to ensure it's unique to the ship and that the tag change actually sticks. Not the best system in the world, but if it works for now...
Yeah, in all honesty, that sounds like the best way to go - it's just simpler. I almost did something very similar the other day