Checking Config file for certian info on a scheduled task.

Discussion in 'Plugin Development' started by chriztopia, Oct 15, 2012.

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

    chriztopia

    I am looking for some help I want to search thru a config file.

    Code:
    rent:
      region:
        time: 0
        rentable: false
    
    Basicly I want search the yml file for any rentable set as false I will check the time and if everything has expired it will do a task. The Two main problems Is searching thru the config for any rentable being false and pulling the "region" for that rentable.

    rent.region.rentable = false

    So how to pull region and search for false?
     
  2. Offline

    !Phoenix!

    You can make use of ConfigurationSection.getKeys(false), which will return a set containing all names of the sub-entries. Let me try to modify something out of my code a little bit:

    PHP:
    ConfigurationSection yaml config.getConfigurationSection("rent");
    for (
    String regionName yaml.getKeys(false)) {
        
    // May should extend the statement below by something like isBoolean() etc
        
    if (!yaml.getBoolean(regionName ".rentable") && yaml.getInt(regionName ".time") == 0) {
            
    // Do something
        
    }
    }
    Does that help?
     
    chriztopia likes this.
Thread Status:
Not open for further replies.

Share This Page