当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.get方法代码示例

本文整理汇总了Java中net.minecraftforge.common.config.Configuration.get方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.get方法的具体用法?Java Configuration.get怎么用?Java Configuration.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.common.config.Configuration的用法示例。


在下文中一共展示了Configuration.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: constructFromConfig

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
private static void constructFromConfig(String ID,
                             Potion effect,
                             String enableKey,
                             String enableComment,
                             int maxLevelDefault,
                             int defaultDifficultyCost,
                             double defaultWeight,
                             List<DifficultyModifier> returns,
                             Configuration config) {
    Property modifierEnabledProp = config.get(ID,
            enableKey, true, enableComment);
    boolean modifierEnabled = modifierEnabledProp.getBoolean();
    Property MaxLevelProp = config.get(ID,
            "ModifierMaxLevel", maxLevelDefault, "Maximum level of this effect added to the target player when entering the cloud.");
    int maxLevel = MaxLevelProp.getInt();
    Property difficultyCostPerLevelProp = config.get(ID,
            "DifficultyCostPerLevel", defaultDifficultyCost, "Cost of each level of the effect applied to the target player.");
    int diffCostPerLevel = difficultyCostPerLevelProp.getInt();
    Property selectionWeightProp = config.get(ID,
            "ModifierWeight", defaultWeight, "Weight that affects how often this modifier is selected.");
    double selectionWeight = selectionWeightProp.getDouble();
    if (modifierEnabled && maxLevel > 0 && diffCostPerLevel > 0 && selectionWeight > 0) {
        returns.add(new PotionCloudModifier(effect, maxLevel, diffCostPerLevel, selectionWeight, ID));
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:26,代码来源:PotionCloudModifier.java

示例2: preInit

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {

    Configuration config = new Configuration(new File(e.getModConfigurationDirectory(), "creativezone.cfg"));
    config.load();

    // Check interval (seconds)
    checkInterval = config.getInt("ScanInterval", "config", 1, 1, 60,
            "Sets the interval (in seconds) for scanning player locations");

    // Creative zone radius
    zoneRadius = config.getInt("ZoneRadius", "config", 25, 5, 1000,
            "Sets the radius of the creative zone");

    Property whiteListProp = config.get("config", "Whitelist", new String[0],
            "Gets the list of whitelisted users");
    for (String s : whiteListProp.getStringList()) {
        whitelist.add(s);
    }

    config.save();
}
 
开发者ID:dizzyd,项目名称:creativezone,代码行数:23,代码来源:CreativeZoneMod.java

示例3: getBooleanFor

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
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.comment = comment;
		return prop.getBoolean(value);
	}
	catch (Exception e)
	{
		System.out.println("[" + ModDetails.ModName + "] Error while trying to add Integer, config wasn't loaded properly!");
	}
	return value;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:17,代码来源:ModOptions.java

示例4: getIntFor

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
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.comment = comment;
		return prop.getInt(value);
	}
	catch (Exception e)
	{
		System.out.println("[" + ModDetails.ModName + "] Error while trying to add Integer, config wasn't loaded properly!");
	}
	return value;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:17,代码来源:ModOptions.java

示例5: getDoubleFor

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
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.comment = comment;
		return prop.getDouble(value);
	}
	catch (Exception e)
	{
		System.out.println("[" + ModDetails.ModName + "] Error while trying to add Double, config wasn't loaded properly!");
	}
	return value;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:17,代码来源:ModOptions.java

示例6: preInit

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event){
    config = new Configuration(event.getSuggestedConfigurationFile());
    config.load();
    COMPASSX_PROPERTY = config.get("hidden", ConfigValues.COMPASSX_NAME, ConfigValues.COMPASSX_DEFAULT, I18n.format(ConfigValues.COMPASSX_NAME+".tooltip"));
    COMPASSY_PROPERTY = config.get("hidden", ConfigValues.COMPASSY_NAME, ConfigValues.COMPASSY_DEFAULT, I18n.format(ConfigValues.COMPASSY_NAME+".tooltip"));
    TARGETX_PROPERTY = config.get(Configuration.CATEGORY_GENERAL, ConfigValues.TARGETX_NAME, ConfigValues.TARGETX_DEFAULT, I18n.format(ConfigValues.TARGETX_NAME+".tooltip"));
    TARGETZ_PROPERTY = config.get(Configuration.CATEGORY_GENERAL, ConfigValues.TARGETZ_NAME, ConfigValues.TARGETZ_DEFAULT, I18n.format(ConfigValues.TARGETZ_NAME+".tooltip"));
    XALIGNMENT_PROPERTY = config.get("hidden", ConfigValues.XALIGNMENT_NAME, ConfigValues.XALIGNMENT_DEFAULT.name(), I18n.format(ConfigValues.XALIGNMENT_NAME+".tooltip"));
    YALIGNMENT_PROPERTY = config.get("hidden", ConfigValues.YALIGNMENT_NAME, ConfigValues.YALIGNMENT_DEFAULT.name(), I18n.format(ConfigValues.YALIGNMENT_NAME+".tooltip"));
    syncConfig();

    GameRegistry.register(uhccompass);
    ModelLoader.setCustomModelResourceLocation(uhccompass, 0, new ModelResourceLocation(MODID+":uhccompass", "inventory"));

    MinecraftForge.EVENT_BUS.register(new ClientEvents());
    MinecraftForge.EVENT_BUS.register(new RenderEvents());
    MinecraftForge.EVENT_BUS.register(keyHandler = new KeyHandler());
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:UHC-Compass,代码行数:20,代码来源:UHCCompass.java

示例7: initConfig

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
public static void initConfig(File configFile) { // Gets called from preInit
    try {

        // Ensure that the config file exists
        if (!configFile.exists()) configFile.createNewFile();

        // Create the config object
        config = new Configuration(configFile);

        // Load config
        config.load();

        // Read props from config
        Property debugModeProp = config.get(Configuration.CATEGORY_GENERAL, // What category will it be saved to, can be any string
                "debug_mode", // Property name
                "false", // Default value
                "Enable the debug mode (useful for reporting issues)"); // Comment

        DEBUG_MODE = debugModeProp.getBoolean(); // Get the boolean value, also set the property value to boolean
    } catch (Exception e) {
        // Failed reading/writing, just continue
    } finally {
        // Save props to config IF config changed
        if (config.hasChanged()) config.save();
    }
}
 
开发者ID:lukas2005,项目名称:Device-Mod-Apps,代码行数:27,代码来源:ModConfig.java

示例8: getTierBasedIntList

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
private static int[] getTierBasedIntList(Configuration cfg, String name, String category, int[] def, String comment) {
	Property prop = cfg.get(category, name, def, comment);
	int[] ret = prop.getIntList();
	if(ret == null || ret.length < 3) {
		ret = def;
		prop.set(ret);
	}
	return ret;
}
 
开发者ID:SolraBizna,项目名称:j6502,代码行数:10,代码来源:MainClass.java

示例9: getIntegerConfigNode

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
public static int getIntegerConfigNode(Configuration conf, Property prop, List<String> propOrder, String category, String key, String discription, int defaultInt) {
	int out;
	prop = conf.get(category, key, defaultInt);
	prop.comment = discription;
	prop.setLanguageKey("gc.configgui.dimensionIDMars").setRequiresMcRestart(true);
	out = prop.getInt();
	propOrder.add(prop.getName());
	return out;
}
 
开发者ID:BlesseNtumble,项目名称:TRAPPIST-1,代码行数:10,代码来源:TPBiomeConfig.java

示例10: handleConfig

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
public static void handleConfig(Configuration config){
	Property current;
	int chunkRange; double maxSpawnTime;
	String[] dimensionArray = {"0"};
	config.load();
	current = config.get(Configuration.CATEGORY_GENERAL, "Logging", false);
	current.setComment("Enable this to receive server messages whenever a villager tries to spawn.  Default false.");
	LOGGING = current.getBoolean();
	current = config.get("SpawnValues", "Chunk check range", 2);
	current.setComment("This is the range in chunks from each player that Emergent Villages checks for valid spawn positions.  Default 2.");
	chunkRange = current.getInt();
	current = config.get("SpawnValues", "Inhabited time for maximum spawn chance", 3600000.0d);
	current.setComment("This is the time in ticks at which the spawn chance for a villager for any given chunk is 100%.  Minecraft increments this timer for each player "
			+ "in a chunk once per tick.  Increase this value for a slower spawn rate, and decrease it for a faster spawn rate.  "
			+ "Default 3600000.0f.");
	maxSpawnTime = current.getDouble();
	current = config.get(Configuration.CATEGORY_GENERAL, "Max villagers per chunk", 1);
	current.setComment("This is the maximum amount of villagers that Emergent Villages spawns per chunk.  Default 1.");
	SpawnHandler.initConfig(chunkRange, current.getInt(), maxSpawnTime);
	current = config.get(Configuration.CATEGORY_GENERAL , "Dimensions", dimensionArray);
	current.setComment("These are the dimensions that Emergent Villages will spawn villagers in.  Default 0 (Overworld).");
	dimensionArray = current.getStringList();
	current = config.get(Configuration.CATEGORY_GENERAL, "Tick speed", 600);
	current.setComment("This is the amount of time that Emergent Villages waits between checks.  Minecraft ticks 20 times per second.  Higher numbers means that even if "
			+ "the regional difficulty is high it will take a while to spawn villagers, but the impact on the server will be low.  Lower numbers means villagers spawn "
			+ "faster, up to the limit, but there will be a performance hit.  Default 600.");
	TickHandler.initConfig(current.getInt(), dimensionArray);
	config.save();
}
 
开发者ID:Edicatad,项目名称:EmergentVillages,代码行数:30,代码来源:ConfigHandler.java

示例11: getStringFor

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
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("[" + ModDetails.ModName + "] Error while trying to add String, config wasn't loaded properly!");
	}
	return value;
}
 
开发者ID:Wahazar,项目名称:TFCPrimitiveTech,代码行数:15,代码来源:ModOptions.java

示例12: readRegionConfig

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
private void readRegionConfig(Configuration regionConfig){
    try {
        regionConfig.load();
        Property baseDifficultyProp = regionConfig.get(Configuration.CATEGORY_GENERAL,
                "BaseDifficulty", 0, "Base Difficulty before any modifiers are added. 0 is baseline vanilla.  If this is negative, mobs will be easier, Decreasing this has an effect of making the game ");
        baseDifficulty = baseDifficultyProp.getInt();
        Property allowedMarginProp = regionConfig.get(Configuration.CATEGORY_GENERAL,
                "AllowedMargin", 5, "If the difficulty of a mob is this close to the target, stop looking.  Larger values will cause more variance in mob difficulty, but smaller values may cause excessive computation attempting to find an exact match.");
        allowedMargin = Math.abs(allowedMarginProp.getInt());
        Property maxFailCountProp = regionConfig.get(Configuration.CATEGORY_GENERAL,
                "MaxAllowedFailures", 5, "Allow this many failures while trying to apply modifiers.  Higher values might cause modifier determination to take a long time, but allows closer control over difficulty.");
        maxFailCount = Math.abs(maxFailCountProp.getInt());
        Property thresholdProp = regionConfig.get(Configuration.CATEGORY_GENERAL,
                "ModificationThresold", 0, "Set a threshold that limits when difficulty modifiers will be applied.  Values significantly above 'AllowedMargin' would cause many mobs to be unmodified, but ones that are modified to be significantly modified.");
        threshold = thresholdProp.getInt();

        Property negativeDifficultyPreventsSpawnProp = regionConfig.get(Configuration.CATEGORY_GENERAL,
                "PreventLowDifficultySpawns", true, "Spawns with a negative calculated difficulty for any reason (usually \"MobBaseDifficulty\"), will have a chance of not spawning at all.  The chance of it not spawning is equal to the negative difficulty as a percent.  (-50 has a 50/50 chance of spawning, -101 will never spawn)");
        negativeDifficultyPreventsSpawn = negativeDifficultyPreventsSpawnProp.getBoolean();

        Property mobSpawnMapProp = regionConfig.get(Configuration.CATEGORY_GENERAL,"MobBaseDifficulty",generateDefaultSpawnCosts(),"A set of mob costs, of the format \"<mobRegistryName>:<cost>\".  " +
                "Provides bonus difficulty points to the mob before spawning if the number is positive.  If the number is negative, subtract that much difficulty from the mod before applying modifiers.  If the result after all controls is still negative, the value is used as the chance out of 100 that the mob spawn is cancelled entirely.");
        mobSpawnCosts.clear();
        Arrays.stream(mobSpawnMapProp.getStringList()).forEach(entry->{
            int index = entry.lastIndexOf(":");
            if(index<0) {
                LOG.error("Problem reading line for mob spawn cost.  Needed \"<mobRegistryName>:<cost>\", but string was " + entry);
            }else{
                String name = entry.substring(0,index);
                String valStr = entry.substring(index+1);
                try {
                    int value = Integer.parseInt(valStr);
                    mobSpawnCosts.put(name,value);
                }catch(Exception e){
                    LOG.error("Problem reading line for mob spawn cost.  Second parameter should have been integer, but was "+valStr);
                }
            }
            mobSpawnCosts.put(entry,0);
        });

        if(name.equals("default")) {
            minX = -30000000;
            minZ = -30000000;
            minY = 0;

            maxX = 30000000;
            maxZ = 30000000;
            maxY = 256;

            dimensionId=0;
        }else{
            Property minXBoundaryProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "minXBoundary", -30000000, "minimum x for bounding box of this region.");
            minX = minXBoundaryProp.getInt();
            Property maxXBoundaryProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "maxXBoundary", 30000000, "maximum x for bounding box of this region.");
            maxX = maxXBoundaryProp.getInt();

            Property minYBoundaryProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "minYBoundary", 0, "minimum y for bounding box of this region.");
            minY = minYBoundaryProp.getInt();
            Property maxYBoundaryProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "maxYBoundary", 256, "maximum y for bounding box of this region.");
            maxY = maxYBoundaryProp.getInt();

            Property minZBoundaryProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "minZBoundary", -30000000, "minimum z for bounding box of this region.");
            minZ = minZBoundaryProp.getInt();
            Property maxZBoundaryProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "maxZBoundary", 30000000, "maximum z for bounding box of this region.");
            maxZ = maxZBoundaryProp.getInt();

            Property dimensionIdProp = regionConfig.get(Configuration.CATEGORY_GENERAL, "dimesionId",0,"What dimension this region exists in.");
            dimensionId = dimensionIdProp.getInt();
        }

    }finally {
        if(regionConfig.hasChanged()){
            regionConfig.save();
        }
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:77,代码来源:Region.java

示例13: syncConfig

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
public static void syncConfig() {
    regionsByDim.clear();
    regionsByName.clear();
    if(!rootProgDiffConfigDir.exists()){
        rootProgDiffConfigDir.mkdirs();
    }
    File defaultConfigFile = new File(rootProgDiffConfigDir, ProgressiveDifficulty.MODID+".cfg");
    Configuration defaultConfig = new Configuration(defaultConfigFile);
    //read root config.
    try {
        defaultConfig.load();
        Property isDifficultyChangeEnabledProp = defaultConfig.get(Configuration.CATEGORY_GENERAL,
                "DifficultyControlEnabled", true, "Allow ProgressiveDifficulty to control difficulty of mob spawns.");
        boolean controlEnabled = isDifficultyChangeEnabledProp.getBoolean();
        Property debugLogSpawnsProp = defaultConfig.get(Configuration.CATEGORY_GENERAL,
                "debugSpawnDetails", false, "Send messages to the log detailing computed costs of mobs and which modifiers have been chosen for them.");
        debugLogSpawns = debugLogSpawnsProp.getBoolean();

        Property blacklistProp = defaultConfig.get(Configuration.CATEGORY_GENERAL,"BlacklistMode",true,"All mobs are modified, except those that are in the blacklist.  If set to false, only those in the mob list are modified.  Boss-type mobs are never modified.");
        isBlacklistMode = blacklistProp.getBoolean();

        Property mobListProp = defaultConfig.get(Configuration.CATEGORY_GENERAL,"MobList",defaultBlacklist,"List of mobs, either blacklist or whitelisted for modification by this mod.  See BlacklistMode.");
        mobBlackWhiteList.clear();
        mobBlackWhiteList.addAll(Sets.newHashSet(mobListProp.getStringList()));

        Property iMobFilterProp = defaultConfig.get(Configuration.CATEGORY_GENERAL,"UseIMobFilter",true,"Only modify creatures that implement the IMob interface.  You almost certainly want this, unless a modded mob is not being modified.  This allows easy filtering of passive mobs.  If you set this to false, make sure you add all passive mobs to the blacklist!");
        useIMobFilter = iMobFilterProp.getBoolean();

        enabled=controlEnabled;
        if (!controlEnabled) {
            //mod is effectively disabled.
            return;
        }
    } catch (Exception e) {
        //failed to read config!?
        LOG.error("FAILED TO READ BASE CONFIG FOR ProgressiveDifficulty.  Message was: " + e.getMessage());
        StringWriter stream = new StringWriter();
        PrintWriter writer = new PrintWriter(stream);
        e.printStackTrace(writer);
        LOG.error(stream.toString());
    } finally {
        if (defaultConfig.hasChanged()) {
            defaultConfig.save();
        }
    }

    List<String> regionNames = Lists.newArrayList();
    File[] subFiles = rootProgDiffConfigDir.listFiles();
    if(subFiles!=null){
        regionNames.addAll(Arrays.stream(subFiles)
                .filter(path->path.isDirectory())
                .map(file->file.getName())
                .collect(Collectors.toList()));
    }

    if(!regionNames.contains("default")){
        regionNames.add("default");
    }
    for(String regionName : regionNames){
        Region region = new Region(regionName);
        region.readConfig();
        int dimId = region.getDimensionId();
        regionsByDim.computeIfAbsent(dimId, key -> new TreeSet<Region>()).add(region);
        regionsByName.put(regionName,region);
    }
    defaultRegion = regionsByName.get("default");
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:68,代码来源:DifficultyManager.java

示例14: loadConfig

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
static void loadConfig(File configurationFile)
{
    config = new Configuration(configurationFile);

    Property bl = config.get("items", "blacklist", new String[0]);
    bl.setComment("List of items to disallow from placing in the belt.");

    Property wl = config.get("items", "whitelist", new String[0]);
    wl.setComment("List of items to force-allow placing in the belt. Takes precedence over blacklist.");

    Property showBeltOnPlayersProperty = config.get("display", "showBeltOnPlayers", true);
    showBeltOnPlayersProperty.setComment("If set to FALSE, the belts and tools will NOT draw on players.");

    Property beltItemScaleProperty = config.get("display", "beltItemScale", 0.5);
    beltItemScaleProperty.setComment("Changes the scale of items on the belt.");

    Property releaseToSwapProperty = config.get("input", "releaseToSwap", false);
    releaseToSwapProperty.setComment("If set to TRUE, releasing the menu key (R) will activate the swap. Requires a click otherwise (default).");

    Property clipMouseToCircleProperty = config.get("input", "clipMouseToCircle", false);
    clipMouseToCircleProperty.setComment("If set to TRUE, the radial menu will try to prevent the mouse from leaving the outer circle.");

    Property allowClickOutsideBoundsProperty = config.get("input", "allowClickOutsideBounds", false);
    allowClickOutsideBoundsProperty.setComment("If set to TRUE, the radial menu will allow clicking outside the outer circle to activate the items.");

    display = config.getCategory("display");
    display.setComment("Options for customizing the display of tools on the player");

    input = config.getCategory("input");
    input.setComment("Options for customizing the interaction with the radial menu");

    showBeltOnPlayers = showBeltOnPlayersProperty.getBoolean();
    beltItemScale = (float)beltItemScaleProperty.getDouble();

    releaseToSwap = releaseToSwapProperty.getBoolean();
    clipMouseToCircle = clipMouseToCircleProperty.getBoolean();
    allowClickOutsideBounds = allowClickOutsideBoundsProperty.getBoolean();

    blackListString.addAll(Arrays.asList(bl.getStringList()));
    whiteListString.addAll(Arrays.asList(wl.getStringList()));
    if (!bl.wasRead() ||
            !wl.wasRead() ||
            !releaseToSwapProperty.wasRead() ||
            !showBeltOnPlayersProperty.wasRead() ||
            !beltItemScaleProperty.wasRead() ||
            !clipMouseToCircleProperty.wasRead() ||
            !allowClickOutsideBoundsProperty.wasRead())
    {
        config.save();
    }
}
 
开发者ID:gigaherz,项目名称:ToolBelt,代码行数:52,代码来源:Config.java

示例15: addBook

import net.minecraftforge.common.config.Configuration; //导入方法依赖的package包/类
private static void addBook(Configuration cfg, String name, String type) {
    cfg.get(CATEGORY_BOOKS, name, type);
    validBooks.put(name, type);
}
 
开发者ID:McJty,项目名称:Lector,代码行数:5,代码来源:GeneralConfiguration.java


注:本文中的net.minecraftforge.common.config.Configuration.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。