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


Java ConfigCategory.containsKey方法代码示例

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


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

示例1: parse

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json) {
    String category = JsonUtils.getString(json, "category");
    String key = JsonUtils.getString(json, "key");
    boolean flip = JsonUtils.getBoolean(json, "flip", false);

    if (config.hasCategory(category)) {
        ConfigCategory cat = config.getCategory(category);
        if (cat.containsKey(key) && cat.get(key).isBooleanValue()) {
            return () -> flip != cat.get(key).getBoolean();
        } else {
            throw new JsonParseException(String.format("Key doesn't exist on category or is not of a boolean type. Category: %s, Key: %s", category, key));
        }
    } else {
        throw new JsonParseException(String.format("Category doesn't exist on config file. Category: %s, Config: %s", category, config.getConfigFile().getAbsolutePath()));
    }
}
 
开发者ID:TheCBProject,项目名称:CodeChickenLib,代码行数:18,代码来源:AbstractForgeConfigConditionalFactory.java

示例2: isFree

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
boolean isFree(String name, int val) {
    for (String categoryName : channelConfig.getCategoryNames()) {
        ConfigCategory cat = channelConfig.getCategory(categoryName);
        if (cat.getQualifiedName().equals(name)) {
            if (channelConfig.get(categoryName, "channel", val).getInt() == val) {
                return true;
            }
            // Uhm.
            continue;
        }
        if (!cat.containsKey("channel")) {
            continue;
        }
        int here_chan = channelConfig.get(categoryName, "channel", -1).getInt();
        if (here_chan == val) {
            return false;
        }
    }
    return true;
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:21,代码来源:HammerInfo.java

示例3: copyCategoryProps

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
/**
 * Copies property objects from another Configuration object to this one using the list of category names. Properties that only exist in the
 * "from" object are ignored. Pass null for the ctgys array to include all categories.
 */
public void copyCategoryProps(final Configuration fromConfig, String... ctgys)
{
    if (ctgys == null)
        ctgys = this.getCategoryNames().toArray(new String[this.getCategoryNames().size()]);
    
    for (final String ctgy : ctgys)
        if (fromConfig.hasCategory(ctgy) && this.hasCategory(ctgy))
        {
        	final ConfigCategory thiscc = this.getCategory(ctgy);
        	final ConfigCategory fromcc = fromConfig.getCategory(ctgy);
            for (final Entry<String, Property> entry : thiscc.getValues().entrySet())
                if (fromcc.containsKey(entry.getKey()))
                    thiscc.put(entry.getKey(), fromcc.get(entry.getKey()));
        }
}
 
开发者ID:OreCruncher,项目名称:Restructured,代码行数:20,代码来源:JarConfiguration.java

示例4: reload

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
/**
 * Loads the config file from the hard drive
 */
public void reload() {
    config.load();
    for (ConfigProperty property : properties) {
        ConfigCategory category = config.getCategory(property.category);
        Property forgeProp;
        if (!category.containsKey(property.name)) {
            forgeProp = new Property(property.name, property.get().toString(), property.getType());
            forgeProp.comment = property.comment;
            category.put(property.name, forgeProp);
        } else {
            forgeProp = category.get(property.name);
            forgeProp.comment = property.comment;
        }
        setProperty(property, forgeProp);
    }
    config.save();
}
 
开发者ID:MyEssentials,项目名称:MyEssentials-Core,代码行数:21,代码来源:ConfigTemplate.java

示例5: transferOldConfig

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
private void transferOldConfig(File file) {
	if (file.exists()) {
		Configuration temp = new Configuration(file);
		ConfigCategory cat = temp.getCategory(Configuration.CATEGORY_GENERAL);
		if (cat.containsKey("mrb1"))
			DROPEGG_PROPERTY.set(!cat.get("mrb1").getBoolean());
		if (cat.containsKey("mrb2"))
			REBIRTHCHANCE_PROPERTY.set(cat.get("mrb2").getDouble());
		if (cat.containsKey("mrb3"))
			ANIMALREBIRTH_PROPERTY.set(cat.get("mrb3").getBoolean());
		if (cat.containsKey("mrb4"))
			EXTRAMOBCOUNT_PROPERTY.set(cat.get("mrb4").getInt());
		if (cat.containsKey("mrb5"))
			REBIRTHFROMNONPLAYER_PROPERTY.set(cat.get("mrb5").getBoolean());
		if (cat.containsKey("mrb6"))
			MULTIMOBCHANCE_PROPERTY.set(cat.get("mrb6").getDouble());
		if (cat.containsKey("mrb7"))
			MULTIMOBMODE_PROPERTY.set(cat.get("mrb7").getString());
		if (cat.containsKey("solar_apocalypse_fix"))
			DAMAGEFROMSUNLIGHT_PROPERTY.set(!cat.get("solar_apocalypse_fix").getBoolean());
		if (cat.containsKey("allowbosses"))
			ALLOWBOSSES_PROPERTY.set(cat.get("allowbosses").getBoolean());
		if (cat.containsKey("allowslimes"))
			ALLOWSLIMES_PROPERTY.set(cat.get("allowslimes").getBoolean());
		if (cat.containsKey("vanillaonly"))
			VANILLAONLY_PROPERTY.set(cat.get("vanillaonly").getBoolean());
		if (file.delete())
			logInfo("Old Config transferred.");
	}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Mob-Rebirth,代码行数:31,代码来源:MobRebirth.java

示例6: doConfig

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public void doConfig(ConfigCategory cat)
{
    if (!(cat.containsKey("name") && cat.containsKey("item"))) throw new RuntimeException("Configuration error. Missing required element on " + getUniqueName());

    this.name = cat.get("name").getString();
    this.item = cat.get("item").getString();

    this.aliases = cat.containsKey("aliases") ? cat.get("aliases").getStringList() : new String[0];
    this.allowUsername = cat.containsKey("allowUsername") && cat.get("allowUsername").getBoolean();
    this.meta = cat.containsKey("meta") ? cat.get("meta").getInt() : 0;
    this.stacksize = cat.containsKey("stacksize") ? cat.get("stacksize").getInt() : 1;
    this.message = cat.containsKey("message") ? cat.get("message").getString() : null;
    this.displayname = cat.containsKey("displayname") ? cat.get("displayname").getString() : null;
    this.enabled = !cat.containsKey("enabled") || cat.get("enabled").getBoolean();
}
 
开发者ID:DoubleDoorDevelopment,项目名称:D3Commands,代码行数:16,代码来源:ItemCommandEntry.java

示例7: deserializeRecursive

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public void deserializeRecursive(ConfigCategory categoryCurrent, Object objectCurrent)
{
	try
	{
		for (Field f : objectCurrent.getClass().getDeclaredFields())
		{
			if (Modifier.isPublic(f.getModifiers()) && !Modifier.isStatic(f.getModifiers()) && !Modifier.isFinal(f.getModifiers()) && !f.isAnnotationPresent(ConfigIgnore.class))
			{
				if (f.getType().isPrimitive() || f.getType().equals(String.class))
				{
					if (categoryCurrent.containsKey(f.getName()))
					{
						this.deserializePrimitiveField(f, categoryCurrent.get(f.getName()), objectCurrent);
					}
				}
				else
				{
					boolean hasAdapter = false;
					for (ConfigAdapter<Object> a : adapters)
					{
						if (a.acceptsDeserialization(f.getType()))
						{
							f.set(objectCurrent, a.deserialize(categoryCurrent.get(f.getName())));
							hasAdapter = true;
							break;
						}
					}
					
					if (!hasAdapter)
					{
						deserializeRecursive(new ConfigCategory(f.getName(), categoryCurrent), f.getType().newInstance());
					}
				}
			}
		}
	}
	catch (Exception ex)
	{
		VCLoggers.loggerErrors.log(LogLevel.Error, "Caught an exception trying to serialize a configuration file!", ex);
	}
}
 
开发者ID:V0idWa1k3r,项目名称:VoidApi,代码行数:42,代码来源:SerializableConfig.java

示例8: hasKey

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public boolean hasKey(final String category, final String key)
{
	final ConfigCategory cat = categories.get(category);
    return cat != null && cat.containsKey(key);
}
 
开发者ID:OreCruncher,项目名称:Restructured,代码行数:6,代码来源:JarConfiguration.java

示例9: ItemCommandEntry

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public ItemCommandEntry(ConfigCategory cat)
{
    super(cat.getQualifiedName(), cat.containsKey("modids") ? cat.get("modids").getStringList() : null);
    doConfig(cat);
}
 
开发者ID:DoubleDoorDevelopment,项目名称:D3Commands,代码行数:6,代码来源:ItemCommandEntry.java

示例10: ModVersionChecker

import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public ModVersionChecker(String modName, String currentVer, String versionURL, String updateURL, String[] loadMsg, String[] inGameMsg, int timeoutMS) {
	this.modName = modName;
	this.currentVer = currentVer;
	this.updateURL = updateURL;
	this.loadMsg = loadMsg;
	this.inGameMsg = inGameMsg;

	try {
		this.versionURL = new URL(versionURL);
		Log.info("Initializing ModVersionChecker for mod %s", modName);
	} catch (Throwable e) {
		Log.warn("Error initializing ModVersionChecker for mod %s: %s", modName, e.getMessage());
	}

	String[] versionLines = MiscUtils.loadTextFromURL(this.versionURL, new String[] { currentVer }, timeoutMS);

	proposedVer = versionLines[0].trim();

	// Keep track of the versions we've seen to keep from nagging players
	// with new version notifications beyond the first one
	if (trackerDir == null) {
		trackerDir = new File(MCUtils.getConfigDir() + "/OpenModsLib/");
		if (trackerDir.exists() || trackerDir.mkdirs()) trackerFile = new File(trackerDir, "ModVersionCheckerTracking.txt");
	}

	if (versionCheckTracker == null) versionCheckTracker = new Configuration(trackerFile);

	versionCheckTracker.load();
	ConfigCategory cc = versionCheckTracker.getCategory("version_check_tracker");

	if (!cc.containsKey(modName)) versionCheckTracker.get("version_check_tracker", modName, currentVer);

	if (isNewerVersion(currentVer, proposedVer)) lastNewVersionFound = proposedVer;
	else lastNewVersionFound = cc.get(modName).getString();

	cc.get(modName).set(proposedVer);

	versionCheckTracker.save();

	setLoadMessage(loadMsg);
	setInGameMessage(inGameMsg);
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:43,代码来源:ModVersionChecker.java


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