Java源码示例:com.electronwill.nightconfig.core.InMemoryFormat

示例1
public ForgeConfigSpec build() {
	context.ensureEmpty();
	Config valueCfg = Config.of(InMemoryFormat.withSupport(ConfigValue.class::isAssignableFrom));
	values.forEach(v -> valueCfg.set(v.getPath(), v));

	ForgeConfigSpec ret = new ForgeConfigSpec(storage, valueCfg, levelComments);
	values.forEach(v -> v.spec = ret);
	return ret;
}
 
示例2
ServerConfig(ForgeConfigSpec.Builder builder)
{
    builder.comment("Settings for stick crafting").push("sticks");
    removeSticksFromPlanks = builder.define("RemoveSticksFromPlanksRecipes", true);
    builder.pop();
    builder.comment("Settings for rock and ore rock drops").push("rocks");
    enableRocks = builder.define("Enable", true);
    replaceStoneDrops = builder.define("ReplaceStoneDrops", true);
    replaceIronOreDrops = builder.define("ReplaceIronOreDrops", true);
    replaceGoldOreDrops = builder.define("ReplaceGoldOreDrops", true);
    replaceModOreDrops = builder.define("ReplaceModOreDrops", true);
    replacePoorOreDrops = builder.define("ReplacePoorOreDrops", true);
    cobbleRequiresClay = builder.define("CobbleRequiresClay", true);
    builder.pop();
    builder.comment("Settings for the Scraping feature and enchant").push("scraping");
    enableScraping = builder.define("Enable", false);
    scrapingIsTreasure = builder.define("IsTreasureEnchantment", false);
    enableToolScraping = builder.define("EnableToolScraping", true);
    enableArmorScraping = builder.define("EnableArmorScraping", true);
    builder.pop();
    builder.comment("Settings for the drying rack block").push("drying_rack");
    enableMeatRotting = builder.define("EnableMeatRotting", true);
    enableRottenDrying = builder.define("EnableRottenDrying", true);
    enableJerky = builder.define("EnableJerky", true);
    enableMeatDrying = builder.define("EnableMeatDrying", true);
    enableLeatherTanning = builder.define("EnableLeatherTanning", true);
    enableSaddleCrafting = builder.define("EnableSaddleCrafting", true);
    builder.pop();
    builder.comment("Settings for the torch setting fire to entities").push("torch_fire");
    enableTorchFire = builder.define("Enable", true);
    builder.pop();

    builder.comment("Settings for the dough/bread replacements").push("bread");
    enableBread = builder.define("Enable", true);
    removeVanillaBread = builder.define("RemoveVanillaBread", true);
    builder.pop();

    builder.comment("Settings for the chopping block").push("chopping");
    disablePlanksRecipes = builder.define("DisablePlanksRecipes", true);
    choppingDegradeChance = builder
            .comment("The average number of uses before degrading to the next phase will be 1/DegradeChance. Default is 16.67 average uses.")
            .defineInRange("DegradeChance", 0.06, 0, Double.MAX_VALUE);
    choppingExhaustion = builder.defineInRange("Exhaustion", 0.0025, 0, Double.MAX_VALUE);
    choppingWithEmptyHand = builder.defineInRange("EmptyHandFactor", 0.4, 0, Double.MAX_VALUE);
    builder.pop();

    builder.comment("Settings for the fibre collection").push("fibres");
    dropStringFromSheep = builder.define("DropStringFromSheep", true);
    enableStringCrafting = builder.define("EnableStringCrafting", true);
    builder.pop();

    builder.comment("Settings for slime merging").push("slimes");
    mergeSlimes = builder
            .comment("If enabled, slimes will have new AI rules to feel attracted to other slimes, and if 4 slimes of the same size are nearby they will merge into a slime of higher size.")
            .define("Merge", true);
    builder.pop();


    axeLevels = builder
            .comment("If enabled, slimes will have new AI rules to feel attracted to other slimes, and if 4 slimes of the same size are nearby they will merge into a slime of higher size.")
            .define(Arrays.asList("axe_levels"), () -> Config.of(InMemoryFormat.defaultInstance()), x -> true, Config.class);

/*
configuration.addCustomCategoryComment("AxeMultipliers",
        "Allows customizing the multiplier for each axe level. By default this is 'baseOutput * (1+axeLevel)'.\n" +
                "To customize an axeLevel, add a line like 'D:AxeLevel1=2.0' or 'D:AxeLevel5=3.0' without the quotes.\n" +
                "Levels that are not defined will continue using their default value."
);
axeMultipliers = configuration.getCategory("AxeMultipliers");

 */
}
 
示例3
/**
 * Creates a new config bound to the static fields of a class.
 *
 * @param clazz the class to bind
 * @return a config bound to the static fields of the class
 */
public Config bind(Class<?> clazz) {
	return bind(clazz, InMemoryFormat.defaultInstance());
}
 
示例4
/**
 * Creates a new config bound to the fields of a object.
 *
 * @param object the class to bind
 * @return a config bound to the fields of the object
 */
public Config bind(Object object) {
	return bind(object, InMemoryFormat.defaultInstance());
}