public static void set(String categoryName, String propertyName, String newValue) {

    configuration.load();
    if (configuration.getCategoryNames().contains(categoryName)) {
      if (configuration.getCategory(categoryName).containsKey(propertyName)) {
        configuration.getCategory(categoryName).get(propertyName).set(newValue);
      }
    }
    configuration.save();
  }
Exemplo n.º 2
0
 /**
  * Disables metrics for the server by setting "opt-out" to true in the config file and canceling
  * the metrics task.
  *
  * @throws java.io.IOException
  */
 public void disable() throws IOException {
   // Check if the server owner has already set opt-out, if not, set it.
   if (!isOptOut()) {
     configuration.getCategory(Configuration.CATEGORY_GENERAL).get("opt-out").set("true");
     configuration.save();
   }
 }
Exemplo n.º 3
0
 /**
  * Enables metrics for the server by setting "opt-out" to false in the config file and starting
  * the metrics task.
  *
  * @throws java.io.IOException
  */
 public void enable() throws IOException {
   // Check if the server owner has already set opt-out, if not, set it.
   if (isOptOut()) {
     configuration.getCategory(Configuration.CATEGORY_GENERAL).get("opt-out").set("false");
     configuration.save();
   }
   // Enable Task, if it is not running
   if (task == null) {
     start();
   }
 }
Exemplo n.º 4
0
  static void loadConfiguration(Configuration cg) throws RuntimeException {
    String cn =
        new StringBuilder()
            .append(Configuration.CATEGORY_GENERAL)
            .append(Configuration.CATEGORY_SPLITTER)
            .append("PowerSetting")
            .append(Configuration.CATEGORY_SPLITTER)
            .toString();

    String cn2 =
        new StringBuilder()
            .append(cn)
            .append("Quarry")
            .append(Configuration.CATEGORY_SPLITTER)
            .toString();
    ConfigCategory c =
        cg.getCategory(new StringBuilder().append(cn2).append("BreakBlock").toString());
    B_BP = get(c, "BasePower", 40);
    B_CE = get(c, "EfficiencyCoefficient", 1.3);
    B_CU = get(c, "UnbreakingCoefficient", 1);
    B_CF = get(c, "FortuneCoefficient", 1.3);
    B_CS = get(c, "SilktouchCoefficient", 2);
    B_NR = get(c, "BaseMinRecieve", 100);
    B_XR = get(c, "BaseMaxRecieve", 300);
    B_MS = get(c, "BaseMaxStored", 15000);

    c =
        cg.getCategory(
            new StringBuilder()
                .append(cn2)
                .append("BreakBlock")
                .append(Configuration.CATEGORY_SPLITTER)
                .append("MoveHead")
                .toString());
    H_BP = get(c, "BasePower", 200);
    H_CU = get(c, "UnbreakingCoefficient", 1);

    c = cg.getCategory(new StringBuilder().append(cn2).append("MakeFrame").toString());
    F_BP = get(c, "BasePower", 25);
    F_CE = get(c, "EfficiencyCoefficient", 1.3);
    F_CU = get(c, "UnbreakingCoefficient", 1);
    F_NR = get(c, "BaseMinRecieve", 50);
    F_XR = get(c, "BaseMaxRecieve", 100);
    F_MS = get(c, "BaseMaxStored", 15000);

    cn2 =
        new StringBuilder()
            .append(cn)
            .append("Pump")
            .append(Configuration.CATEGORY_SPLITTER)
            .toString();
    c = cg.getCategory(new StringBuilder().append(cn2).append("DrainLiquid").toString());
    PL_BP = get(c, "BasePower", 10);
    PL_CU = get(c, "UnbreakingCoefficient", 1);

    c = cg.getCategory(new StringBuilder().append(cn2).append("MakeFrame").toString());
    PF_BP = get(c, "BasePower", 25);
    PF_CU = get(c, "UnbreakingCoefficient", 1);

    c = cg.getCategory(new StringBuilder().append(cn).append("MiningWell").toString());
    W_BP = get(c, "BasePower", 40);
    W_CE = get(c, "EfficiencyCoefficient", 1.3);
    W_CU = get(c, "UnbreakingCoefficient", 1);
    W_CF = get(c, "FortuneCoefficient", 1.3);
    W_CS = get(c, "SilktouchCoefficient", 2);
    W_NR = get(c, "BaseMinRecieve", 100);
    W_XR = get(c, "BaseMaxRecieve", 100);
    W_MS = get(c, "BaseMaxStored", 1000);

    c = cg.getCategory(new StringBuilder().append(cn).append("Laser").toString());
    L_BP = get(c, "BasePower", 4);
    L_CE = get(c, "EfficiencyCoefficient", 2);
    L_CU = get(c, "UnbreakingCoefficient", 0.1);
    L_CF = get(c, "FortuneCoefficient", 1.05);
    L_CS = get(c, "SilktouchCoefficient", 1.1);
    L_NR = get(c, "BaseMinRecieve", 25);
    L_XR = get(c, "BaseMaxRecieve", 100);
    L_MS = get(c, "BaseMaxStored", 1000);

    c = cg.getCategory(new StringBuilder().append(cn).append("Refinery").toString());
    R_CE = get(c, "EfficiencyCoefficient", 1.3);
    R_CU = get(c, "UnbreakingCoefficient", 1);
    R_NR = get(c, "BaseMinRecieve", 25);
    R_XR = get(c, "BaseMaxRecieve", 100);
    R_MS = get(c, "BaseMaxStored", 1000);

    StringBuilder sb = new StringBuilder();

    if (B_BP < 0) sb.append("general.PowerSetting.Quarry.BreakBlock.BasePower value is bad.\n");
    if (B_CE < 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.EfficiencyCoefficient value is bad.\n");
    if (B_CU < 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.UnbreakingCoefficient value is bad.\n");
    if (B_CF < 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.FortuneCoefficient value is bad.\n");
    if (B_CS < 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.SilktouchCoefficient value is bad.\n");
    if (B_NR < 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.BaseMinRecieve value is bad.\n");
    if (B_XR <= 0 || B_XR < B_NR)
      sb.append("general.PowerSetting.Quarry.BreakBlock.BaseMaxRecieve value is bad.\n");
    if (B_MS <= 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.BaseMaxStored value is bad.\n");

    if (H_BP < 0)
      sb.append("general.PowerSetting.Quarry.BreakBlock.MoveHead.BasePower value is bad.\n");
    if (H_CU < 0)
      sb.append(
          "general.PowerSetting.Quarry.BreakBlock.MoveHead.UnbreakingCoefficient value is bad.\n");

    if (F_BP < 0) sb.append("general.PowerSetting.Quarry.MakeFrame.BasePower value is bad.\n");
    if (F_CE < 0)
      sb.append("general.PowerSetting.Quarry.MakeFrame.EfficiencyCoefficient value is bad.\n");
    if (F_CU < 0)
      sb.append("general.PowerSetting.Quarry.MakeFrame.UnbreakingCoefficient value is bad.\n");
    if (F_NR < 0) sb.append("general.PowerSetting.Quarry.MakeFrame.BaseMinRecieve value is bad.\n");
    if (F_XR <= 0 || F_XR < F_NR)
      sb.append("general.PowerSetting.Quarry.MakeFrame.BaseMaxRecieve value is bad.\n");
    if (F_MS <= 0) sb.append("general.PowerSetting.Quarry.MakeFrame.BaseMaxStored value is bad.\n");

    if (PL_BP < 0) sb.append("general.PowerSetting.Pump.DrainLiquid.BasePower value is bad.\n");
    if (PL_CU < 0)
      sb.append("general.PowerSetting.Pump.DrainLiquid.UnbreakingCoefficient value is bad.\n");

    if (PF_BP < 0) sb.append("general.PowerSetting.Pump.MakeFrame.BasePower value is bad.\n");
    if (PF_CU < 0)
      sb.append("general.PowerSetting.Pump.MakeFrame.UnbreakingCoefficient value is bad.\n");

    if (W_BP < 0) sb.append("general.PowerSetting.MiningWell.BasePower value is bad.\n");
    if (W_CE < 0)
      sb.append("general.PowerSetting.MiningWell.EfficiencyCoefficient value is bad.\n");
    if (W_CU < 0)
      sb.append("general.PowerSetting.MiningWell.UnbreakingCoefficient value is bad.\n");
    if (W_CF < 0) sb.append("general.PowerSetting.MiningWell.FortuneCoefficient value is bad.\n");
    if (W_CS < 0) sb.append("general.PowerSetting.MiningWell.SilktouchCoefficient value is bad.\n");
    if (W_NR < 0) sb.append("general.PowerSetting.MiningWell.BaseMinRecieve value is bad.\n");
    if (W_XR <= 0 || W_XR < W_NR)
      sb.append("general.PowerSetting.MiningWell.BaseMaxRecieve value is bad.\n");
    if (W_MS <= 0) sb.append("general.PowerSetting.MiningWell.BaseMaxStored value is bad.\n");

    if (L_BP < 0) sb.append("general.PowerSetting.Laser.BasePower value is bad.\n");
    if (L_CE < 0) sb.append("general.PowerSetting.Laser.EfficiencyCoefficient value is bad.\n");
    if (L_CU < 0) sb.append("general.PowerSetting.Laser.UnbreakingCoefficient value is bad.\n");
    if (L_CF < 0) sb.append("general.PowerSetting.Laser.FortuneCoefficient value is bad.\n");
    if (L_CS < 0) sb.append("general.PowerSetting.Laser.SilktouchCoefficient value is bad.\n");
    if (L_NR < 0) sb.append("general.PowerSetting.Laser.BaseMinRecieve value is bad.\n");
    if (L_XR <= 0 || W_XR < W_NR)
      sb.append("general.PowerSetting.Laser.BaseMaxRecieve value is bad.\n");
    if (L_MS <= 0) sb.append("general.PowerSetting.Laser.BaseMaxStored value is bad.\n");

    if (R_CE < 0) sb.append("general.PowerSetting.Refinery.EfficiencyCoefficient value is bad.\n");
    if (R_CU < 0) sb.append("general.PowerSetting.Refinery.UnbreakingCoefficient value is bad.\n");
    if (R_NR < 0) sb.append("general.PowerSetting.Refinery.BaseMinRecieve value is bad.\n");
    if (R_XR <= 0 || R_XR < R_NR)
      sb.append("general.PowerSetting.Refinery.BaseMaxRecieve value is bad.\n");
    if (R_MS <= 0) sb.append("general.PowerSetting.Refinery.BaseMaxStored value is bad.\n");

    if (sb.length() != 0) throw new RuntimeException(sb.toString());
  }