Add item to config & remove item from config

Discussion in 'Plugin Development' started by davidp027, Oct 26, 2014.

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

    davidp027

    I've been looking on forums and I can't find something, I have no idea how to delete an item as I see no functions for it, and when I try to add another item, it always replace the first one I'm using craftbukkit 1.6.4 . Here's my code.

    Code:
    if(!args[0].equals("")){
        if(args[0].matches("(\\d{1,})[:{1}](\\d{1,})")){
            String string = args[0];
            String[] parts = string.split(":");
            Integer part1 = Integer.valueOf(parts[0]); 
            Integer part2 = Integer.valueOf(parts[1]); 
            String igitems = "IgnoredItems";
            getConfig().set(igitems + ".itemid", args[0]);
            saveConfig();
            sender.sendMessage(prefix + ChatColor.GREEN + "Added " + ChatColor.GOLD + args[0] +          ChatColor.GREEN + " to ignore list.");
        } else {
          sender.sendMessage(prefix + ChatColor.RED + "Invalid Paramaters. Remeber to add " +                ChatColor.GOLD + ":0 " + ChatColor.RED + "if it's a normal ID. Example: " + ChatColor.GOLD + "/addignore 2:0 " + ChatColor.RED +"for a grass block.");
     
    }
     
  2. Offline

    TheCodingCat

    just set the configuration section where you keep the item stacks to null then save it
     
  3. Offline

    Hellgast

    To remove a node in the config, set it to null.
    Code:
    getConfig().set("your-path",null);
     
  4. Offline

    davidp027

    Got it for the remove, but still can't figure out how to add more than one item with the addignore command, keeps editing the first one without adding any new one
     
  5. Offline

    TheCodingCat

    do
    config.set("item.1",item1)
    config.set("item.2",item2)
    config.set("item.3",item3)
     
Thread Status:
Not open for further replies.

Share This Page