Help with saving things to a list

Discussion in 'Plugin Development' started by Jackson12, May 25, 2015.

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

    Jackson12

    Hey, So im trying to make it so when players type /recommend <Staff Name> It will save the staff name that they typed as a list in a yml file. Thanks for any help.
     
  2. Offline

    teej107

  3. Offline

    Jackson12

    Ok. I will give it a try

    This doesnt really help me with my situation, Please give me more info
     
    Last edited by a moderator: May 25, 2015
  4. Offline

    caderape

    @Jackson12 look in the link at 'Setting Values'
     
  5. Offline

    Jackson12

    ok

    Can you provide more help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  6. Offline

    Zombie_Striker

    @Jackson12
    If you're looking to be spoonfed code, don't count on it.

    In order to do this, you would need to :
    • Create an arraylist of ___ (you did not say exactly what you were storing)
    • Use the method in the link to put that arraylist in the config.
    • Use Config()#get(PATH) to then retrieve your arraylist from the config
    • AND REMEMBER THAT AFTER YOU SET ANYTHING IN THE CONFIG ADD saveConfig(); TO SAVE IT. (There are a lot of people who forget this step)
     
  7. Offline

    Jackson12

    This is what i have for my custom yml can you please tell me what i am doing wrong.

    Code:
                    YamlConfiguration RecommendConfig = YamlConfiguration.loadConfiguration(Recommend);
                    RecommendConfig.addDefault("Recommends", "Test");
                   
                    File Recommend;
                    File RecommendFolder;
                    RecommendFolder = new File(getDataFolder(), "Recommends");
                    RecommendFolder.mkdir();
                    Recommend = new File(RecommendFolder, args[1] + ".yml");
                   
                    try {
                        RecommendConfig.save(getDataFolder() + File.separator + "Recommends" + File.separator + args[1] + ".yml");
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    try {
                        Recommend.createNewFile();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
     
  8. Offline

    Zombie_Striker

    @Jackson12
    What are you trying to do? I honestly don't know what you're trying to accomplish with this code.
     
  9. Offline

    Jackson12

    This is the code that im using to create the custom yml
     
  10. Offline

    marknzl

    You mean like a custom named YML file? E.g: users.yml
     
  11. Offline

    Jackson12

    yea, but in my case its recommendations.yml
     
  12. Offline

    marknzl

  13. Offline

    Jackson12

    Ok ill give it a look at

    Can u just help me, because things like that dont really help me, I find them hard to understand, What im wanting to do is create a custom yml file such as Recommendations.yml . After i create that i want to be able to type /recommend <Staff Name> and it will save the Staff Name typed to the recommendations.yml
     
    Last edited by a moderator: May 25, 2015
  14. Offline

    nverdier

    You could use the Config class from EnviousAPI to create multiple configs, link in signature.
     
  15. Offline

    teej107

    unconventional naming :p
     
    nverdier likes this.
  16. You find them hard to understand most likely because you do not understand basic Java, a fact which is apparent from your code. Please learn basic Java before trying to learn how to make plugins, as Bukkit is made in Java, meaning learning it is compulsory. If you do not, you will continue to run into simple problems such as this, and have no idea how to solve them.
     
    BrickBoy55, FisheyLP and nverdier like this.
  17. Offline

    Jackson12

    Ok, I will start learning basic java
     
    nverdier and teej107 like this.
  18. Offline

    nverdier

  19. Nah, he could find good tutorials on youtube, and it is easier to understand.
     
  20. Offline

    nverdier

    Many Youtubers have bad practices which are picked up by their viewers, so it's bad.
     
  21. No it isn't bad, they are starting, yes they can take some 'bad practices' but with some they will end not doing it 'bad practices'.
     
  22. Offline

    Pocketkid2

    I happen to really love this class https://gist.github.com/SagaciousZed/3174347. It does exactly what you want, and you can just copy/paste that code into a class and use it for free out of the box. You just need to make sure you call all the right methods.
     
  23. @MaTaMoR_ It is not ok for beginners to get bad practices, they will then get used to having them and end up not learning good practices. It is always better to teach good practices so the beginner and anyone using the plugin has an efficient plugin. Bad practices lead to bad things such as memory leaks. Please don't teach bad practices.

    @nverdier is right with YouTubers, most do teach bad practice, especially the most popular BcBroz. It is our job as a community to help not make it even worse.

    This is the last I will say, if this starts turning into a flame bait posts will be deleted and points will be given.
     
    CodePlaysMinecraft and nverdier like this.
  24. Offline

    Jackson12

    Ok guys. Thanks for the tutorials they are helping
     
Thread Status:
Not open for further replies.

Share This Page