當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。