net.minecraftforge.common.config.Property Java Examples

The following examples show how to use net.minecraftforge.common.config.Property. 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: OpenModsConfigScreen.java    From OpenModsLib with MIT License 6 votes vote down vote up
protected static IConfigElement createFeatureEntries(String modId) {
	final AbstractFeatureManager manager = FeatureRegistry.instance.getManager(modId);
	if (manager == null) return null;

	final List<IConfigElement> categories = Lists.newArrayList();

	for (String category : manager.getCategories()) {
		List<IConfigElement> categoryEntries = Lists.newArrayList();
		for (String feature : manager.getFeaturesInCategory(category)) {
			final Property property = FeatureRegistry.instance.getProperty(modId, category, feature);
			if (property != null) categoryEntries.add(new ConfigElement(property));
		}

		categories.add(new CategoryElement(category, "openmodslib.config.features." + category, categoryEntries));
	}

	return new CategoryElement("features", "openmodslib.config.features", categories);
}
 
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: TFCOptions.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
public static double getDoubleFor(Configuration config,String heading, String item, double value, String comment)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		prop.setComment(comment);
		return prop.getDouble(value);
	}
	catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add Double, config wasn't loaded properly!");
	}
	return value;
}
 
Example #4
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 #5
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
public static boolean getBooleanFor(Configuration config,String heading, String item, boolean value, String comment)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		prop.setComment(comment);
		return prop.getBoolean(value);
	}
	catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add Integer, config wasn't loaded properly!");
	}
	return value;
}
 
Example #6
Source File: PLConfig.java    From Production-Line with MIT License 6 votes vote down vote up
public static void init(File configFile) {
    instance = new PLConfig(configFile);

    if (!configFile.exists()) {
        gtiLogger.log(Level.ERROR, "Cannot create ProductionLine config file");
        gtiLogger.log(Level.INFO, "Skipping config load");
    } else {
        instance.load();

        Property throwableUran238 = instance.get(CATEGORY_GENERAL, "ThrowableUran238", true);
        throwableUran238.setComment("Allow throw uranium 238, was hit after the radiation effect");
        instance.throwableUran238 = throwableUran238.getBoolean();

        Property throwablePackagedSalt = instance.get(CATEGORY_GENERAL, "ThrowablePackagedSalt", true);
        throwablePackagedSalt.setComment("Allow throw uranium 238, was hit after the salty effect");
        instance.throwablePackagedSalt = throwablePackagedSalt.getBoolean();

        instance.explosiveFurnace = instance.get(CATEGORY_GENERAL, "ExplosiveFurnace", true).getBoolean();

        instance.save();
    }
    gtiLogger.log(Level.INFO, "ProductionLine config loaded");
}
 
Example #7
Source File: ConfigurableFeatureManager.java    From OpenModsLib with MIT License 6 votes vote down vote up
public Table<String, String, Property> loadFromConfiguration(Configuration config) {
	final Table<String, String, Property> properties = HashBasedTable.create();
	for (Table.Cell<String, String, FeatureEntry> cell : features.cellSet()) {
		final FeatureEntry entry = cell.getValue();
		if (!entry.isConfigurable) continue;

		final String categoryName = cell.getRowKey();
		final String featureName = cell.getColumnKey();
		final Property prop = config.get(categoryName, featureName, entry.isEnabled);
		properties.put(categoryName, featureName, prop);
		if (!prop.wasRead()) continue;

		if (!prop.isBooleanValue()) prop.set(entry.isEnabled);
		else entry.isEnabled = prop.getBoolean(entry.isEnabled);
	}

	return ImmutableTable.copyOf(properties);
}
 
Example #8
Source File: ConfigurationCommands.java    From mobycraft with Apache License 2.0 6 votes vote down vote up
@Override
public ConfigProperties getConfigProperties() {
	Property property = Mobycraft.config.get("files", "docker-host", "Docker host IP",
			"The IP of your Docker host (set using /docker host <host>); only used if DOCKER_HOST environment variable is not set");
	if (property.isDefault()) {
		property.setValue(getDefaultHost());
	}
	configProperties.setDockerHostProperty(property);

	property = Mobycraft.config.get("files", "docker-cert-path", "File path",
			"The directory path of your Docker certificate (set using /docker path <path>); only used if DOCKER_CERT_PATH environment variable is not set");
	if (property.isDefault()) {
		property.setValue(getDefaultPath());
	}
	configProperties.setCertPathProperty(property);

	configProperties.setStartPosProperty(Mobycraft.config.get("container-building", "start-pos", "0, 0, 0",
			"The position - x, y, z - to start building containers at (set using /docker start_pos"));

	configProperties.setPollRateProperty(Mobycraft.config.get("container-building", "poll-rate", "2",
			"The rate in seconds at which the containers will update (set using /docker poll_rate <rate in seconds>)"));

	MainCommand.maxCount = (int) Math.floor((Float.parseFloat(configProperties.getPollRateProperty().getString()) * 50));

	return configProperties;
}
 
Example #9
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)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		return prop.getString();
	} catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add String, config wasn't loaded properly!");
	}
	return value;
}
 
Example #10
Source File: ConfigManager.java    From GardenCollection with MIT License 5 votes vote down vote up
public ConfigManager (File file) {
    config = new Configuration(file);

    Property propStrangePlantDrops = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDrops", new String[0]);
    propStrangePlantDrops.comment = "A list of zero or more item IDs.  Breaking the plant will drop an item picked at random from the list.  Ex: minecraft:coal:1";

    Property propStrangePlantDropChance = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDropChance", 1.0);
    propStrangePlantDropChance.comment = "The probability from 0.0 - 1.0 that breaking a strange plant will drop its contents.";
    strangePlantDropChance = propStrangePlantDropChance.getDouble();

    Property propStrangePlantDropMin = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDropMin", 1);
    propStrangePlantDropMin.comment = "The minimum number of items dropped when breaking a strange plant.";
    strangePlantDropMin = propStrangePlantDropMin.getInt();

    Property propStrangePlantDropMax = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDropMax", 1);
    propStrangePlantDropMax.comment = "The maximum number of items dropped when breaking a strange plant.";
    strangePlantDropMax = propStrangePlantDropMax.getInt();

    Property propCompostGrowsOrnamentalTrees = config.get(Configuration.CATEGORY_GENERAL, "compostGrowsOrnamentalTrees", true);
    propCompostGrowsOrnamentalTrees.comment = "Using compost on saplings will grow ornamental (miniature) trees instead of normal trees.";
    compostGrowsOrnamentalTrees = propCompostGrowsOrnamentalTrees.getBoolean();

    Property propGenerateCandelilla = config.get(Configuration.CATEGORY_GENERAL, "generateCandelilla", true);
    propGenerateCandelilla.comment = "Generates clusters of candelilla shrub in warm, sandy biomes.";
    generateCandelilla = propGenerateCandelilla.getBoolean();

    config.save();
}
 
Example #11
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Property getProp(String category, String key, String[] defaultValue, boolean requiresMcRestart)
{
    VALID_CATEGORIES.add(category);
    Property prop = config.get(category, key, defaultValue).setRequiresMcRestart(requiresMcRestart);
    VALID_CONFIGS.add(category + "_" + key);
    return prop;
}
 
Example #12
Source File: ConfigManager.java    From GardenCollection with MIT License 5 votes vote down vote up
private void parseStrangePlantItems (Property property) {
    String[] entries = property.getStringList();
    if (entries == null || entries.length == 0) {
        strangePlantDrops = new ItemStack[0];
        return;
    }

    List<ItemStack> results = new ArrayList<ItemStack>();

    for (String entry : entries) {
        UniqueMetaIdentifier uid = new UniqueMetaIdentifier(entry);
        int meta = (uid.meta == OreDictionary.WILDCARD_VALUE) ? 0 : uid.meta;

        Item item = GameRegistry.findItem(uid.modId, uid.name);
        if (item != null) {
            results.add(new ItemStack(item, 1, meta));
            continue;
        }

        Block block = GameRegistry.findBlock(uid.modId, uid.name);
        if (block != null) {
            item = Item.getItemFromBlock(block);
            if (item != null) {
                results.add(new ItemStack(item, 1, meta));
                continue;
            }
        }
    }

    strangePlantDrops = new ItemStack[results.size()];
    for (int i = 0; i < results.size(); i++)
        strangePlantDrops[i] = results.get(i);
}
 
Example #13
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Property getProp(String category, String key, String defaultValue, boolean requiresMcRestart)
{
    VALID_CATEGORIES.add(category);
    Property prop = config.get(category, key, defaultValue).setRequiresMcRestart(requiresMcRestart);
    VALID_CONFIGS.add(category + "_" + key);
    return prop;
}
 
Example #14
Source File: ConfigManager.java    From GardenCollection with MIT License 5 votes vote down vote up
public ItemStack[] getStrangePlantDrops () {
    if (strangePlantDrops == null) {
        Property propStrangePlantDrops = config.get(Configuration.CATEGORY_GENERAL, "strangePlantDrops", new String[0]);
        parseStrangePlantItems(propStrangePlantDrops);
    }

    return strangePlantDrops;
}
 
Example #15
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Property getProp(String category, String key, double defaultValue, boolean requiresMcRestart)
{
    VALID_CATEGORIES.add(category);
    Property prop = config.get(category, key, defaultValue).setRequiresMcRestart(requiresMcRestart);
    VALID_CONFIGS.add(category + "_" + key);
    return prop;
}
 
Example #16
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Property getProp(String category, String key, int defaultValue, boolean requiresMcRestart)
{
    VALID_CATEGORIES.add(category);
    Property prop = config.get(category, key, defaultValue).setRequiresMcRestart(requiresMcRestart);
    VALID_CONFIGS.add(category + "_" + key);
    return prop;
}
 
Example #17
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Property getProp(String category, String key, boolean defaultValue, boolean requiresMcRestart)
{
    VALID_CATEGORIES.add(category);
    Property prop = config.get(category, key, defaultValue).setRequiresMcRestart(requiresMcRestart);
    VALID_CONFIGS.add(category + "_" + key);
    return prop;
}
 
Example #18
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 #19
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 #20
Source File: TFCOptions.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static boolean getBooleanFor(Configuration config,String heading, String item, boolean value)
{
	if (config == null)
		return value;
	try
	{
		Property prop = config.get(heading, item, value);
		return prop.getBoolean(value);
	}
	catch (Exception e)
	{
		System.out.println("[TFC2] Error while trying to add Integer, config wasn't loaded properly!");
	}
	return value;
}
 
Example #21
Source File: ModConfigs.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
public static void loadConfigs(Configuration config) {
	Property off = config.get(CATAGORY_SERVER, "disabled", disabled);
	off.comment = "On the client this disables other world renders entirely, preventing world requests. On the server this disables sending world info to all clients.";
	disabled = off.getBoolean(disabled);

	Property d = config.get(CATAGORY_SERVER, "datarate", dataRate);
	d.comment = "The number of bytes to send per tick before the server cuts off sending. Only applies to other-world chunks. Default: " + dataRate;
	dataRate = d.getInt(dataRate);

	if (dataRate <= 0) disabled = true;

	if (config.hasChanged()) config.save();
}
 
Example #22
Source File: Config.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
private static void syncMain()
{
	String category = "main";
	List<String> propOrder = Lists.newArrayList();
	Property prop;
	
	/*
	 * Experience
	 */
	prop = main.get(category, "maxLevel", maxLevel);
	prop.setComment("Determines the max level of weapons and armor.");
	maxLevel = prop.getDouble();
	propOrder.add(prop.getName());
	
	prop = main.get(category, "experienceExponent", expExponent);
	prop.setComment("Sets the exponent of the experience algorithm.");
	expExponent = prop.getDouble();
	propOrder.add(prop.getName());
	
	prop = main.get(category, "experienceMultiplier", expMultiplier);
	prop.setComment("Sets the multiplier of the experience algorithm.");
	expMultiplier = prop.getInt();
	propOrder.add(prop.getName());
	
	/*
	 * Miscellaneous
	 */
	prop = main.get(category, "itemBlacklist", itemBlacklist);
	prop.setComment("Items in this blacklist will not gain the leveling systems. Useful for very powerful items or potential conflicts. Style should be 'modid:item'");
	itemBlacklist = prop.getStringList();
	propOrder.add(prop.getName());
	
	prop = main.get(category, "unlimitedDurability", unlimitedDurability);
	prop.setComment("Determines whether or not weapons and armor will lose durability.");
	unlimitedDurability = prop.getBoolean();
	propOrder.add(prop.getName());
	
	main.setCategoryPropertyOrder(category, propOrder);
	main.save();
}
 
Example #23
Source File: ConfigReader.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static Property getProp(String key, int defaultValue)
{
    return getProp(currentCategory, key, defaultValue, currentRequiresMcRestart);
}
 
Example #24
Source File: FeatureRegistry.java    From OpenModsLib with MIT License 4 votes vote down vote up
public void register(AbstractFeatureManager manager) {
	addValue(new Entry(manager, ImmutableTable.<String, String, Property> of()));
}
 
Example #25
Source File: FeatureRegistry.java    From OpenModsLib with MIT License 4 votes vote down vote up
public Entry(AbstractFeatureManager manager, Table<String, String, Property> properties) {
	this.manager = manager;
	this.properties = properties;
}
 
Example #26
Source File: FeatureRegistry.java    From OpenModsLib with MIT License 4 votes vote down vote up
public Property getProperty(String modId, String category, String feature) {
	final Entry entry = features.get(modId);
	if (entry == null) return null;

	return entry.properties.get(category, feature);
}
 
Example #27
Source File: SettingBoolean.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
protected Property.Type getPropertyType() { return Property.Type.BOOLEAN; }
 
Example #28
Source File: SettingPercent.java    From WearableBackpacks with MIT License 4 votes vote down vote up
@Override
protected Property getPropertyFromConfig(Configuration config) {
	return config.get(getCategory(), getName(),
		String.valueOf(getDefault()), getComment(), Property.Type.STRING);
}
 
Example #29
Source File: ConfigManager.java    From GardenCollection with MIT License 4 votes vote down vote up
public ConfigManager (File file) {
    config = new Configuration(file);

    Property propEnableVillagerTrading = config.get(Configuration.CATEGORY_GENERAL, "enableVillagerStampTrading", true);
    propEnableVillagerTrading.comment = "Allows some villagers to buy and sell pattern stamps.";
    enableVillagerTrading = propEnableVillagerTrading.getBoolean();

    boolean firstGen = !config.hasCategory(CAT_PATTERNS);

    categoryPatterns = config.getCategory(CAT_PATTERNS);
    categoryPatterns.setComment("Patterns are additional textures that can be overlaid on top of large pots, both normal and colored.\n"
        + "For each pattern defined, a corresponding 'stamp' item is registered.  The stamp is used with the\n"
        + "pottery table to apply patterns to raw clay pots.\n\n"
        + "This mod can support up to 255 registered patterns.  To add a new pattern, create a new entry in the\n"
        + "config below using the form:\n\n"
        + "  S:pattern.#=texture_name; A Name\n\n"
        + "Where # is an id between 1 and 255 inclusive.\n"
        + "Place a corresponding texture_name.png file into the mod's jar file in assets/modularpots/textures/blocks.\n"
        + "To further control aspects of the pattern, seeing the next section, pattern_settings.\n\n"
        + "Note: Future versions of this mod may add new patterns.  If you haven't made any changes to this\n"
        + "configuration, simply delete it and let it regenerate.  Otherwise visit the mod's development thread\n"
        + "on Minecraft Forums to see what's changed.");

    categoryPatternSettings = config.getCategory(CAT_SETTINGS);
    categoryPatternSettings.setComment("Specifies all the attributes for patterns.  Attributes control how patterns can be found in the world.\n"
        + "In the future, they might control other aspects, such as how patterns are rendered.\n\n"
        + "By default, all patterns will take their attributes from the 'pattern_default' subcategory.  To\n"
        + "customize some or all attributes for a pattern, create a new subcategory modeled like this:\n\n"
        + "  pattern_# {\n"
        + "      I:weight=5\n"
        + "  }\n\n"
        + "The S:pattern_gen option controls what kinds of dungeon chests the pattern's stamp item will appear in, and the\n"
        + "rarity of the item appearing.  The location and rarity are separated by a comma (,), and multiple locations\n"
        + "are separated with a semicolon (;).  Rarity is a value between 1 and 100, with 1 being very rare.  Golden\n"
        + "apples and diamond horse armor also have a rarity of 1.  Most vanilla items have a rarity of 10.  The valid\n"
        + "location strings are:\n\n"
        + "  mineshaftCorridor, pyramidDesertChest, pyramidJungleChest, strongholdCorridor, strongholdLibrary,\n"
        + "  strongholdCrossing, villageBlacksmith, dungeonChest");

    populateDefaultPattern();

    if (firstGen) {
        config.get(categoryPatterns.getQualifiedName(), "pattern.1", "large_pot_1; Serpent");
        config.get(categoryPatterns.getQualifiedName(), "pattern.2", "large_pot_2; Lattice");
        config.get(categoryPatterns.getQualifiedName(), "pattern.3", "large_pot_3; Offset Squares");
        config.get(categoryPatterns.getQualifiedName(), "pattern.4", "large_pot_4; Inset");
        config.get(categoryPatterns.getQualifiedName(), "pattern.5", "large_pot_5; Turtle");
        config.get(categoryPatterns.getQualifiedName(), "pattern.6", "large_pot_6; Creeper");
        config.get(categoryPatterns.getQualifiedName(), "pattern.7", "large_pot_7; Freewheel");
        config.get(categoryPatterns.getQualifiedName(), "pattern.8", "large_pot_8; Creepy Castle");
        config.get(categoryPatterns.getQualifiedName(), "pattern.9", "large_pot_9; Savannah");
        config.get(categoryPatterns.getQualifiedName(), "pattern.10", "large_pot_10; Scales");
        config.get(categoryPatterns.getQualifiedName(), "pattern.11", "large_pot_11; Growth");
        config.get(categoryPatterns.getQualifiedName(), "pattern.12", "large_pot_12; Fern");
        config.get(categoryPatterns.getQualifiedName(), "pattern.13", "large_pot_13; Diamond");

        config.getCategory(CAT_SETTINGS + ".pattern_2");
        config.get(CAT_SETTINGS + ".pattern_2", "weight", 8);
    }

    config.save();

    for (int i = 1; i < 256; i++) {
        if (config.hasKey(categoryPatterns.getQualifiedName(), "pattern." + i)) {
            String entry = config.get(categoryPatterns.getQualifiedName(), "pattern." + i, "").getString();
            String[] parts = entry.split("[ ]*;[ ]*");

            String overlay = parts[0];
            String name = (parts.length > 1) ? parts[1] : null;

            patterns[i] = new PatternConfig(i, overlay, name);
            if (config.hasCategory(CAT_SETTINGS + ".pattern_" + i))
                parsePatternAttribs(patterns[i], CAT_SETTINGS + ".pattern_" + i);
            else {
                if (patterns[i].getName() == null)
                    patterns[i].setName(defaultPattern.getName());

                patterns[i].setWeight(defaultPattern.getWeight());
            }

            patternCount++;
        }
    }
}
 
Example #30
Source File: ConfigPropertyMeta.java    From OpenModsLib with MIT License 4 votes vote down vote up
public Property getProperty() {
	return wrappedProperty;
}