net.minecraftforge.common.config.Configuration Java Examples

The following examples show how to use net.minecraftforge.common.config.Configuration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public ForgeMetrics(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();
}
 
Example #2
Source File: ConfigManager.java    From GardenCollection with MIT License 6 votes vote down vote up
public ConfigManager (File file) {
    config = new Configuration(file);

    Property propEnableCompostBonemeal = config.get(Configuration.CATEGORY_GENERAL, "enableCompostBonemeal", true);
    propEnableCompostBonemeal.comment = "Allows compost trigger plant growth like bonemeal.";
    enableCompostBonemeal = propEnableCompostBonemeal.getBoolean();

    Property propCompostBonemealStrength = config.get(Configuration.CATEGORY_GENERAL, "compostBonemealStrength", 0.5);
    propCompostBonemealStrength.comment = "The probability that compost will succeed when used as bonemeal relative to bonemeal.";
    compostBonemealStrength = propCompostBonemealStrength.getDouble();

    Property propEnableTilledSoilGrowthBonus = config.get(Configuration.CATEGORY_GENERAL, "enableTilledSoilGrowthBonus", true).setRequiresMcRestart(true);
    propEnableTilledSoilGrowthBonus.comment = "Allows tilled garden soil to advance crop growth more quickly.  Enables random ticks.";
    enableTilledSoilGrowthBonus = propEnableTilledSoilGrowthBonus.getBoolean();

    config.save();
}
 
Example #3
Source File: BackpacksConfig.java    From WearableBackpacks with MIT License 6 votes vote down vote up
public void save() {
	// Our settings are very deliberately sorted, so group our settings by
	// category and set the property order to how we have ordered the fields.
	// This is also why we use LinkedHashMap: Keeps elements in insertion order.
	Map<String, List<Setting<?>>> byCategory = getSettings().stream().collect(
		Collectors.groupingBy(setting -> setting.getCategory(), LinkedHashMap::new, Collectors.toList()));
	for (Map.Entry<String, List<Setting<?>>> entry : byCategory.entrySet()) {
		String category = entry.getKey();
		if (category.equals(Configuration.CATEGORY_GENERAL)) continue;
		List<String> order = entry.getValue().stream().map(Setting::getName).collect(Collectors.toList());
		_config.setCategoryPropertyOrder(category, order);
	}
	// Unfortunately ordering is not possible for categories in the config file itself.
	
	// Remove old config properties.
	_config.getCategory(Configuration.CATEGORY_GENERAL).remove("enableHelpTooltips");
	
	getSettings().forEach(setting -> setting.saveToConfiguration(_config));
	
	_config.save();
}
 
Example #4
Source File: PackBase.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
protected void loadConfig(Configuration config) {
    if (this.defaults.fuelCapacity != null) {
        this.fuelCapacity = config.get(this.defaults.section.name, "Fuel Capacity", this.defaults.fuelCapacity, "The maximum amount of fuel that this pack can hold.").setMinValue(1).getInt(this.defaults.fuelCapacity);
    }
    if (this.defaults.fuelUsage != null) {
        this.fuelUsage = config.get(this.defaults.section.name, "Fuel Usage", this.defaults.fuelUsage, "The amount of fuel that this pack uses every tick when used.").setMinValue(0).getInt(this.defaults.fuelUsage);
    }
    if (this.defaults.fuelPerTickIn != null) {
        this.fuelPerTickIn = config.get(this.defaults.section.name, "Fuel Per Tick In", this.defaults.fuelPerTickIn, "The amount of fuel that can be inserted into this pack per tick from external sources.").setMinValue(0).getInt(this.defaults.fuelPerTickIn);
    }
    if (this.defaults.fuelPerTickOut != null) {
        this.fuelPerTickOut = config.get(this.defaults.section.name, "Fuel Per Tick Out", this.defaults.fuelPerTickOut, "The amount of fuel that can be extracted from this pack per tick by external sources. Also determines how quickly Flux Packs can charge other items.").setMinValue(0).getInt(this.defaults.fuelPerTickOut);
    }
    if (this.defaults.armorReduction != null) {
        this.armorReduction = config.get(this.defaults.section.name, "Armor Reduction", this.defaults.armorReduction, "How well this pack can protect the user from damage, if armored. The higher the value, the stronger the armor will be.").setMinValue(0).setMaxValue(20).getInt(this.defaults.armorReduction);
    }
    if (this.defaults.armorFuelPerHit != null) {
        this.armorFuelPerHit = config.get(this.defaults.section.name, "Armor Fuel Per Hit", this.defaults.armorFuelPerHit, "How much fuel is lost from this pack when the user is hit, if armored.").setMinValue(0).getInt(this.defaults.armorFuelPerHit);
    }
    if (this.defaults.enchantability != null) {
        this.enchantability = config.get(this.defaults.section.name, "Enchantability", this.defaults.enchantability, "The enchantability of this pack. If set to 0, no enchantments can be applied.").setMinValue(0).getInt(this.defaults.enchantability);
    }
}
 
Example #5
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 6 votes vote down vote up
public ForgeMetrics(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();
}
 
Example #6
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
public static int getIntFor(Configuration config,String heading, String item, int value, String comment)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		prop.setComment(comment);
		return prop.getInt(value);
	}
	catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add Integer, config wasn't loaded properly!");
	}
	return value;
}
 
Example #7
Source File: IGWSupportNotifier.java    From IGW-mod with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Needs to be instantiated somewhere in your mod's loading stage.
 */
public IGWSupportNotifier(){
    if(FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
        File dir = new File(".", "config");
        Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
        config.load();

        if(config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
            ModContainer mc = Loader.instance().activeModContainer();
            String modid = mc.getModId();
            List<ModContainer> loadedMods = Loader.instance().getActiveModList();
            for(ModContainer container : loadedMods) {
                if(container.getModId().equals(modid)) {
                    supportingMod = container.getName();
                    MinecraftForge.EVENT_BUS.register(this);
                    ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
                    break;
                }
            }
        }
        config.save();
    }
}
 
Example #8
Source File: BackpacksConfig.java    From WearableBackpacks with MIT License 6 votes vote down vote up
public BackpacksConfig(File file) {
	_config = new Configuration(file);
	
	// Add settings from this class as general category.
	addSettingsFromClass(this, Configuration.CATEGORY_GENERAL);
	
	// Iterate over category fields and add their settings.
	for (Field field : getClass().getFields()) {
		if ((field.getDeclaringClass() != getClass()) ||
		    !field.getType().getName().endsWith("Category")) continue;
		try {
			String category = field.getName();
			field.set(this, field.getType().getConstructors()[0].newInstance(this));
			addSettingsFromClass(field.get(this), category);
			if (!_categories.contains(category)) _categories.add(category);
		} catch (InstantiationException |
		         InvocationTargetException |
		         IllegalAccessException ex) { throw new RuntimeException(ex); }
	}
}
 
Example #9
Source File: OilGeneratorFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 6 votes vote down vote up
public OilConfig( Configuration pConfigObject )
{
  pConfigObject.addCustomCategoryComment( "ModFixes.OilGen", "The OilgenChance is based on height of the biome. On high-y biomes, the basic chance is divided by 2, on low-y biomes like oceans, it is multiplied by 1.8.\nThe multiplier set here for -OilBoostBiomes- Biomes is applied after those multipliers are set." );
  OilFixEnabled = pConfigObject.getBoolean( "GenerateOil", "ModFixes", OilFixEnabled, "Set to true to enable OilSpawn from this Mod. Make sure to disable Oil-Spawn in BuildCraft if you do" );
  OilDepostMinDistance = pConfigObject.getInt( "OilDepostMinDistance", "ModFixes.OilGen", OilDepostMinDistance, 0, 1024, "The minimum distance of 2 Oil-Deposits in chunks. Modulo-Based; A 2 here means an deposit can only spawn in chunks that have a number that is a multiple of 2 (Chunknumber * 16 = X/Z coord)" );
  OilSphereChance = pConfigObject.getFloat( "OilSphereChance", "ModFixes.OilGen", (float) OilSphereChance, 0.0F, 2000F, "General OilGen factor" );
  OilSphereMinRadius = pConfigObject.getInt( "OilSphereMinRadius", "ModFixes.OilGen", OilSphereMinRadius, 0, 20, "The minimum radius of an underground OilSphere" );
  OilSphereMaxSize = pConfigObject.getInt( "OilSphereMaxSize", "ModFixes.OilGen", OilSphereMaxSize, 3, 50, "The maximum radius of an underground OilSphere. The final size is calculated by OilSphereMinRadius + Random(OilSphereMaxSize-OilSphereMinRadius)" );
  OilDepositThresholdMedium = pConfigObject.getInt( "OilDepositThresholdMedium", "ModFixes.OilGen", OilDepositThresholdMedium, 0, 100, "Threshold at which an oil-deposit will be considered as 'medium' and the fountain will be higher and thicker." );
  OilDepositThresholdLarge = pConfigObject.getInt( "OilDepositThresholdLarge", "ModFixes.OilGen", OilDepositThresholdLarge, 0, 100, "Threshold at which an oil-deposit will be considered as 'large' and the fountain will be higher and thicker." );
  OilFountainSizeSmall = pConfigObject.getInt( "OilFountainSizeSmall", "ModFixes.OilGen", OilFountainSizeSmall, 0, 100, "Visible height of the fountain above the oil-deposit for MEDIUM deposits" );
  OilFountainSizeLarge = pConfigObject.getInt( "OilFountainSizeLarge", "ModFixes.OilGen", OilFountainSizeLarge, 0, 100, "Visible height of the fountain above the oil-deposit for LARGE deposits" );
  OilBiomeBoostFactor = pConfigObject.getFloat( "OilBiomeBoostFactor", "ModFixes.OilGen", (float) OilBiomeBoostFactor, 0.0F, 50.0F, "Boost factor of oil spheres in certain Biomes that are listed in -OilBoostBiomes-" );

  OilDimensionWhitelist = parseStringListToIntList( pConfigObject.getStringList( "OilDimensionWhitelist", "ModFixes.OilGen", new String[] { "0" }, "List DimensionIDs (Numbers only; One per line!) here where the OilGenerator should do its work" ) );
  OilBiomeIDBlackList = parseStringListToIntList( pConfigObject.getStringList( "OilBiomeIDBlackList", "ModFixes.OilGen", new String[] {}, "List BiomeIDs (Numbers only; One per line!) where no oil should be generated" ) );
  OilBoostBiomes = parseStringListToIntList( pConfigObject.getStringList( "OilBoostBiomes", "ModFixes.OilGen", new String[] {}, "List BiomeIDs (Numbers only; One per line!) where the boost multiplicator is applied. Leave empty to disable Biome-Boost" ) );

}
 
Example #10
Source File: ConfigurationHandler.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
public static void loadConfiguration() {
	try {
		repDisplayPosition = config.getString("Rep Badge Position", Configuration.CATEGORY_CLIENT, "BOTTOM RIGHT", "Location of Rep Badge",
				new String[] { "TOP LEFT", "TOP CENTER", "TOP RIGHT", "BOTTOM LEFT", "BOTTOM RIGHT", "OFF" });
		repDisplayX = config.getInt("Rep Badge X", Configuration.CATEGORY_CLIENT, 0, -20000, 20000, "Sets X offset of Rep Badge");
		repDisplayY = config.getInt("Rep Badge Y", Configuration.CATEGORY_CLIENT, 0, -20000, 20000, "Sets Y offset of Rep Badge");
		repDisplayY = config.getInt("Rep Badge Y", Configuration.CATEGORY_CLIENT, 0, -20000, 20000, "Sets Y offset of Rep Badge");
		sentrySpawnRate = config.getInt("Sentry Spawn Rate", Configuration.CATEGORY_CLIENT, 3, 0, 5, "Sets Sentry Spawn Rate n + 1");
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		if (config.hasChanged()) {
			config.save();
		}
	}
}
 
Example #11
Source File: Config.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
/**
 * Read the config file ordered by Category
 * @throws Exception to Log when sth goes wrong
 */
public static void readConfig(){
	Configuration cfg = CommonProxy.config;
	
	try{
		cfg.load();
		initGeneral(cfg);
		initNetwork(cfg);
		initWorld(cfg);
	}
	catch(Exception e){
		LogisticsPipes2.logger.log(Level.ERROR, "There was a Problem reading the Config File!");
	}
	finally{
		if(cfg.hasChanged()){
			cfg.save();
		}
	}
}
 
Example #12
Source File: CommonProxy.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
public void preInit(FMLPreInitializationEvent event){
	//Read/make the Config file on Startup
	File directory = event.getModConfigurationDirectory();
	config = new Configuration(new File(directory.getPath(), "LogisticsPipes2.cfg"));
	Config.readConfig();
	
	//Load Blocks
	BlockRegistry.init();
	
	//Load Pipes
	PipeRegistry.init();
	
	//Load Items
	ItemRegistry.init();
	
	TileRegistry.init();
	
	LPPacketHandler.registerMessages();
}
 
Example #13
Source File: CoreHandler.java    From AgriCraft with MIT License 6 votes vote down vote up
public static void preInit(FMLPreInitializationEvent event) {
    // Setup Config.
    configDir = event.getSuggestedConfigurationFile().getParentFile().toPath().resolve(Reference.MOD_ID);
    config = new Configuration(configDir.resolve("config.cfg").toFile());

    // Setup Plant Dir.
    jsonDir = configDir.resolve("json");
    defaultDir = jsonDir.resolve("defaults");

    // Setup Provider
    AgriConfigAdapter provider = new ModProvider(config);
    MinecraftForge.EVENT_BUS.register(provider);

    // Initialize AgriCore
    AgriCore.init(new ModLogger(), new ModTranslator(), new ModValidator(), new ModConverter(), provider);

    // Transfer Defaults
    ResourceHelper.findResources(JSON_FILE_PATTERN.asPredicate()).stream()
            .filter(AGRI_FOLDER_PATTERN.asPredicate())
            .forEach(r -> ResourceHelper.copyResource(r, configDir.resolve(r), false)
            );

    // Load the JSON files.
    loadJsons();
}
 
Example #14
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void loadConfigsFromFile(File configFile)
{
    configurationFile = configFile;
    config = new Configuration(configurationFile, null, true);
    config.load();
    reLoadAllConfigs(false);
}
 
Example #15
Source File: Jetpack.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@Override
protected void loadConfig(Configuration config) {
    super.loadConfig(config);
    
    if (this.defaults.speedVertical != null) {
        this.speedVertical = config.get(this.defaults.section.name, "Vertical Speed", this.defaults.speedVertical, "The maximum vertical speed of this jetpack when flying.").setMinValue(0.0D).getDouble(this.defaults.speedVertical);
    }
    if (this.defaults.accelVertical != null) {
        this.accelVertical = config.get(this.defaults.section.name, "Vertical Acceleration", this.defaults.accelVertical, "The vertical acceleration of this jetpack when flying; every tick, this amount of vertical speed will be added until maximum speed is reached.").setMinValue(0.0D).getDouble(this.defaults.accelVertical);
    }
    if (this.defaults.speedVerticalHover != null) {
        this.speedVerticalHover = config.get(this.defaults.section.name, "Vertical Speed (Hover Mode)", this.defaults.speedVerticalHover, "The maximum vertical speed of this jetpack when flying in hover mode.").setMinValue(0.0D).getDouble(this.defaults.speedVerticalHover);
    }
    if (this.defaults.speedVerticalHoverSlow != null) {
        this.speedVerticalHoverSlow = config.get(this.defaults.section.name, "Vertical Speed (Hover Mode / Slow Descent)", this.defaults.speedVerticalHoverSlow, "The maximum vertical speed of this jetpack when slowly descending in hover mode.").setMinValue(0.0D).getDouble(this.defaults.speedVerticalHoverSlow);
    }
    if (this.defaults.speedSideways != null) {
        this.speedSideways = config.get(this.defaults.section.name, "Sideways Speed", this.defaults.speedSideways, "The speed of this jetpack when flying sideways. This is mostly noticeable in hover mode.").setMinValue(0.0D).getDouble(this.defaults.speedSideways);
    }
    if (this.defaults.sprintSpeedModifier != null) {
        this.sprintSpeedModifier = config.get(this.defaults.section.name, "Sprint Speed Multiplier", this.defaults.sprintSpeedModifier, "How much faster this jetpack will fly forward when sprinting. Setting this to 1.0 will make sprinting have no effect apart from the added speed from vanilla.").setMinValue(0.0D).getDouble(this.defaults.sprintSpeedModifier);
    }
    if (this.defaults.sprintFuelModifier != null) {
        this.sprintFuelModifier = config.get(this.defaults.section.name, "Sprint Fuel Usage Multiplier", this.defaults.sprintFuelModifier, "How much more energy this jetpack will use when sprinting. Setting this to 1.0 will make sprinting have no effect on energy usage.").setMinValue(0.0D).getDouble(this.defaults.sprintFuelModifier);
    }
    if (this.defaults.emergencyHoverMode != null) {
        this.emergencyHoverMode = config.get(this.defaults.section.name, "Emergency Hover Mode", this.defaults.emergencyHoverMode, "When enabled, this jetpack will activate hover mode automatically when the wearer is about to die from a fall.").getBoolean(this.defaults.emergencyHoverMode);
    }
}
 
Example #16
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #17
Source File: MainHelmetHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initConfig(Configuration config){
    powerStatX = config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Power_Stat", "stat X", -1).getInt();
    powerStatY = config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Power_Stat", "stat Y", 2).getInt();
    powerStatLeftSided = config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Power_Stat", "stat leftsided", true).getBoolean(true);
    messagesStatX = config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Message_Stat", "stat X", 2).getInt();
    messagesStatY = config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Message_Stat", "stat Y", 2).getInt();
    messagesStatLeftSided = config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Message_Stat", "stat leftsided", false).getBoolean(true);
}
 
Example #18
Source File: Config.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
public static void doNormalConfig(File file)
{
	Configuration config = new Configuration(file);
	
	config.load();
	
	enableBarrels = config.get("Mechanics", "barrels", true).getBoolean();
	enableCrucible = config.get("Mechanics", "crucible", true).getBoolean();
	shouldBarrelsFillWithRain = config.get("Mechanics", "barrelsFillWithRain", true).getBoolean();
	fakePlayersCanSieve = config.get("Mechanics", "fakePlayersCanSieve", false).getBoolean();
	
	compostingTicks = config.get("Composting", "ticksToFormDirt", 600).getInt();
	
	infestedLeavesTicks = config.get("Infested Leaves","ticksToTransform",600).getInt();
       leavesUpdateFrequency = config.get("Infested Leaves", "leavesUpdateFrequency", 40).getInt();
       leavesSpreadChance = config.get("Infested Leaves", "leavesSpreadChance", 0.0015).getDouble();
       doLeavesUpdateClient = config.get("Infested Leaves", "doLeavesUpdateClient", true).getBoolean();
	
       enableBarrelTransformLighting = config.get("Misc", "enableBarrelTransformLighting", true).getBoolean();
       
	stringChance = config.get("Crooking", "stringChance", 1).getDouble();
	stringFortuneChance = config.get("Crooking", "stringFortuneChance", 1).getDouble();
	
	sieveSimilarRadius = config.get("Sieving", "sieveSimilarRadius", 2).getInt();
	
	doEnderIOCompat = config.get("Compatibilitiy", "EnderIO", true).getBoolean();
	doTICCompat = config.get("Compatibilitiy", "TinkersConstruct", true).getBoolean();
	doTOPCompat = config.get("Compatibilitiy", "TheOneProbe", true).getBoolean();
	shouldOreDictOreChunks = config.get("Compatibilitiy", "OreDictOreChunks", true).getBoolean();
	shouldOreDictOreDusts = config.get("Compatibilitiy", "OreDictOreDusts", true).getBoolean();
	
	setFireToMacroUsers = config.get("Sieving", "setFireToMacroUsers", false).getBoolean();
	sievesAutoOutput = config.get("Sieving", "sievesAutoOutput", false).getBoolean();
	
	numberOfTimesToTestVanillaDrops = config.get("Crooking", "numberOfVanillaDropRuns", 3).getInt();
	
	if (config.hasChanged())
		config.save();
}
 
Example #19
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #20
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #21
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #22
Source File: ForgeMetrics.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #23
Source File: ConfigGuiFactory.java    From OpenPeripheral with MIT License 5 votes vote down vote up
private static IConfigElement createModConfig() {
	final Configuration config = OpenPeripheralCore.instance.config();
	final List<IConfigElement> result = Lists.newArrayList();

	for (String categoryName : config.getCategoryNames()) {
		if (!categoryName.equalsIgnoreCase(Config.CATEGORY_FEATURE_GROUPS)) {
			ConfigCategory category = config.getCategory(categoryName);
			result.add(new ConfigElement(category));
		}
	}

	return new DummyCategoryElement("modConfig", "openperipheralcore.config.miscConfig", result);
}
 
Example #24
Source File: SettingListEntities.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@Override
protected void loadFromConfiguration(Configuration config) {
	set(BackpackRegistry.mergeEntityEntriesWithDefault(config.getCategoryNames().stream()
		.filter(name -> name.startsWith(getCategory() + Configuration.CATEGORY_SPLITTER))
		.sorted(Comparator.comparingInt(category -> config.get(category, "index", Integer.MAX_VALUE).getInt()))
		.map(category -> loadEntity(config, category))
		.collect(Collectors.toList())));
}
 
Example #25
Source File: BlockTrackUpgradeHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void saveToConfig(){
    Configuration config = Config.config;
    config.load();
    config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Block_Tracker", "stat X", -1).set(blockTrackInfo.getBaseX());
    config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Block_Tracker", "stat Y", 46).set(blockTrackInfo.getBaseY());
    config.get("Helmet_Options" + Configuration.CATEGORY_SPLITTER + "Block_Tracker", "stat leftsided", true).set(blockTrackInfo.isLeftSided());
    statX = blockTrackInfo.getBaseX();
    statY = blockTrackInfo.getBaseY();
    statLeftSided = blockTrackInfo.isLeftSided();
    config.save();
}
 
Example #26
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static String getStringFor(Configuration config, String heading, String item, String value, String comment)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		prop.setComment(comment);
		return prop.getString();
	} catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add String, config wasn't loaded properly!");
	}
	return value;
}
 
Example #27
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static int getIntFor(Configuration config, String heading, String item, int value)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		return prop.getInt(value);
	}
	catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add Integer, config wasn't loaded properly!");
	}
	return value;
}
 
Example #28
Source File: ScoreHelper.java    From malmo with MIT License 5 votes vote down vote up
/** Initialize scoing. */
static public void update(Configuration configs)
{
    scoringPolicy = configs.get(MalmoMod.SCORING_CONFIGS, "policy", DEFAULT_NO_SCORING).getInt();
    if (scoringPolicy > 0) {
        String customLogHandler = configs.get(MalmoMod.SCORING_CONFIGS, "handler", "").getString();
        setLogging(Level.INFO, customLogHandler);
    }
    if (logging)
        log("<ScoreInit><Policy>" + scoringPolicy + "</Policy></ScoreInit>");
}
 
Example #29
Source File: ConfigHandler.java    From IGW-mod with GNU General Public License v2.0 5 votes vote down vote up
public static void init(File configFile){
    conf = new Configuration(configFile);
    conf.load();
    shouldShowTooltip = conf.get(Configuration.CATEGORY_GENERAL, "Should show tooltip", true).getBoolean(true);
    debugMode = conf.get(Configuration.CATEGORY_GENERAL, "Debug mode", false).getBoolean(false);
    conf.save();
}
 
Example #30
Source File: HoloInventory.java    From HoloInventory with MIT License 5 votes vote down vote up
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
    logger = event.getModLog();

    config = new Configuration(event.getSuggestedConfigurationFile());
    updateConfig();

    int id = 0;
    snw = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);

    // Request packets (client -> server)
    snw.registerMessage(EntityRequest.Handler.class, EntityRequest.class, id++, Side.SERVER);
    snw.registerMessage(TileRequest.Handler.class, TileRequest.class, id++, Side.SERVER);

    // Response packets (server -> client)
    snw.registerMessage(PlainInventory.Handler.class, PlainInventory.class, id++, Side.CLIENT);
    snw.registerMessage(MerchantRecipes.Handler.class, MerchantRecipes.class, id++, Side.CLIENT);

    if (event.getSide().isClient())
    {
        //noinspection MethodCallSideOnly
        ClientEventHandler.init();
    }

    MinecraftForge.EVENT_BUS.register(this);
    MinecraftForge.EVENT_BUS.register(ServerEventHandler.I);
}