How do i store temporary data?

Discussion in 'Spigot Plugin Development' started by TheGamerPlayz, Jun 6, 2016.

  1. How would I store data without using a config? I am trying to make a cooldown, but I don't think making an entry in a config is the best way. Anyone have a solution?
     
  2. MetaData
     
  3. You could always make a file called something like 'tempdata' in your plugin's data folder. You could just use regular old Java IO to save your datastructure of temporary data in that file and retrieve it back.
     
  4. You could make a new YML file to save cooldowns
     
  5. How would I store a string in MetaData?

    Edit: I know I could store it in a yml or similar, but this particular class is causing quite a bit of lag
     
  6. You could use a HashMap.
     
  7. I don't think HashMaps would work for this
     
  8. Alright, how exactly are you handling the cooldowns?
     
  9. Config is the best way. That's what they are made for… to store data
     
    #9 Synapz, Jun 6, 2016
    Last edited: Jun 6, 2016
  10. This way:

    entity.setMetadata(new FixedMetadataValue(Main.instance(),"Hello this is a string");
     
  11. entity.setMetadata("key", new FixedMetadataValue(Main.instance(),"Hello this is a string");