Пример #1
0
 private static void setData(String path, Object data) {
   try {
     Orebfuscator.instance.getConfig().set(path, data);
     save();
   } catch (Exception e) {
     Orebfuscator.log(e);
   }
 }
Пример #2
0
  public static void load() {
    // Version check
    int version = getInt("ConfigVersion", CONFIG_VERSION);
    if (version < CONFIG_VERSION) {
      /*
      Orebfuscator.log("Configuration out of date. Recreating new configuration file.");
      File configFile = new File(Orebfuscator.instance.getDataFolder(), "config.yml");
      File destination = new File(Orebfuscator.instance.getDataFolder(), "config_old.yml");
      if (destination.exists())
      {
          try
          {
              destination.delete();
          }
          catch (Exception e)
          {
              Orebfuscator.log(e);
          }
      }
      configFile.renameTo(destination);
      reload();
      */
      ObfuscatedDataCache.ClearCache();
      setData("ConfigVersion", CONFIG_VERSION);
    }

    EngineMode = getInt("Integers.EngineMode", EngineMode);
    if (EngineMode != 1 && EngineMode != 2) {
      EngineMode = 2;
      System.out.println("[Orebfuscator] EngineMode must be 1 or 2.");
    }
    UpdateRadius = getInt("Integers.UpdateRadius", UpdateRadius);
    InitialRadius = getInt("Integers.InitialRadius", InitialRadius);
    if (InitialRadius > 5) {
      InitialRadius = 5;
      System.out.println("[Orebfuscator] InitialRadius must be less than 6.");
    }
    if (InitialRadius == 0) {
      System.out.println(
          "[Orebfuscator] Warning, InitialRadius is 0. This will cause all exposed blocks to be obfuscated.");
    }
    ProcessingThreads = getInt("Integers.ProcessingThreads", ProcessingThreads);
    MaxLoadedCacheFiles = getInt("Integers.MaxLoadedCacheFiles", MaxLoadedCacheFiles);
    ProximityHiderDistance = getInt("Integers.ProximityHiderDistance", ProximityHiderDistance);
    ProximityHiderID = getInt("Integers.ProximityHiderID", ProximityHiderID);
    ProximityHiderEnd = getInt("Integers.ProximityHiderEnd", ProximityHiderEnd);
    AirGeneratorMaxChance = getInt("Integers.AirGeneratorMaxChance", AirGeneratorMaxChance);
    OrebfuscatorPriority = getInt("Integers.OrebfuscatorPriority", OrebfuscatorPriority);
    UseProximityHider = getBoolean("Booleans.UseProximityHider", UseProximityHider);
    UseSpecialBlockForProximityHider =
        getBoolean("Booleans.UseSpecialBlockForProximityHider", UseSpecialBlockForProximityHider);
    UpdateOnDamage = getBoolean("Booleans.UpdateOnDamage", UpdateOnDamage);
    DarknessHideBlocks = getBoolean("Booleans.DarknessHideBlocks", DarknessHideBlocks);
    NoObfuscationForOps = getBoolean("Booleans.NoObfuscationForOps", NoObfuscationForOps);
    NoObfuscationForPermission =
        getBoolean("Booleans.NoObfuscationForPermission", NoObfuscationForPermission);
    UseCache = getBoolean("Booleans.UseCache", UseCache);
    LoginNotification = getBoolean("Booleans.LoginNotification", LoginNotification);
    AntiTexturePackAndFreecam =
        getBoolean("Booleans.AntiTexturePackAndFreecam", AntiTexturePackAndFreecam);
    Enabled = getBoolean("Booleans.Enabled", Enabled);
    setBlockValues(
        ObfuscateBlocks,
        getIntList(
            "Lists.ObfuscateBlocks",
            Arrays.asList(new Integer[] {14, 15, 16, 21, 54, 56, 73, 74, 129})));
    setBlockValues(
        ProximityHiderBlocks,
        getIntList(
            "Lists.ProximityHiderBlocks",
            Arrays.asList(new Integer[] {23, 54, 56, 58, 61, 62, 116, 129})));
    DisabledWorlds = getStringList("Lists.DisabledWorlds", DisabledWorlds);
    CacheLocation = getString("Strings.CacheLocation", CacheLocation);
    CacheFolder = new File(CacheLocation);

    RandomBlocks = getIntList2("Lists.RandomBlocks", Arrays.asList(RandomBlocks));

    // Validate RandomBlocks
    for (int i = 0; i < RandomBlocks.length; i++) {
      // Don't want people to put chests and other stuff that lags the hell out of players.
      if (OrebfuscatorConfig.isBlockTransparent((short) (int) RandomBlocks[i])) {
        RandomBlocks[i] = 0;
      }
    }
    RandomBlocks2 = RandomBlocks;

    save();
  }