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


Java Property类代码示例

本文整理汇总了Java中net.minecraftforge.common.config.Property的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: constructFromConfig

import net.minecraftforge.common.config.Property; //导入依赖的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: get

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
protected <T> T get(String name, String category, String comment, T normal)
{
	try
	{
		Object returned = HarshenUtils.getMethod("get", config.getClass(), String.class, String.class, normal.getClass()).invoke(config, category, name, normal);
		if(normal.getClass().isArray())
			for(Method method : config.getClass().getMethods())
				if(method.getParameterTypes().length == 3 && method.getParameterTypes()[0] == String.class && method.getParameterTypes()[1] == String.class
				&& method.getParameterTypes()[2] == normal.getClass() && method.getParameterTypes()[2].isArray())
					returned = method.invoke(config, category, name, normal);
		if(!(returned instanceof Property))	throw new IllegalArgumentException("Returned Type was not a property. This is practically impossible");
		Property property = (Property) returned;
		property.setComment(comment);
		propertyMap.put(category + "*" + name, property);
		return (T) property.getClass().getMethod("get" + normal.getClass().getSimpleName().replace("Integer", "Int").replace("[]", "List")).invoke(property);
	}
	catch (NullPointerException | SecurityException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
		HarshenCastle.LOGGER.error("Forge Config has no such getter for " + normal.getClass() + ". ErrorClass: " + e.getClass().getSimpleName());
		e.printStackTrace();
	}
	return normal;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:23,代码来源:BaseConfig.java

示例3: preInit

import net.minecraftforge.common.config.Property; //导入依赖的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

示例4: syncConfig

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
private static void syncConfig(boolean load) {
	List<String> propOrder = new ArrayList<String>();
	try {
		Property prop = null;
		if(!config.isChild) {
			if(load) {
				config.load();
			}
		}
		
		biomeIDSpace = getIntegerConfigNode(config, prop, propOrder, Constants.CONFIG_CATEGORY_DIMENSIONS, "biomeIDSpace", "Biome ID for Space.", 100);
		
		config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);

           if (config.hasChanged())
           {
               config.save();
           }
	}catch (final Exception ex) {
		FMLLog.log(Level.ERROR, ex, "Trappist-1 has a problem loading it's config, this can have negative repercussions.");
	}
}
 
开发者ID:BlesseNtumble,项目名称:TRAPPIST-1,代码行数:23,代码来源:TPBiomeConfig.java

示例5: syncConfig

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
private static void syncConfig(boolean load) {
	List<String> propOrder = new ArrayList<String>();
	try {
		Property prop = null;
		if(!config.isChild) {
			if(load) {
				config.load();
			}
		}
		
		dimensionIDTrappistOneB = getIntegerConfigNode(config, prop, propOrder, Constants.CONFIG_CATEGORY_DIMENSIONS, "dimensionIDTrappistOneB", "Dimension ID for Trappist-1B.", -35);
		dimensionIDTrappistOneC = getIntegerConfigNode(config, prop, propOrder, Constants.CONFIG_CATEGORY_DIMENSIONS, "dimensionIDTrappistOneC", "Dimension ID for Trappist-1C.", -36);
		
		config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);

           if (config.hasChanged())
           {
               config.save();
           }
	}catch (final Exception ex) {
		FMLLog.log(Level.ERROR, ex, "Trappist-1 has a problem loading it's config, this can have negative repercussions.");
	}
}
 
开发者ID:BlesseNtumble,项目名称:TRAPPIST-1,代码行数:24,代码来源:TPDimensionConfig.java

示例6: fromJavaPrimitiveType

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
public static Property.Type fromJavaPrimitiveType(Class<?> javaType)
{
	if (javaType.equals(Byte.TYPE) || javaType.equals(Short.TYPE) || javaType.equals(Integer.TYPE))
	{
		return Property.Type.INTEGER;
	}
	
	if (javaType.equals(Float.TYPE) || javaType.equals(Double.TYPE) || javaType.equals(Long.TYPE))
	{
		return Property.Type.DOUBLE;
	}
	
	if (javaType.equals(Boolean.TYPE))
	{
		return Property.Type.BOOLEAN;
	}
	
	return Property.Type.STRING;
}
 
开发者ID:V0idWa1k3r,项目名称:VoidApi,代码行数:20,代码来源:SerializableConfig.java

示例7: setZoomAmount

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
public static void setZoomAmount(int zoomAmount) {
	if (zoomAmount > MAX_ZOOM) {
		zoomAmount = MAX_ZOOM;
	} else if (zoomAmount < MIN_ZOOM) {
		zoomAmount = MIN_ZOOM;
	}

	if (Config.zoomAmount != zoomAmount) {
		Config.zoomAmount = zoomAmount;
		if (config != null) {
			String configComment = I18n.format("config.itemzoom.zoom.amount");
			configComment = configComment + " [range: " + MIN_ZOOM + " ~ " + MAX_ZOOM + ", default: " + DEFAULT_ZOOM + "]";
			Property property = config.get(category, "zoom.amount", DEFAULT_ZOOM, configComment, MIN_ZOOM, MAX_ZOOM);
			property.set(Config.zoomAmount);
			if (config.hasChanged()) {
				config.save();
			}
		}
	}
}
 
开发者ID:mezz,项目名称:ItemZoom,代码行数:21,代码来源:Config.java

示例8: refresh

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
/**
 * Refreshes this mod's configuration
 */
public void refresh()
{
	load();

	Property prop;

	prop = get("options", "spinspeed", 1.0D);
	prop.setLanguageKey("globalxp.config.spinspeed");
	spinSpeed = prop.getDouble(1.0D);

	prop = get("options", "bobspeed", 1.0D);
	prop.setLanguageKey("globalxp.config.bobspeed");
	bobSpeed = prop.getDouble(1.0D);

	prop = get("options", "renderNameplate", true);
	prop.setLanguageKey("globalxp.config.renderNameplate");
	renderNameplate = prop.getBoolean(true);

	if(hasChanged())
		save();
}
 
开发者ID:bl4ckscor3,项目名称:GlobalXP,代码行数:25,代码来源:Config.java

示例9: onConfigApplied

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
public static void onConfigApplied()
{
    AuthlibLoginHelper instance = AuthlibLoginHelper.getInstance();
    for (Property property : PROPERTIES.values())
    {
        if (property.hasChanged())
        {
            String address = property.getName();
            AuthlibLoginHelper.Data data = RESULTS.get(property.getString());
            if (data != null)
            {
                instance.saveAccount(address, data);
            }
        }
    }
}
 
开发者ID:ustc-zzzz,项目名称:AuthlibLoginHelper,代码行数:17,代码来源:AuthlibLoginHelperGuiFactory.java

示例10: getConfigElements

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
private static List<IConfigElement> getConfigElements()
{
    PROPERTIES.clear();
    ImmutableList.Builder<IConfigElement> builder = ImmutableList.builder();
    Map<String, AuthlibLoginHelper.Data> accounts = AuthlibLoginHelper.getInstance().listAccounts();
    for (Map.Entry<String, AuthlibLoginHelper.Data> entry : accounts.entrySet())
    {
        String name = entry.getKey();
        AuthlibLoginHelper.Data data = entry.getValue();
        boolean skip = data.userid.isEmpty() && !data.accessToken.isPresent();

        String[] choices = skip ? SKIP_CHOICES.toArray(new String[0]) : LOGIN_CHOICES.toArray(new String[0]);
        Property property = new Property(name, choices[0], Property.Type.STRING, choices);
        property.setComment(skip ? SKIP_COMMENT : LOGIN_COMMENT);

        builder.add(new ConfigElement(property));
        PROPERTIES.put(name, property);
    }
    return builder.build();
}
 
开发者ID:ustc-zzzz,项目名称:AuthlibLoginHelper,代码行数:21,代码来源:AuthlibLoginHelperGuiFactory.java

示例11: setupBookConfig

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
public static void setupBookConfig(Configuration cfg) {
    ConfigCategory category = cfg.getCategory(CATEGORY_BOOKS);
    if (category.isEmpty()) {
        // Initialize with defaults
        addBook(cfg, Items.BOOK.getRegistryName().toString(), "*");
        addBook(cfg, Items.ENCHANTED_BOOK.getRegistryName().toString(), "*");
        addBook(cfg, Items.WRITABLE_BOOK.getRegistryName().toString(), "*");
        addBook(cfg, Items.WRITTEN_BOOK.getRegistryName().toString(), "*");
        addBook(cfg, "rftools:rftools_manual", BookType.BOOK_BLUE.getModel());
        addBook(cfg, "rftoolscontrol:rftoolscontrol_manual", BookType.BOOK_GREEN.getModel());
        addBook(cfg, "rftoolsdim:rftoolsdim_manual", BookType.BOOK_GREEN.getModel());
        addBook(cfg, "deepresonance:dr_manual", BookType.BOOK_RED.getModel());
    } else {
        for (Map.Entry<String, Property> entry : category.entrySet()) {
            validBooks.put(entry.getKey(), entry.getValue().getString());
        }
    }
}
 
开发者ID:McJty,项目名称:Lector,代码行数:19,代码来源:GeneralConfiguration.java

示例12: getBooleanFor

import net.minecraftforge.common.config.Property; //导入依赖的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

示例13: getIntFor

import net.minecraftforge.common.config.Property; //导入依赖的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

示例14: getDoubleFor

import net.minecraftforge.common.config.Property; //导入依赖的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

示例15: loadConfiguration

import net.minecraftforge.common.config.Property; //导入依赖的package包/类
static void loadConfiguration()
{
    ticketConstraints.clear();
    chunkConstraints.clear();
    for (String mod : config.getCategoryNames())
    {
        if (mod.equals("Forge") || mod.equals("defaults"))
        {
            continue;
        }
        Property modTC = config.get(mod, "maximumTicketCount", 200);
        Property modCPT = config.get(mod, "maximumChunksPerTicket", 25);
        ticketConstraints.put(mod, modTC.getInt(200));
        chunkConstraints.put(mod, modCPT.getInt(25));
    }
    if (config.hasChanged())
    {
        config.save();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:ForgeChunkManager.java


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