Make items in your inventory go into config

Discussion in 'Spigot Plugin Help' started by Bailey Crowe, May 20, 2015.

  1. I need some help with my plugin: StarCache
    Currently you have to add items into the config, so it will make different crates fall. Well currently you have to add them into the config, how could i make it so you can just type a command i'll make "/starcache input" and it'll add all the items in your inventory as a new crate
    Config:
    Code (Text):
    general:
    ##################################################
    # Time Between each Star Cache Event. #
    # Expressed in Seconds #
    ##################################################
    eventCooldown: 43200
    ##################################################
    # Radius is caclulated in a square #
    # Values will be +- the defined #
    ##################################################
    world:
    radius: 5000
    ##################################################
    # DO NOT TOUCH #
    ##################################################
    lastEvent: 0
    ##################################################
    # Are we using Factions to determine #
    # safe areas? #
    ##################################################
    useFactions: true
    ##################################################
    # How should we broadcast coordinates? #
    # By CHUNK or EXACT? #
    ##################################################
    announcer:
    method: CHUNK
    caches:
    netherstar:
    - 399%1
    blocks:
    - 57%32
    - 41%32
    - 42%32
    the end where it says "caches:" is where i want to add the command so i can input items into the starcache, i've never worked with something like this in a plugin so some help would be nice!
    If someone is confused on what i mean just message me and i'll try to explain better
    Here is the caches part in my config.class
    Code (Text):
            if (config.contains("caches")) {
                Set<String> caches = config.getConfigurationSection("caches").getKeys(false);
                for (String cache : caches) {
                    System.out.println(cache);
                    List<String> items = config.getStringList("caches." + cache);
                    cacheList.add(new Cache(items));
                }
            }
        }
    So for the netherstar cache it would be caches.netherstar
    So to add my inventory it'll just take my inventory and add a
    caches.[name] then input inventory into the config then i can reload the config
    Also i've been messing with it, how could i add an item with an enchantment? considering 311%1 would be 1 diamond chestplate how could i add an enchantment? i've been searching around and can't get this to work :(
     
    #1 Bailey Crowe, May 20, 2015
    Last edited: May 20, 2015
  2. you will need to use gson and store it in yml