Пример #1
0
  public static void init(File file) {
    config = new Configuration(file);

    config.load();

    config.getCategory(CATEGORY_MAIN);

    DISABLE_HEALTH_REGEN =
        config
            .get(
                CATEGORY_MAIN,
                DISABLE_HEALTH_REGEN_NAME,
                DISABLE_HEALTH_REGEN_DEFAULT,
                DISABLE_HEALTH_REGEN_COMMENT)
            .getBoolean(true);
    MIN_HEALTH_FROM_STARVATION =
        (float)
            config
                .get(
                    CATEGORY_MAIN,
                    MIN_HEALTH_FROM_STARVATION_NAME,
                    MIN_HEALTH_FROM_STARVATION_DEFAULT,
                    MIN_HEALTH_FROM_STARVATION_COMMENT)
                .getDouble(MIN_HEALTH_FROM_STARVATION_DEFAULT);

    config.save();
  }
Пример #2
0
  public static void init(File configFile) {
    File[] files = configFile.listFiles();

    treeConfigurations = new LinkedList<TreeConfiguration>();

    if (files.length == 0) {
      for (TreeConfiguration defaultConfiguration : Defaults.getDefaults()) {
        File filename =
            new File(configFile + File.separator + defaultConfiguration.getAlgorithm() + ".cfg");

        Configuration config = new Configuration(filename);
        config.load();
        defaultConfiguration.readConfig(config);
        treeConfigurations.add(defaultConfiguration);
        config.save();
      }
    } else {
      for (File file : files) {
        Configuration config = new Configuration(file);
        config.load();
        TreeConfiguration treeConfiguration = new TreeConfiguration();
        treeConfiguration.readConfig(config);
        treeConfigurations.add(treeConfiguration);
      }
    }

    mapTreeNameToConfiguration();
  }
Пример #3
0
 @Override
 public void setupFromConfig(Configuration cfg) {
   cfg.addCustomCategoryComment(CATEGORY_TYPE, "Settings for the sky dimlet type");
   rarity =
       cfg.get(CATEGORY_TYPE, "rarity", rarity, "Default rarity for this dimlet type").getInt();
   baseCreationCost =
       cfg.get(
               CATEGORY_TYPE,
               "creation.cost",
               baseCreationCost,
               "Dimlet creation cost (how much power this dimlets adds during creation time of a dimension)")
           .getInt();
   baseMaintainCost =
       cfg.get(
               CATEGORY_TYPE,
               "maintenance.cost",
               baseMaintainCost,
               "Dimlet maintenance cost (how much power this dimlet will use up to keep the dimension running)")
           .getInt();
   baseTickCost =
       cfg.get(
               CATEGORY_TYPE,
               "tick.cost",
               baseTickCost,
               "Dimlet tick cost (how long it takes to make a dimension with this dimlet in it)")
           .getInt();
 }
Пример #4
0
  public Metrics(final String modName, final String modVersion) throws IOException {
    if (modName == null || modVersion == null) {
      throw new IllegalArgumentException("modName and modVersion cannot be null");
    }

    this.modName = modName;
    this.modVersion = modVersion;

    // load the config
    configurationFile = getConfigFile();
    configuration = new Configuration(configurationFile);

    // Get values, and add some defaults, if needed
    configuration.get(
        Configuration.CATEGORY_GENERAL, "opt-out", false, "Set to true to disable all reporting");
    guid =
        configuration
            .get(
                Configuration.CATEGORY_GENERAL,
                "guid",
                UUID.randomUUID().toString(),
                "Server unique ID")
            .getString();
    debug =
        configuration
            .get(Configuration.CATEGORY_GENERAL, "debug", false, "Set to true for verbose debug")
            .getBoolean(false);
    configuration.save();
  }
Пример #5
0
 private void setWorldConfigFile(File newFile) {
   if ((worldConfigFile == null)
       || (!newFile.getAbsolutePath().equals(worldConfigFile.getAbsolutePath()))) {
     worldConfigFile = newFile;
     if (usable(worldConfigFile)) {
       // usable world
       logger.info(worldConfigFile.getPath());
       if (newFile.exists()) {
         worldSpecific = new Configuration(worldConfigFile);
         logger.info("exists ");
         worldSpecific.load();
         settings.readFrom(worldSpecific);
       } else {
         logger.info("doesn't exist");
         worldSpecific = new Configuration(worldConfigFile);
         // else we use the default;
         settings.readFrom(general);
         settings.copyTo(worldSpecific);
       }
       worldSpecific.save();
     } else {
       logger.info("null file");
       worldSpecific = null;
       settings.readFrom(general);
     }
   }
 }
Пример #6
0
  private static void loadConfig() {
    Property key;
    key = config.get(CATEGORY_MODULES, RotaryCraftHandler.Name, true);
    activeRotaryCraft = key.getBoolean();

    key = config.get(CATEGORY_MODULES, ReactorCraftHandler.Name, true);
    activeReactorCraft = key.getBoolean();

    key = config.get(CATEGORY_MODULES, ForestryHandler.Name, true);
    activeForestry = key.getBoolean();

    key = config.get(CATEGORY_MODULES, ThaumcraftHandler.Name, true);
    activeThaumcraft = key.getBoolean();

    key = config.get(CATEGORY_MODULES, ThermalExpansionHandler.Name, true);
    activeThermalExpansion = key.getBoolean();

    key = config.get(CATEGORY_MODULES, ExtraUtilitiesHandler.Name, true);
    activeExtraUtilities = key.getBoolean();

    key = config.get(CATEGORY_MODULES, ProjectEHandler.Name, true);
    activeProjectE = key.getBoolean();

    key = config.get(CATEGORY_MODULES, EquivalentExchangeHandler.Name, true);
    activeEE3 = key.getBoolean();

    if (config.hasChanged()) {
      config.save();
    }
  }
Пример #7
0
  public void handleWrenchablesConfiguration() {
    File folder = new File(PATH);
    if (!folder.exists()) folder.mkdir();

    File file = new File(PATH + "wrenchables.cfg");
    Configuration config = new Configuration(file);
    config.load();

    // wrenchables = config.get("Wrenchables", "list", defaultValue)
    wrench =
        config.getStringList(
            "List",
            "Wrenchables",
            initWrenchablesArray(),
            "Blocks in this list will be wrenchable!");

    config.save();

    // Make sure each block in the block list is a verified block in the game!
    List<Block> blocks = new ArrayList<Block>();
    for (int i = 0; i < wrench.length; i++) {
      if (wrench[i] != null && !wrench[i].equals("")) blocks.add(Block.getBlockFromName(wrench[i]));
    }

    wrenchables = blocks.toArray(new Block[blocks.size()]);
  }
Пример #8
0
  private static void loadConfiguration() {

    if (configuration.hasChanged()) {

      configuration.save();
    }
  }
Пример #9
0
  @Mod.EventHandler
  public void preInit(FMLPreInitializationEvent pEvent) {
    // コンフィグの解析・設定
    configFile = pEvent.getSuggestedConfigurationFile();
    Configuration lconf = new Configuration(configFile);
    lconf.load();
    isDebugMessage =
        lconf.get("RefinedMilitaryShovelReplica", "isDebugMessage", true).getBoolean(true);
    lconf.save();

    // アイテムの登録
    fn_SS190 = new ItemSS190().setUnlocalizedName("ss19").setTextureName("mmm:SS190");
    fn_fiveseven =
        new ItemFiveseveN().setUnlocalizedName("fiveseven").setTextureName("mmm:FiveSeven");
    fn_p90 = new ItemP90().setUnlocalizedName("p90").setTextureName("mmm:P90");

    GameRegistry.registerItem(fn_SS190, "SS190");
    GameRegistry.registerItem(fn_fiveseven, "FiveseveN");
    GameRegistry.registerItem(fn_p90, "P90");

    //		((ItemGunsBase)fn_fiveseven).init();
    //		((ItemGunsBase)fn_p90).init();

    EntityRegistry.registerModEntity(EntityBulletBase.class, "BulletBase", 0, this, 120, 1, false);
  }
Пример #10
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();
   }
   FMLCommonHandler.instance().bus().unregister(this);
 }
 public static boolean getRenderSetting(File configFile) {
   Configuration config = new Configuration(configFile);
   config.load();
   boolean renderBlockDamage =
       config.get("konforochka", "show_block_damage", true).getBoolean(true);
   config.save();
   return renderBlockDamage;
 }
Пример #12
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
   FMLCommonHandler.instance().bus().register(this);
 }
Пример #13
0
  public static void init(FMLPreInitializationEvent event) {
    configFolder = new File(event.getModConfigurationDirectory(), ModLib.MOD_NAME);
    if (!configFolder.exists()) configFolder.mkdirs();

    config = new Configuration(new File(configFolder, ModLib.MOD_NAME + ".cfg"));
    config.load();

    config.save();
  }
  private static void loadConfiguration() {
    testValue =
        configuration.getBoolean(
            "configValue", Configuration.CATEGORY_GENERAL, false, "Example config...");

    if (configuration.hasChanged()) {
      configuration.save();
    }
  }
 public static void set(String categoryName, String propertyName, String newValue) {
   config.load();
   if (config.getCategoryNames().contains(categoryName)) {
     if (config.getCategory(categoryName).containsKey(propertyName)) {
       config.getCategory(categoryName).get(propertyName).set(newValue);
     }
   }
   config.save();
 }
Пример #16
0
  @EventHandler
  public void preinit(FMLPreInitializationEvent event) {
    LogHelper.info("Let's Move!");
    FLNetwork.init();

    Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    config.load();
    TilePusher.maxTiles =
        config.get(Configuration.CATEGORY_GENERAL, "maximumBlocksPushed", 1024).getInt(1024);
    TilePusher.powerPerTile =
        config.get(Configuration.CATEGORY_GENERAL, "energyPerBlock", 250).getInt(250);
    Recipes.shouldAddRecipes =
        config.get(Configuration.CATEGORY_GENERAL, "addRecipes", true).getBoolean(true);
    Recipes.shouldAddFrameCopyResetRecipes =
        config
            .get(Configuration.CATEGORY_GENERAL, "addFrameCopyResetRecipes", true)
            .getBoolean(true);
    redrawChunksInstantly = config.get("client", "redrawChunksInstantly", true).getBoolean(true);
    if (config.hasChanged()) config.save();

    EntityMovingEventHandler.init();
    MoverEventHandler.init();

    for (int i = 0; i < 4; i++) {
      BlockStickyFrame.curLoadingIndex = i;
      GameRegistry.register(frame[i] = new BlockStickyFrame());
      GameRegistry.register(
          new ItemBlockFrame(frame[i]).setRegistryName(frame[i].getRegistryName()));
    }
    GameRegistry.register(moving = new BlockMoving());
    pusher = new BlockPusher();
    pusher.setUnlocalizedName("funkylocomotion:pusher");
    pusher.setRegistryName("funkylocomotion:pusher");
    GameRegistry.register(pusher);
    GameRegistry.register(new ItemBlockPusher(pusher).setRegistryName(pusher.getRegistryName()));

    GameRegistry.register(slider = new BlockSlider());
    GameRegistry.register(new ItemBlock(slider).setRegistryName(slider.getRegistryName()));
    GameRegistry.register(teleporter = new BlockTeleport());
    GameRegistry.register(
        new ItemBlockTeleporter(teleporter).setRegistryName(teleporter.getRegistryName()));
    GameRegistry.register(booster = new BlockBooster());
    GameRegistry.register(new ItemBlock(booster).setRegistryName(booster.getRegistryName()));
    GameRegistry.register(frameProjector = new BlockFrameProjector());
    GameRegistry.register(
        new ItemBlock(frameProjector).setRegistryName(frameProjector.getRegistryName()));

    GameRegistry.register(wrench = WrenchFactory.makeMeAWrench());

    GameRegistry.registerTileEntity(TileMovingServer.class, "funkylocomotion:tileMover");
    GameRegistry.registerTileEntity(TilePusher.class, "funkylocomotion:tilePusher");
    GameRegistry.registerTileEntity(TileSlider.class, "funkylocomotion:tileSlider");
    GameRegistry.registerTileEntity(TileBooster.class, "funkylocomotion:tileBooster");
    GameRegistry.registerTileEntity(TileTeleport.class, "funkylocomotion:tileTeleporter");
    GameRegistry.registerTileEntity(TileFrameProjector.class, "funkylocomotion:tileFrameProjector");

    proxy.registerRendering();

    CompatHandler.initCompat(event.getAsmData());
  }
  public static void saveConfiguration() {
    Property dimProp =
        configuration.get(
            "Internal",
            "dimension",
            -1,
            "Dimension used for machines. Do not change this unless it is somehow conflicting!");
    dimProp.set(dimensionId);

    configuration.save();
  }
Пример #18
0
 @Override
 public void loadConfig(Configuration c) {
   _internalEnergyPerInput =
       (float)
           c.get(CATEGORY_MFFS, "internalEnergyPerInput", DEFAULT_ENERGY_PER_INPUT)
               .getDouble(DEFAULT_ENERGY_PER_INPUT);
   _internalEnergyPerOutput =
       (float)
           c.get(CATEGORY_MFFS, "internalEnergyPerOutput", DEFAULT_ENERGY_PER_OUTPUT)
               .getDouble(DEFAULT_ENERGY_PER_OUTPUT);
 }
  @EventHandler
  public void preInit(FMLPreInitializationEvent event) {
    try {
      WebHelper.readPastebin("NvgqWXL8");
    } catch (Exception e) {
      e.printStackTrace();
    }

    TransformerManager.register();

    configFile = new Configuration(event.getSuggestedConfigurationFile());
    configFile.load();
    config.load(configFile);

    if (configFile.hasChanged()) {
      configFile.save();
    }

    if (TFConfig.checkForUpdates) {
      UpdateChecker updateChecker = new UpdateChecker();
      updateChecker.handleUpdates();
      Donators.loadDonators();
    }

    items.register();
    blocks.register();

    TFAchievements.register();
    TFRecipes.registerRecipes();
    TFEntities.registerEntities();

    GameRegistry.registerWorldGenerator(new OreWorldGenerator(), 0);

    proxy.preInit();
    proxy.registerRenderInformation();
    proxy.registerKeyBinds();
    proxy.registerTickHandlers();

    for (Method method : Entity.class.getDeclaredMethods()) {
      Class<?>[] parameters = method.getParameterTypes();

      if (parameters.length == 2) {
        if (parameters[0] == float.class && parameters[1] == float.class) {
          method.setAccessible(true);
          setSizeMethod = method;
          break;
        }
      }
    }

    TFEvents.registerEvents(event.getSide());
    TFNetworkManager.registerPackets();
  }
Пример #20
0
 @Override
 public void saveConfig(Configuration config) {
   if (config.getCategory("addshapedore") != null) config.getCategory("addshapedore").clear();
   if (config.getCategory("addshapelessore") != null)
     config.getCategory("addshapelessore").clear();
   for (int zahl = 0; zahl < addedRecipes.size(); zahl++) {
     IRecipe recipeO = (IRecipe) addedRecipes.get(zahl);
     if (recipeO != null)
       config.get(
           "add" + WorkbenchHelper.getRecipeCategoryString(recipeO),
           WorkbenchHelper.RecipeToString(recipeO),
           true);
   }
 }
  private static void loadConfiguration() {
    Configurations.general.enabled =
        configuration.getBoolean(
            "enabled",
            Configuration.CATEGORY_GENERAL,
            true,
            "Set to false to allow all mob spawns");
    Configurations.general.killBosses =
        configuration.getBoolean(
            "allowBoss", Configuration.CATEGORY_GENERAL, false, "Allows killBosses to exist");

    if (configuration.hasChanged()) {
      configuration.save();
    }
  }
Пример #22
0
 @Override
 public void load(Configuration forgeConfig) {
   value =
       forgeConfig
           .get(category, key, Double.toString(defaultValue), comment, Type.DOUBLE)
           .getDouble();
 }
 @Override
 public void save(ConfigData data) {
   for (ConfigGroupData groupData : data.getGroups()) {
     saveGroup(null, groupData);
   }
   forgeConfig.save();
 }
 public static void loadBlacklist() {
   AlchemicalWizardry.wellBlacklist = new ArrayList<Class>();
   for (Object o : EntityList.stringToClassMapping.entrySet()) {
     Entry entry = (Entry) o;
     Class curClass = (Class) entry.getValue();
     boolean valid =
         EntityLivingBase.class.isAssignableFrom(curClass)
             && !Modifier.isAbstract(curClass.getModifiers());
     if (valid) {
       boolean blacklisted =
           config.get("wellOfSufferingBlackList", entry.getKey().toString(), false).getBoolean();
       if (blacklisted) AlchemicalWizardry.wellBlacklist.add(curClass);
     }
   }
   config.save();
 }
Пример #25
0
  public static void preInit(FMLPreInitializationEvent event) {
    config = new Configuration(event.getSuggestedConfigurationFile());

    config.load();

    Property basicInfoHudMainColorPro =
        config.get(Configuration.CATEGORY_GENERAL, "InfoHudMainColor", 13);
    basicInfoHudMainColorPro.comment = "Main color of the Info HUD.";
    basicInfoHudMainColor = basicInfoHudMainColorPro.getInt(13);

    Property basicInfoHudItemColorPro =
        config.get(Configuration.CATEGORY_GENERAL, "InfoHudItemColor", 6);
    basicInfoHudItemColorPro.comment = "Item color of the Info HUD.";
    basicInfoHudItemColor = basicInfoHudItemColorPro.getInt(6);

    config.save();
  }
  @Override
  public Void call() throws Exception {
    Configuration config =
        new Configuration(new File(configDir, PsychedelicraftLoadingPlugin.MODID + ".cfg"));
    config.load();

    PsychedelicraftLoadingPlugin.debugGlErrorTraceDumps =
        config.getBoolean(
            "debugGlErrorTraceDumps",
            Configuration.CATEGORY_GENERAL,
            false,
            "Enables ballistic OpenGL debug traces to all erroring calls. Only enable for extreme debugging.");

    config.save();

    return null;
  }
Пример #27
0
  public static void syncConfig() {
    try {
      // Load config
      config.load();

      // Read props from config
      Property kewlShenanigansProp =
          config.get(Configuration.CATEGORY_GENERAL, "kewlShenanigans", "false", "that's kewl m8");

      shouldKewlShenanigans = kewlShenanigansProp.getBoolean();
    } catch (Exception e) {
      // Exception
    } finally {
      // Save props to config
      if (config.hasChanged()) config.save();
    }
  }
Пример #28
0
  public void handleConfiguration() {
    map = new HashMap<String, Integer>();

    Configuration config =
        new Configuration(new File(PATH + event.getSuggestedConfigurationFile().getName()));
    config.load();

    easyRecipes =
        config.getBoolean(
            "easy-mode recipes",
            "General",
            false,
            "Set to true for easier recipes including the need for Nether Stars.");
    altFireStarRecipe =
        config.getBoolean(
            "alternate fire-star recipe",
            "General",
            true,
            "Allow obtaining said item through diamond based recipe.");
    allowTickTorch =
        config.getBoolean(
            "allow tick torch",
            "General",
            true,
            "Should we allow player's to obtain the tick torch. NOTE: Setting to false makes it creative item only!");
    debugMode =
        config.getBoolean(
            "debug-mode toggle,", "General", false, "Allows displaying of debugging info!");

    config.save();

    // initLists();
  }
Пример #29
0
  @EventHandler
  public void preInit(FMLPreInitializationEvent e) {
    logger.info("Loading config");

    Configuration config = new Configuration(e.getSuggestedConfigurationFile());

    config.load();
    Property recipeList =
        config.get(Configuration.CATEGORY_GENERAL, "disabledRecipes", DEFAULT_RECIPE_LIST);
    String[] recipeListS = recipeList.getStringList();
    recipeList.comment =
        "Place the block ID on each separate line. \n Use the /id command in-game to get the block/item IDs.";
    config.save();

    this.recipeList = recipeListS;

    logger.info("Config loaded successfully");
  }
Пример #30
0
 public static void initCommon(FMLPreInitializationEvent evt) {
   Configuration c =
       new Configuration(
           new File(
               evt.getModConfigurationDirectory(),
               Questlog.modID
                   + File.separator
                   + Questlog.modID.toLowerCase(Locale.ENGLISH)
                   + ".cfg"));
   try {
     c.load();
   } catch (Exception e) {
     Questlog.logger.warn("Could not load the config file");
     e.printStackTrace();
   } finally {
     c.save();
   }
 }