Future Persistent Entity Serialization

Discussion in 'Spigot Discussion' started by Senmori, Sep 8, 2018.

?

Did you click this poll?

  1. Yes

    62.5%
  2. No

    37.5%
  1. Senmori

    Senmori Retired Resource Staff
    Retired Patron

    I'm here to talk about a proof-of-concept idea I had that I would like to introduce into Spigot.

    ABOUT ME:
    If you know who I am then I feel sorry for you.
    As for everyone else, I am Senmori. I contribute to Spigot pretty regularly. I contribute enough the @md_5 ignores my PRs for the first few days because he knows it annoys me (also because I almost always never get it right on the first commit so I have to push new updates but that doesn't count right?).

    I've contributed many things to Spigot but I am most proud of the LootTable API. LootTables are awesome. Everyone should use them.

    Anyways, let me introduce my idea.

    IDEA:
    The idea is that of persistent entity data. This data would consist of any data Spigot currently allows you to
    save on an entity. I am not talking about direct NBT data manipulation. This system would allow you to, effectively, save custom entity formats such as equipped armor, custom names, attributes, etc. and apply them to any given entity whenever you want.
    This system relies on a current Pull Request that allows developers to create 'virtual' entities. Visit the link for more information on that.

    IMPLEMENTATION:
    I do not know the specifics of how this system would work, but I had a general idea of:
    Create Virtual Entity -> Create serializable data from entity -> save data to file
    Load file -> create entity data from file -> apply data to entity

    Again, this is proof-of-concept so implementation hasn't been decided on yet considering we don't know the scope of what the system should do.

    The idea is you create a loadout, save it to file, and then load the loadout from file and apply it to any entity you want.

    If there is something you would like to be saved, but the current API does not allow you to set it via Spigot then please let us know.

    STORAGE:
    The final goal of this system would allow plugins to easily save entity loadouts to/from file. This would apply to players. This system should also be easily implemented by plugins who wish to integrate permissions.
    Since Spigot would merely transform the data into something YAML compatible, we hope this system would be somewhat version independent.

    As of right now, I do not plan on adding support to automatically serialize all data to file. That would be way too cumbersome and inconsistent. Instead, I will rely on plugins to tell the system what should be serialized. Everything else will be ignored.

    Finally, none of this will be stored server-side. This is important. Mainly because the server is not the place to store plugin-specific configurations, but also because storing arbitrary data on the server is just a bad idea.

    CLOSING:
    So what do I want? I'd like suggestions to a few questions/ideas I had. More ideas and/or suggestions are always welcome. Even if they remove suggested behavior.

    I'd like ideas on what the system should, or should not, do. For example, we are toying with the idea of letting plugins implement their own entity serialization system so they can store whatever data they want. This system also has no name yet so please feel free to suggest some.

    1. What data should the system serialize by default (if any)?
    2. Should plugins be able to save custom data (by means of their own serializer?)
    3. How should it be stored? In a ConfigurationSection? One entity per-file? How to retrieve that data?
    4. Plugins should be able to have their own implementations of this system, is there anything plugins might need that would need to be exposed?
    5. This system would support already existing ConfigurationSerializable objects, are they any other objects that might need support?

    P.S. Enjoy this fanart @MagmaGuy made: https://i.imgur.com/DbqIWc1.png
     
    • Like Like x 1
  2. That is the best fanart I've ever seen.
     
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  3. Weaves

    Resource Staff

    Quick answers because I need to go to bed.
    I like this idea.
    1. Not sure but probably a few things like type or name.
    2. Yes, please.
    3. Per-file with a setable name. Multiple detailed entities would clutter a single file.
    4. Probably, but I don't know right now.
    5. Same as 4.