Hey! I'm developing a minigame and I putted all the players in an ArrayList. You know when I restart/reload the server or a player rejoins the ArrayLists will be emtpy again. How do I save it in the config? I'm experienced with coding but not with config files, I don't even know how to make a config file. Can someone help me to save the ArrayLists in the config? And how to create a config file.
Have you even tried to google... Took me a minute... https://www.spigotmc.org/threads/how-to-save-an-arraylist-of-players-to-a-config.51031/ https://bukkit.org/threads/how-to-save-arraylists-using-config-yml.254514/ https://www.spigotmc.org/wiki/creating-a-config-file/
I don't understand anything, I need an explaination. I also have to implent it, not just copy the code and paste it
We are not here to spoonfeed you.. Youtube, Google etc contains tons of tutorials, docs and stuff. Don't be a lazy guy and work for it..
What don't you understand on using youtube, google and those links I provided... We don't talk in a baby language and make posts with over 500 words to explain something. Man up and work for it. Use google, youtube, read those docs. Try it.
I did, but no one explains how to do this: Someone in the server gers putted in an ArrayList. And it gets saved instantly (at least before the server reloads/restarts or the player leaves).
try this: Arraylist<String> stringlist = new arraylist<String>(); And to set it into the conifg: config.set(path, stringlist); To get it: config.getstringlist(path); for creating a config: https://bukkit.org/threads/tutorial-custom-yml-files.259122/
Eehm, maybe do the path as: "Players."+ p.getuniculdid + "List"; you might correct it :d i write it on my phone
Is it okay to create the onDisable function and put it in there? Because if the server reloads/restarts it gets trough the onDisable function
It depends on what you're storing, but not usually a good idea to put them in onDisable() or onEnable().
onEnable to store the players in the ArrayList from the config. onDisable to store the players in the config from the ArrayList
Okay, can someone tell me how to set/save the config like this This is an example! testarraylist: playerone, playertwo, playerthree.
That's an array. a List is saved to config like so: Code (Text): ListName: - player1 - player2 - player3 You can simply use MemorySection#set(String, Object) (object being your List instance) function do do that; Spigot'll take care of the rest. So, as an example, say we have a List of 3 Strings: 'string1', 'string2' and 'string3': Code (Java): List<String> list = Arrays.asList("string1", "string2", "string3"); Now, if we saved this to the config like so: Code (Java): config.set("MyList", list); .. our config would look like this: Code (Text): MyList: - string1 - string2 - string3 Now, we can also add 'paths', and with Yaml, the separator is a dot. Say we want to have a List called 'MyList' located as follows; Code (Text): Examples: Lists: MyList: - string1 - string2 - string3 Now, there are 2 'sections': 'Examples' and 'Lists' inside the Examples -section. Since the sections are separated by a dot, we can save our list right there as follows: Code (Java): config.set("Examples.Lists.MyList", list); Hope this helps :l
You can take a look at the API as a tutorial.... http://bukkit.gamepedia.com/Configuration_API_Reference Please use google, this was the second result...