Hello, I'm currently developing a mini-games plugin for a server, and I'm questioning how I should be storing information. At the moment, I need to store locations, blocks, and integers; all data for Arenas that players can play in. What I had in mind was looping through all keys (arenas + key + node) during startup, pulling the information, and storing it in an 'Arena' class's variables for each arena instead of constantly seeking the config for information. So my question is which is better, storing in a class or pulling from a config file?
Considering that storing in a class would be storing in RAM afaik, the data would be wiped when the program terminates.
You'll only need config if you want to save information after restarting & reloads, or whenever the match is reset.
Store in config what you need to persist between reloads/restarts. When you load a config file it loads the entire contents into memory anyway AFAIK.
That's not really a problem considering I'll be reloading that data into memory when the server starts from the config. That's what I had in mind, I was just wondering if the difference between pulling from a config or the bloat of using class variables would make any difference.
You just need to save data from the yml file into a class when the plugin enables, do operations to that data, not the data in the file, then write the cache into the yml when your plugin disables.
I never really used YAML before, but JSON quite nice as well, especially while using Google' GSON library. Even though the library has some limitations, it's generally really nice, and extremely easy to work with.