Stumped on a command argument code

Discussion in 'Plugin Development' started by ClintonM0, Dec 9, 2012.

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

    ClintonM0

    Code:
    if(args.length == 2 && args[0].equalsIgnoreCase("add")) {
        plugin.getConfig().addDefault("censored", args[1]);
        plugin.saveConfig();
        sender.sendMessage(ChatColor.GREEN + "Censor successfully rigged!");
    }
    It has no error message but it doesn't do anything to the configurations. Anyone help?
     
  2. Offline

    iZanax

  3. Offline

    ClintonM0

    Of course I did. Since there was no error code when I enabled the plugin, the plugin.yml is correct.

    It's something to do with not adding to a list and instead setting a fixed value
     
  4. Offline

    CeramicTitan

    getConfig().options().copyDefaults(true);
    then save the config.
     
  5. Offline

    ClintonM0

    any help?
     
  6. Offline

    Barinade

  7. Offline

    ClintonM0

  8. Offline

    fireblast709

    Its called: get the list, add, set the list, save
    Code:java
    1. List<String> list = getConfig().getStringList("path.to.list");
    2. list.add("Something");
    3. getConfig().set("path.to.list", list);
    4. saveConfig();
     
Thread Status:
Not open for further replies.

Share This Page