FileConfiguration

Discussion in 'Plugin Development' started by MrPmiguelP, Jul 14, 2012.

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

    MrPmiguelP

    Yesterday I've had help from ferrybig with my SlotWheelEntry and ConfigLoader, but today, I can't get any further again. This time I used the source from minecraft 1.0 again, which looks like this:
    Code:
    public void load() {
        if (!this.file.exists()) {
          ConfigUtils.extract(this.file.getParentFile(), new String[] { this.file.getName() });
        }
     
        Configuration configuration = new Configuration(this.file);
        config.load(file);
     
        ConfigurationSection slotMachine = configuration.getNode("slot_machine");
        this.slot_price = slotMachine.getDouble("price", 45.0D);
        List wheel = slotMachine.getStringList("wheel");
        this.slot_wheel = new SlotWheelEntry[wheel.size()];
        for (int i = 0; i < wheel.size(); i++) {
          String s_material = (String)wheel.get(i);
          Material material = null;
          try {
            material = Material.valueOf(s_material.toUpperCase());
          } catch (Exception exception) {
            material = Material.DIRT;
          }
          this.slot_wheel[i] = new SlotWheelEntry(material, slotMachine.getNode("wheel." + s_material));
        }
    Obviously this source is outdated, so any help on updating this little piece of source? Thanks in advance, Miguel
     
  2. Configuration configuration = new Configuration(this.file);
    >
    FileConfiguration configuration = new YamlConfiguration(this.file);

    ConfigurationSection slotMachine = configuration.getNode("slot_machine");
    >
    ConfigurationSection slotMachine = configuration.getConfigurationSection("slot_machine");

    Code:
    this.slot_wheel[i] = new SlotWheelEntry(material, slotMachine.getNode("wheel." + s_material));
    >
    Code:
    this.slot_wheel[i] = new SlotWheelEntry(material, slotMachine.getConfigurationSection("wheel." + s_material));
    some more chances but not requied (open)

    List wheel = slotMachine.getStringList("wheel");
    >
    List<String> wheel = slotMachine.getStringList("wheel");

    String s_material = (String)wheel.get(i);
    >
    String s_material = wheel.get(i);
     
    Kodfod likes this.
  3. Offline

    MrPmiguelP

    You sir, is a genius. I've put you in the credits.
     
  4. Offline

    Kodfod

    fixed. And Yes that is a great way. +rep for you sir
     
Thread Status:
Not open for further replies.

Share This Page