[Help] Saving data on SEPARATE yaml file

Discussion in 'Spigot Plugin Development' started by martin0leung, May 21, 2015.

  1. Basicly, I want to save my arraylist that lets my plugin toggle through stuff, and I want to save my toggles and arraylist on a file called data.yml.

    How my I do that? If you don't know, thanks for looking at this anyways...
     
  2. Use the YamlConfiguration.load() and FileConfiguration.save() methods.
     
  3. How may I do that?
     
  4. Here's a good place to start. Look up what those methods I mentioned do.
     
  5. Sorry, I am kind of new to programming and using javadocs, can you give me a example code for making a new file called data.yml and how to add/retrieve data from it?
     
    • Optimistic Optimistic x 1
  6. The Wiki is self explanatory.

    I like to put it in a separate class to keep things tidy.

    Then in your main class, just add Plugin plugin = this;

    And in your config class, add

    Main plugin;
    <classname>(Main plugin)
    {
    this.plugin = plugin;
    }

    Also in your main, create an object of the class, so you can use it in other classes. I'm not the best teacher, but it's how I do it.
     
  7. Sorry, but I don't really understand what do I do... I now have that Main plugin and this.plugin = plugin; thing, but can you please provide a example of some code for a different yaml file that I can store arraylists and use it for my toggleable things? How to add it and how to retrieve it from that file... Please!
     
  8. You shouldn't be using this API if you are new to Java. We aren't going to spoon feed you.
     
  9. Why not? Bukkit/Spigot API is literally the easiest API there is to learn. Even with no Java experience, you should understand how commands and basic listeners work within a week.
     
    • Agree Agree x 1
  10. Ok, let me take the extra Saturday school class for World History even though I've never studied World History.
     
  11. This is why.
     
  12. You're implying you have to already know what 1+1 equals to learn what 1+1 equals. Nice logic.


    Well I guess everybody isn't as competent.
     
  13. @RW_Craft @Drtro Ok, I read a little bit of them, but I don't see much help in them... I can't use them to do anything or apply them into my code, I understand them now though.
     
  14. If you don't understand then learn the API a bit and don't go straight into projects you know you can't do.
     
  15. @EvenSafe789
    I just kind of know how to make a .yml file, I just need to know how to use it and use it for arraylists.

    Edit: I just need to know how to add arraylists to it and how to get it to my server.
     
  16. You could read this on the wiki.
     
  17. Would you just believe this? I just found there is this site called Google (http://google.co.uk) and I went to it, typed in:
    "how to use other yaml files than config bukkit" and the top link was:
    https://bukkit.org/threads/bukkits-yaml-configuration-tutorial.42770/
    I was flabbergasted! Like o to the m-fing-g, that is exactly what OP needs! I would have never of thought of using a search engine which is designed to search for stuff. What a world we live in where if you have a question you can find someone who has already asked the question and then look at the answers, rather than looking like an idiot and asking the same question that has already been asked.
     
    • Funny Funny x 6
    • Like Like x 1