Saving ItemStack and UUID restart proof

Discussion in 'Plugin Development' started by Oka, Jul 1, 2019.

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

    Oka

    Hi,

    For one of my plugin I would like to save data when a player hold specifics item, I know how to deal with the event and I was using a map to save who hold what. But I would like the data to be restart proof.

    After some research, I guess my best chance is to use a config file with uuid and itemstack inside, but I have a few questions

    - I guess if I'm changing the config each time a player switch item it would slow down the server a lot as It will need to write on the disk each time, is there a way to just write in the RAM and write on the disk after? (OnDisable for example)

    - Is there another way without using a config file?

    Thank
     
  2. Online

    timtower Administrator Administrator Moderator

    @Oka You can load it for the specific player when they join the server, and save when they leave again.
    There are other ways besides the config file, but that would probably go towards a database which doesn't make it better.
     
  3. Offline

    Oka

    @timtower thank you for the fast answer again, so you mean that if I don't save or load everything is staying in the memory?
     
  4. Online

    timtower Administrator Administrator Moderator

    You do need to load it to load it anyways. Regardless of how you store it. When / how often you do that can be different though.
     
  5. Offline

    Oka

    @timtower If I call load onEnable and save onDisable, is it possible to manipulate data using setConfig() and getConfig() while the server is up?
     
  6. Online

    timtower Administrator Administrator Moderator

    Yes it is. Believe that the config gets loaded to memory.
     
Thread Status:
Not open for further replies.

Share This Page