Пример #1
0
  private void updateTo4(Configuration config) {
    config.setProperty("Config.modes.cluster.enabled", Boolean.valueOf(true));
    config.setProperty("Config.modes.cluster.size", Integer.valueOf(20));

    setVersion(4);
    config.save();
    LightPoles.log("# updated config.yml to VERSION 4", new Object[0]);
    LightPoles.log("# added new mode: CLUSTER", new Object[0]);
  }
Пример #2
0
  private void updateTo8(Configuration config) {
    LightPoles.log("# updated config.yml to VERSION 8", new Object[0]);

    LightPoles.log("# added removeTorchAfterConstruction: false", new Object[0]);
    config.setProperty("Config.modes.power.removeTorchAfterConstruction", Boolean.valueOf(true));

    setVersion(8);
    config.save();
  }
Пример #3
0
  private void updateTo6(Configuration config) {
    String lampList = config.getString("Config.lamplist", "") + "tube;";
    config.setProperty("Config.lamplist", lampList);
    config.setProperty("Lamps.tube.height.min", Integer.valueOf(1));
    config.setProperty("Lamps.tube.height.max", Integer.valueOf(6));
    config.setProperty("Lamps.tube.width.min", Integer.valueOf(2));
    config.setProperty("Lamps.tube.width.max", Integer.valueOf(6));

    setVersion(6);
    config.save();
    LightPoles.log("# updated config.yml to VERSION 6", new Object[0]);
    LightPoles.log("# added new lamp: tube", new Object[0]);
  }
Пример #4
0
  private void updateTo5(Configuration config) {
    String lampList = config.getString("Config.lamplist", "") + "globe;";
    config.setProperty("Config.lamplist", lampList);
    config.setProperty("Lamps.globe.height.min", Integer.valueOf(1));
    config.setProperty("Lamps.globe.height.max", Integer.valueOf(6));
    config.setProperty("Config.disableOnError", Boolean.valueOf(false));

    setVersion(5);
    config.save();
    LightPoles.log("# updated config.yml to VERSION 5", new Object[0]);
    LightPoles.log("# added new lamp: globe", new Object[0]);
    LightPoles.log("# added: disable on error", new Object[0]);
  }
Пример #5
0
  private boolean extractFile(LightPoles plugin, String name) {
    InputStream is = plugin.getClass().getClassLoader().getResourceAsStream(name);
    try {
      File configFile = new File(plugin.getDataFolder(), name);
      if (!configFile.getParentFile().exists()) {
        configFile.getParentFile().mkdirs();
      }

      extractFile(is, configFile);
    } catch (IOException e) {
      LightPoles.log("# could not extract file: " + name, new Object[0]);
      return false;
    }
    LightPoles.log("# extracted file: " + name, new Object[0]);
    return true;
  }
Пример #6
0
  private boolean extractFileFromFolder(LightPoles plugin, String name, String path) {
    InputStream is =
        plugin.getClass().getClassLoader().getResourceAsStream(path + File.separator + name);
    try {
      File folder = new File(plugin.getDataFolder().getPath(), path);
      folder.mkdirs();

      File languageFile = new File(folder, name);

      extractFile(is, languageFile);
    } catch (IOException e) {
      LightPoles.log("# could not extract file: " + name, new Object[0]);
      return false;
    }
    LightPoles.log("# extracted file: " + name, new Object[0]);
    return true;
  }
Пример #7
0
  private void updateTo7(Configuration config, LightPoles plugin) {
    LightPoles.log("# updated config.yml to VERSION 7", new Object[0]);

    LightPoles.log("# removed lamplist", new Object[0]);
    String lamplist = config.getString("Config.lamplist", "");
    config.removeProperty("Config.lamplist");

    LightPoles.log("# added separate switches for each lamp", new Object[0]);
    for (String lamp : LampLoader.lamps) {
      config.setProperty("Lamps." + lamp + ".enabled", Boolean.valueOf(false));
    }
    for (String lamp : lamplist.split(";")) {
      if ((lamp != null) && (!lamp.equals(""))) {
        config.setProperty("Lamps." + lamp + ".enabled", Boolean.valueOf(true));
      }
    }

    LightPoles.log("# added detectRepeater", new Object[0]);
    boolean power = config.getBoolean("Config.modes.power", false);
    config.removeProperty("Config.modes.power");
    config.setProperty("Config.modes.power.enabled", Boolean.valueOf(power));
    config.setProperty("Config.modes.power.detectRepeater", Boolean.valueOf(false));

    LightPoles.log("# moved start/end of day", new Object[0]);
    boolean daytime = config.getBoolean("Config.modes.daytime", false);
    config.removeProperty("Config.modes.daytime");
    int start = config.getInt("Config.daytime.night_start", 12500);
    int end = config.getInt("Config.daytime.night_end", 12500);
    config.removeProperty("Config.daytime.night_start");
    config.removeProperty("Config.daytime.night_end");
    config.removeProperty("Config.daytime");
    config.setProperty("Config.modes.daytime.enabled", Boolean.valueOf(daytime));
    config.setProperty("Config.modes.daytime.night_start", Integer.valueOf(start));
    config.setProperty("Config.modes.daytime.night_end", Integer.valueOf(end));

    LightPoles.log("# added pureBulb", new Object[0]);
    config.setProperty("Config.modes.pureBulb.enabled", Boolean.valueOf(false));

    LightPoles.log("# removed disableOnError", new Object[0]);
    config.removeProperty("Config.disableOnError");

    LightPoles.log("# added controller", new Object[0]);
    config.setProperty("Config.modes.controller.enabled", Boolean.valueOf(true));

    setVersion(7);
    config.save();
  }