Custom NBT Loading/Saving

Discussion in 'Plugin Development' started by krazytraynz, Jun 22, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    krazytraynz

    How would I load/save custom Entity NBT data that will persist through server reloads/restarts? Anything I've seen with custom NBT data so far has involved ItemStacks.
     
  2. Offline

    krazytraynz

  3. Offline

    krazytraynz

  4. Offline

    xTrollxDudex

    krazytraynz
    Is this even possible? I would personally persist it on my side then load it into the entity after the reload/restart but there is probably a different way I'm not seeing.
     
  5. Offline

    krazytraynz

    I don't know if it's possible, I was just wondering if it was. Your way would work though, I don't know why I could only come up with the most complicated way to do this :p
     
  6. Offline

    TheRedHun1

    Could be technically possible. Get the entities position and info and store it seperate. When server restarts remove all the entities and when it starts back up, read off the positions and info and respawn them back. To the player, it looks like the same entity. They wont know.
     
  7. Offline

    krazytraynz

    That would work, but with what I'm planning to do with this, eventually reading/writing all of the information I need could end up being too resource heavy.
     
  8. krazytraynz How many entities are we talking about?
     
  9. Offline

    krazytraynz

    Depends on the amount of players on the server.
     
  10. Offline

    unrealdesign

    The best thing to do would be save into a MySQL database and then load it like others have said. It would not be resource heavy unless it was 100's or something entities.
     
  11. Offline

    krazytraynz

    unrealdesign

    I would do this, but the plugin would end up constantly pulling data from the database. I'm gonna need to use these values in almost everything (AI, commands, listeners, etc.).
     
  12. Offline

    unrealdesign

    No. You would only have to add/remove/get from the database once you are reloading/starting/stoping.

    You would only save to the your MySQL database when one of those three things happens. So you save all of your stuff in you List/Set, or how ever you save them. Then once the server reloads, you save all the information and then load it again on plugin start. If the plugin starts, you load all the information. And if the plugin stops you save all the information. You might also want to have a save method that runs every so often so that if the server crashes or unexpectedly stops, you won't lose your changes.
     
  13. Offline

    krazytraynz

    unrealdesign
    Oh, I get what you're saying now :p I still don't know about using MySQL though, because like I said earlier the overhead for large amounts of entities can be problematic.
     
  14. Offline

    TheRedHun1

    You don't really even need MySQL for this, if your entities are just boosted strength as such then all you need is their location. If it has something important like ownership, then you can just serialize it with the location information. Storing a string for each entity can be done in a config file easily and storing over 1,000s of entities will be fine. And when I mean storing, you are not storing constantly and pulling the information. You are saving and writing when the serer stops or starts reloading and then loading it back on start up. No players should feel the lag if there is any because there will be no players on during this time. Players will just log off looking at these entities and log back to see some entities that look exactly the same and they wouldn't know the difference.

    If large entities seems a problem to you even after all this, then you need MySQL or load them up in waves of like 100 or so at a time by adding a pause or wait upon start up but it shouldn't really matter on start up because no one is on anyways.
     
Thread Status:
Not open for further replies.

Share This Page