List error

Discussion in 'Plugin Development' started by The_Spaceman, Feb 15, 2017.

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

    The_Spaceman

    I'm making a plugin, and I want to use a list, but when I make one, I can't add new stuff to it.
    I have:

    Code:
        List<String> whitelist = Arrays.asList(player.args[4]);
                                    this.getConfig().set(args[1] + ".whitelist", whitelist);
    the list works just fine

    whitelist:
    - The_Spaceman

    but if I use:
    getConfig().set(args[1] + ".whitelist", getConfig().getStringList(args[1] + ".whitelist").add("test"));

    the List will change to:
    whitelist: true

    what I want is you create a list, and after you can add or deleate things from the list.

    creating the list doesn't have to be in the same part of the code, but the problem is I can't edit it.
     
  2. Offline

    PhantomUnicorns

    I believe that
    Code:
    getConfig().getStringList(args[1] + ".whitelist").add("test")
    
    returns a boolean, not an array you would have to save
    Code:
    getConfig().getStringList(args[1] + ".whitelist")
    
    to a List<String>, and then add it then use the one you saved as the argument where you put it:
    Code:
    LIST<STRING>.add("test")
    
     
    Last edited: Feb 16, 2017
  3. Online

    timtower Administrator Administrator Moderator

    @The_Spaceman Get the list, save it in a variable, add values, set the list in the config.
     
  4. Offline

    The_Spaceman

    what is the code to make a list and save it in a config, and what code do I use to get the string and add a extra thing to it?
     
  5. Online

    timtower Administrator Administrator Moderator

    Won't spoonfeed things that you know already and have used before is slightly changed methods.
     
  6. Offline

    The_Spaceman

    yes, thank you, now I really know what to do...
     
  7. Offline

    PhantomUnicorns

  8. Offline

    MaxFireIce

    @The_Spaceman get the list in the config, set it to a variable, add to the variable, set the variable as the new list in the config.
     
  9. Offline

    The_Spaceman

    the problem is that I don't know how
     
  10. Offline

    Zombie_Striker

    @The_Spaceman
    Which part do you not understand? It has already been posted how to get the list, you already know how to set variables, add variables, and how to set the variable in the config (you already posted these in the main post). What more do you need to know?
     
  11. Offline

    The_Spaceman

    this is the first time using lists, and I know very little about java. but I found a tutorial on YT.
     
  12. Offline

    Zombie_Striker

    @The_Spaceman
    There is your problem. Bukkit was made in Java. You need to know Java first before making plugins. You can't just start making plugins from youtube videos. Please read these this link before you continue making plugins.
    https://sites.google.com/site/tecnowizardplugindevelopment/java/not-ready-for-bukkit

    If you do not have a Java tutorial yet, and what to continue making plugins, please pick a tutorial from the following link. Spend a few weeks to fully understand Java before coming back to bukkit:
    https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
     
  13. Offline

    The_Spaceman


    Great thanks! How I learned Java is if I want to make something in a plugin I code it, but when I'm stuck I go look on the internet for examples of how to do it. It's not that I don't know any Java, it's that I don't know a lot of Java. I know how to use if and else, and how to set up variable's. How to get stuff from a config file and save it in a config file. And that kinda stuff. I'm 16 and I do this in my spare time. But I think the links are gonna help me a lot :D
     
Thread Status:
Not open for further replies.

Share This Page