Java Code Examples for net.minecraftforge.common.config.ConfigCategory

The following are top voted examples for showing how to use net.minecraftforge.common.config.ConfigCategory. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: McHeliPrivacyShield   File: ConfigGuiFactory.java   View source code 6 votes vote down vote up
@SuppressWarnings({ "rawtypes" })
private static @Nonnull List<IConfigElement> getConfigElements() {
	final List<IConfigElement> list = new ArrayList<IConfigElement>();

	for (final String cat : Config.getConfig().getCategoryNames()) {
		final ConfigCategory cc = Config.getConfig().getCategory(cat);

		if (cc.isChild())
			continue;

		final ConfigElement ce = new ConfigElement<String>(cc);
		list.add(ce);
	}

	return list;
}
 
Example 2
Project: Lector   File: GeneralConfiguration.java   View source code 6 votes vote down vote up
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());
        }
    }
}
 
Example 3
Project: CustomWorldGen   File: ForgeGuiFactory.java   View source code 6 votes vote down vote up
/**
 * This method is called in the constructor and is used to set the childScreen field.
 */
@Override
protected GuiScreen buildChildScreen()
{
    List<IConfigElement> list = new ArrayList<IConfigElement>();

    list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig",
            AddModOverrideEntry.class));
    for (ConfigCategory cc : ForgeChunkManager.getModCategories())
        list.add(new ConfigElement(cc));

    return new GuiConfig(this.owningScreen, list, this.owningScreen.modID,
            this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
            this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title,
            I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig"));
}
 
Example 4
Project: MacroKey   File: JsonConfig.java   View source code 6 votes vote down vote up
public JsonConfig(File file){
    this.keybindingFile = new File(file.getParent()+"/macrokey/keybindings.json");
    this.layerFile = new File(file.getParent()+"/macrokey/layers.json");


    MacroKey.instance.boundKeys = new ArrayList<BoundKey>();
    MacroKey.instance.layers = new ArrayList<Layer>();


    File dir = new File(file.getParent()+"/macrokey/");
    if(!dir.exists()){
        dir.mkdir();
    }

    FileHelper.fileExist(keybindingFile);
    FileHelper.fileExist(layerFile);


    ConfigCategory category = MacroKey.instance.configuration.getCategory("bindings");
    if(!category.isEmpty()){
        LogHelper.info("Old Configuration File Detected! Converting...");
        convertConfig();
        MacroKey.instance.configuration.removeCategory(category);
        MacroKey.instance.configuration.save();
    }
}
 
Example 5
Project: TRHS_Club_Mod_2016   File: ForgeGuiFactory.java   View source code 6 votes vote down vote up
/**
 * This method is called in the constructor and is used to set the childScreen field.
 */
@Override
protected GuiScreen buildChildScreen()
{
    List<IConfigElement> list = new ArrayList<IConfigElement>();
    
    list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", 
            AddModOverrideEntry.class));
    for (ConfigCategory cc : ForgeChunkManager.getModCategories())
        list.add(new ConfigElement(cc));
    
    return new GuiConfig(this.owningScreen, list, this.owningScreen.modID,
            this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
            this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, 
            I18n.func_135052_a("forge.configgui.ctgy.forgeChunkLoadingModConfig"));
}
 
Example 6
Project: SignPicture   File: ConfigGui.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static @Nonnull List<IConfigElement> getConfigElements() {
	final List<IConfigElement> list = new ArrayList<IConfigElement>();

	for (final String cat : Config.getConfig().getCategoryNames()) {
		final ConfigCategory cc = Config.getConfig().getCategory(cat);

		if (cc.isChild())
			continue;

		final ConfigElement ce = new ConfigElement<String>(cc);
		list.add(ce);
	}

	return list;
}
 
Example 7
Project: blockbuster   File: GuiConfig.java   View source code 6 votes vote down vote up
private static List<IConfigElement> getConfigElements()
{
    List<IConfigElement> elements = new ArrayList<IConfigElement>();

    for (String name : Blockbuster.proxy.forge.getCategoryNames())
    {
        ConfigCategory category = Blockbuster.proxy.forge.getCategory(name);
        category.setLanguageKey("blockbuster.config." + name + ".title");

        if (name.indexOf(".") == -1)
        {
            elements.add(new ConfigElement(category));
        }
    }

    return elements;
}
 
Example 8
Project: CodeChickenLib   File: AbstractForgeConfigConditionalFactory.java   View source code 6 votes vote down vote up
@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()));
    }
}
 
Example 9
Project: EEWReciever   File: ConfigGui.java   View source code 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private static List<IConfigElement> getConfigElements() {
	final List<IConfigElement> list = new ArrayList<IConfigElement>();

	for (final String cat : ConfigHandler.instance.getCategoryNames()) {
		final ConfigCategory cc = ConfigHandler.instance.getCategory(cat);

		if (cc.isChild())
			continue;

		final ConfigElement ce = new ConfigElement<String>(cc);
		list.add(ce);
	}

	return list;
}
 
Example 10
Project: Survivalist   File: ConfigurationCondition.java   View source code 6 votes vote down vote up
@Override
public BooleanSupplier parse(JsonContext context, JsonObject json)
{
    JsonPrimitive categoryName = json.getAsJsonPrimitive("category");
    JsonPrimitive keyName = json.getAsJsonPrimitive("key");

    ConfigCategory category = ConfigManager.instance.config.getCategory(categoryName.getAsString());
    Property property = category != null ? category.get(keyName.getAsString()) : null;

    if (property == null)
    {
        Survivalist.logger.error("Property not found! {} / {}", categoryName.getAsString(), keyName.getAsString());
        return () -> false;
    }

    return property::getBoolean;
}
 
Example 11
Project: Factorization   File: HammerInfo.java   View source code 6 votes vote down vote up
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;
}
 
Example 12
Project: AquaMunda   File: GeneralConfiguration.java   View source code 6 votes vote down vote up
public static void initGrindstoneRecipes(Configuration cfg) {
    ConfigCategory category = cfg.getCategory(CATEGORY_RECIPES_GRINDSTONE);
    if (category.isEmpty()) {
        // Initialize with defaults
        addRecipe(cfg, "flour", new ItemStack(Items.WHEAT), new ItemStack(ModItems.flour), 100);
        addRecipe(cfg, "bonemeal", new ItemStack(Items.BONE), new ItemStack(Items.DYE, 5, EnumDyeColor.WHITE.getDyeDamage()), 100);
        addRecipe(cfg, "flint", new ItemStack(Blocks.GRAVEL), new ItemStack(Items.FLINT, 2), 100);
        addRecipe(cfg, "glowstone", new ItemStack(Blocks.GLOWSTONE), new ItemStack(Items.GLOWSTONE_DUST, 4), 300);
        addRecipe(cfg, "sugar", new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 2), 100);
        addRecipe(cfg, "blazepowder", new ItemStack(Items.BLAZE_ROD), new ItemStack(Items.BLAZE_POWDER, 3), 200);
    } else {
        for (Map.Entry<String, Property> entry : category.entrySet()) {
            String[] list = entry.getValue().getStringList();
            GrindstoneRecipeRepository.addRecipe(new GrindstoneRecipe(getItem(list, 0), getItem(list, 1), getInt(list, 2)));
        }
    }
}
 
Example 13
Project: notenoughwands1.8.8   File: MovingWand.java   View source code 6 votes vote down vote up
@Override
public void initConfig(Configuration cfg) {
    super.initConfig(cfg);
    maxHardness = (float) cfg.get(Config.CATEGORY_WANDS, getUnlocalizedName() + "_maxHardness", maxHardness, "Max hardness this block can move.)").getDouble();
    placeDistance = cfg.get(Config.CATEGORY_WANDS, getUnlocalizedName() + "_placeDistance", placeDistance, "Distance at which to place blocks in 'in-air' mode").getInt();

    ConfigCategory category = cfg.getCategory(Config.CATEGORY_MOVINGBLACKLIST);
    if (category.isEmpty()) {
        // Initialize with defaults
        blacklist(cfg, "tile.shieldBlock");
        blacklist(cfg, "tile.shieldBlock2");
        blacklist(cfg, "tile.shieldBlock3");
        blacklist(cfg, "tile.solidShieldBlock");
        blacklist(cfg, "tile.invisibleShieldBlock");
        setCost(cfg, "tile.mobSpawner", 5.0);
        setCost(cfg, "tile.blockAiry", 20.0);
    } else {
        for (Map.Entry<String, Property> entry : category.entrySet()) {
            blacklisted.put(entry.getKey(), entry.getValue().getDouble());
        }
    }
}
 
Example 14
Project: Coding   File: Configs.java   View source code 6 votes vote down vote up
public static void villageConfiguration() {
	ConfigCategory cat_village = config.getCategory(CATEGORY_VILLAGE);
	cat_village.setComment("Here you can configure the village generation");
	loadFields(cat_village, VILLAGE.class);
	
	if (VILLAGE.village_minDist < 0) {
		LogHelper.error("VillageDensity: Invalid config: Minimal distance must be non-negative.");
		VILLAGE.village_gen_enabled = false;
	}
	if (VILLAGE.village_minDist >= VILLAGE.village_density) {
		LogHelper.error("VillageDensity: Invalid config: Minimal distance must be smaller than density.");
		VILLAGE.village_gen_enabled = false;
	}
	if (VILLAGE.village_size < 0) {
		VILLAGE.village_gen_enabled = false;
		LogHelper.error("VillageDensity: Invalid config: Size must be non-negative.");
	}		
}
 
Example 15
Project: Restructured   File: Assets.java   View source code 6 votes vote down vote up
private static List<ChestGenHooks> getChestGenerationHooks() {

		if (chestHooks != null)
			return chestHooks;

		chestHooks = new ArrayList<ChestGenHooks>();
		final ConfigCategory c = chests.getCategory(ConfigProcessor.CONFIG_CHESTS);

		for (final ConfigCategory p : c.getChildren()) {
			if(!isContainerNode(p)) {
				processEntry(null, p, chestHooks);
			} else {
				for (final ConfigCategory cc : p.getChildren())
					processEntry(p, cc, chestHooks);
			}
		}

		return chestHooks;
	}
 
Example 16
Project: Restructured   File: ConfigProcessor.java   View source code 6 votes vote down vote up
@Override
public boolean apply(final Object[] input) {
	final String prefix = (String) input[0];
	final InputStream stream = (InputStream) input[2];

	// The input stream contains the config file we need
	// to merge into the master.
	final JarConfiguration src = new JarConfiguration(stream);
	final ConfigCategory c = src.getCategory(CONFIG_CHESTS);

	// If the property in the chests.cfg has not been
	// initialized copy it from the ZIP.
	for (final ConfigCategory p : c.getChildren()) {
		final String name = CONFIG_CHESTS + "." + prefix + "." + p.getName();
		final ConfigCategory temp = target.getCategory(name);
		if (temp.isEmpty()) {
			for (final Entry<String, Property> item : p.getValues().entrySet()) {
				temp.put(item.getKey(), item.getValue());
			}
		}
	}

	return true;
}
 
Example 17
Project: Restructured   File: JarConfiguration.java   View source code 6 votes vote down vote up
public void removeCategory(final ConfigCategory category)
{
    for (final ConfigCategory child : category.getChildren())
    {
        removeCategory(child);
    }

    if (categories.containsKey(category.getQualifiedName()))
    {
        categories.remove(category.getQualifiedName());
        if (category.parent != null)
        {
            category.parent.removeChild(category);
        }
        changed = true;
    }
}
 
Example 18
Project: Restructured   File: JarConfiguration.java   View source code 6 votes vote down vote up
public boolean hasChanged()
{
    if (changed) return true;
    
    for (final ConfigCategory cat : categories.values())
    {
        if (cat.hasChanged()) return true;
    }

    for (final JarConfiguration child : children.values())
    {
        if (child.hasChanged()) return true;
    }

    return false;
}
 
Example 19
Project: Restructured   File: JarConfiguration.java   View source code 6 votes vote down vote up
/**
 * 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()));
        }
}
 
Example 20
Project: CauldronGit   File: ForgeGuiFactory.java   View source code 6 votes vote down vote up
/**
 * This method is called in the constructor and is used to set the childScreen field.
 */
@Override
protected GuiScreen buildChildScreen()
{
    List<IConfigElement> list = new ArrayList<IConfigElement>();
    
    list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", 
            AddModOverrideEntry.class));
    for (ConfigCategory cc : ForgeChunkManager.getModCategories())
        list.add(new ConfigElement(cc));
    
    return new GuiConfig(this.owningScreen, list, this.owningScreen.modID,
            this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
            this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, 
            I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig"));
}
 
Example 21
Project: ThermalRecycling   File: ScrappingTables.java   View source code 6 votes vote down vote up
private static void processTables(final String prefix, final Matrix2D<ItemStackWeightTable> weightTables, final JarConfiguration config) {
	for (final ScrapValue sv : ScrapValue.values())
		for (int i = 0; i < UPGRADE_NAMES.length; i++) {
			
			final String category = prefix + "_" + sv.name() + "_" + UPGRADE_NAMES[i];
			
			final ConfigCategory cc = config.getCategory(category);
			if(cc != null && !cc.isEmpty()) {
				
				final ItemStackWeightTable table = new ItemStackWeightTable();
				for(final Entry<String, Property> e: cc.getValues().entrySet()) {
					final ItemStackItem item = getItemStackItem(table, e);
					if(item != null)
						table.add(item);
				}
				weightTables.set(sv.ordinal(), i, table);
			}
		}
}
 
Example 22
Project: ThermalRecycling   File: JarConfiguration.java   View source code 6 votes vote down vote up
public void removeCategory(final ConfigCategory category)
{
    for (final ConfigCategory child : category.getChildren())
    {
        removeCategory(child);
    }

    if (categories.containsKey(category.getQualifiedName()))
    {
        categories.remove(category.getQualifiedName());
        if (category.parent != null)
        {
            category.parent.removeChild(category);
        }
        changed = true;
    }
}
 
Example 23
Project: ThermalRecycling   File: JarConfiguration.java   View source code 6 votes vote down vote up
public boolean hasChanged()
{
    if (changed) return true;
    
    for (final ConfigCategory cat : categories.values())
    {
        if (cat.hasChanged()) return true;
    }

    for (final JarConfiguration child : children.values())
    {
        if (child.hasChanged()) return true;
    }

    return false;
}
 
Example 24
Project: ThermalRecycling   File: JarConfiguration.java   View source code 6 votes vote down vote up
/**
 * 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()));
        }
}
 
Example 25
Project: BigTrees   File: BiomeConfiguration.java   View source code 6 votes vote down vote up
private void handleTreePopulation(ConfigCategory treePopulationCategory) {
	for (ConfigCategory treeConfig: treePopulationCategory.getChildren()) {
		String treeName = treeConfig.getName();
		
		int percentageChancePerChunk = 0;
		int treesPerChunk = 0;
		for (Entry<String, Property> entry : treeConfig.entrySet()) {
			if (entry.getKey().equals(Population.PercentageChancePerTreeConfigKey)) {
				percentageChancePerChunk = entry.getValue().getInt();
			}
			else if (entry.getKey().equals(Population.TreesPerChunkConfigKey)) {
				treesPerChunk = entry.getValue().getInt();
			}
		}
		
		Population population = new Population(percentageChancePerChunk, treesPerChunk);
		
		treePopulation.put(KTreeCfgTrees.getTreeConfiguration(treeName), population);
	}
}
 
Example 26
Project: BigTrees   File: BiomeConfiguration.java   View source code 6 votes vote down vote up
private void handleBiometypes(ConfigCategory child) {
	for(Entry<String, Property> entry : child.entrySet()) {
		Property property = entry.getValue();
		String propertyName = property.getName();
		
		if (propertyName.toLowerCase().equalsIgnoreCase("Included")) {
			includedBiomeTypes = toBiomeTypes(property.getStringList());
		} else if (propertyName.equalsIgnoreCase("Excluded")) {
			excludedBiomeTypes = toBiomeTypes(property.getStringList());
		} else if (propertyName.equalsIgnoreCase("Specific")) {
			for (String specificBiomeName : property.getStringList()) {
				specificBiomes.add(specificBiomeName.toLowerCase());
			}
		} else {
			FMLLog.getLogger().warn("Skipping biome configuration due to unknown property name '%s'", propertyName);
		}
	}
}
 
Example 27
Project: BigTrees   File: KTreeCfgBiomes.java   View source code 6 votes vote down vote up
private static void loadGeneralSettings(Configuration config) {
	ConfigCategory generalSettings = config.getCategory("general");
	
	for(Map.Entry<String, Property> entry : generalSettings.entrySet()) {
		String key = entry.getKey();
		Property property = entry.getValue();
		
		if (key.equals("Enable roots")) {
			KTreeCfg.rootsEnable = property.getBoolean();
		}
		else if (key.equals("Enabled dimension ids")) {
			KTreeCfg.enabledDimensionIds = toSet(property.getIntList());
		}
		else if (key.equals("Disabled dimension ids")) {
			KTreeCfg.disabledDimensionIds = toSet(property.getIntList());
		}
	}
}
 
Example 28
Project: TickDynamic   File: ListManager.java   View source code 6 votes vote down vote up
private void loadLocalGroups() {
	//Add local groups from config
	ConfigCategory config = mod.getWorldConfigCategory(world);
	Iterator<ConfigCategory> localIt;
	for(localIt = config.getChildren().iterator(); localIt.hasNext(); )
	{
		ConfigCategory localGroupCategory = localIt.next();
		String name = localGroupCategory.getName();
		EntityGroup localGroup = mod.getWorldEntityGroup(world, name, entityType, true, true);
		if(localGroup.getGroupType() != entityType || localGroups.contains(localGroup))
			continue;

		if(mod.debug)
			System.out.println("Load local group: " + name);
		localGroups.add(localGroup);
		localGroup.list = this;
	}
}
 
Example 29
Project: TickDynamic   File: ListManager.java   View source code 6 votes vote down vote up
private void loadGlobalGroups() {
	ConfigCategory config = mod.config.getCategory("groups");
	Iterator<ConfigCategory> globalIt;
	for(globalIt = config.getChildren().iterator(); globalIt.hasNext(); )
	{
		ConfigCategory groupCategory = globalIt.next();
		String name = groupCategory.getName();
		EntityGroup globalGroup = mod.getEntityGroup("groups." + name);

		if(globalGroup == null || globalGroup.getGroupType() != entityType)
			continue;

		//Get or create the local group as a copy of the global, but without a world config entry.
		//Will inherit config from the global group.
		EntityGroup localGroup = mod.getWorldEntityGroup(world, name, entityType, true, false);
		if(localGroups.contains(localGroup))
			continue; //Local group already defined

		if(mod.debug)
			System.out.println("Load global group: " + name);
		localGroups.add(localGroup);
		localGroup.list = this;
	}
}
 
Example 30
Project: GlobalGameRules   File: GGRConfig.java   View source code 6 votes vote down vote up
private void setValueToProp(ConfigCategory cat, HashMap<String, Value> list) {
    list.forEach((s, value) -> {
        if (cat.containsKey(s))
            cat.put(s,
                value.getType().equals(ValueType.BOOLEAN) ?
                        cat.get(s).setValue(value.getBooleanValue())
                                .setRequiresWorldRestart(value.getRequireWorldRestart())
                                .setShowInGui(value.getShowInGui()) :
                        value.getType().equals(ValueType.INTEGER) ?
                                cat.get(s).setValue(value.getIntegerValue())
                                        .setRequiresWorldRestart(value.getRequireWorldRestart())
                                        .setShowInGui(value.getShowInGui()) :
                                cat.get(s).setValue(value.getStringValue())
                                        .setRequiresWorldRestart(value.getRequireWorldRestart())
                                        .setShowInGui(value.getShowInGui())
            );
        else
            get(cat.getQualifiedName(), s, value.getStringValue(), "GameRule added by another mod or from commands")
                    .setRequiresWorldRestart(value.getRequireWorldRestart())
                    .setShowInGui(value.getShowInGui());
    });
}
 
Example 31
Project: XRay-Mod   File: ConfigHandler.java   View source code 6 votes vote down vote up
public static void setup(FMLPreInitializationEvent event ) {
	config = new Configuration( event.getSuggestedConfigurationFile() );
	config.load();
	XRay.currentDist = config.get(Configuration.CATEGORY_GENERAL, "searchdist", 0).getInt(); // Get our search distance.

	for( String category : config.getCategoryNames() ) // Iterate through each category in our config file.
	{
		ConfigCategory cat = config.getCategory( category );

		if( category.startsWith("ores.") )
		{
			String name = cat.get("name").getString();
			int id = cat.get("id").getInt();
			int meta = cat.get("meta").getInt();
			int[] color = {cat.get("red").getInt(), cat.get("green").getInt(), cat.get("blue").getInt()};
			boolean enabled = cat.get("enabled").getBoolean(false);

			XRay.searchList.add( new OreInfo( name, name.replaceAll("\\s+", ""), id, meta, color, enabled ) );
		}
	}

	config.save();
}
 
Example 32
Project: notenoughwands   File: MovingWand.java   View source code 6 votes vote down vote up
@Override
public void initConfig(Configuration cfg) {
    super.initConfig(cfg);
    maxHardness = (float) cfg.get(Config.CATEGORY_WANDS, getUnlocalizedName() + "_maxHardness", maxHardness, "Max hardness this block can move.)").getDouble();
    placeDistance = cfg.get(Config.CATEGORY_WANDS, getUnlocalizedName() + "_placeDistance", placeDistance, "Distance at which to place blocks in 'in-air' mode").getInt();

    ConfigCategory category = cfg.getCategory(Config.CATEGORY_MOVINGBLACKLIST);
    if (category.isEmpty()) {
        // Initialize with defaults
        blacklist(cfg, "tile.shieldBlock");
        blacklist(cfg, "tile.shieldBlock2");
        blacklist(cfg, "tile.shieldBlock3");
        blacklist(cfg, "tile.solidShieldBlock");
        blacklist(cfg, "tile.invisibleShieldBlock");
        setCost(cfg, "tile.mobSpawner", 5.0);
        setCost(cfg, "tile.blockAiry", 20.0);
    } else {
        for (Map.Entry<String, Property> entry : category.entrySet()) {
            blacklisted.put(entry.getKey(), entry.getValue().getDouble());
        }
    }
}
 
Example 33
Project: minema   File: MinemaConfigGui.java   View source code 6 votes vote down vote up
private static List<IConfigElement> getConfigElements(Configuration config) {
    // map config elements to their categories, except for CATEGORY_GENERAL
    List<IConfigElement> list = config.getCategoryNames().stream()
        .filter(catName -> !catName.equals(Configuration.CATEGORY_GENERAL))
        .map(catName -> new ConfigElement(config.getCategory(catName)))
        .collect(Collectors.toList());

    // add props in CATEGORY_GENERAL directly to the root of the list
    if (config.hasCategory(Configuration.CATEGORY_GENERAL)) {
        ConfigCategory catGeneral = config.getCategory(Configuration.CATEGORY_GENERAL);
        List<Property> props = catGeneral.getOrderedValues();            
        list.addAll(props.stream()
            .map(prop -> new ConfigElement(prop))
            .collect(Collectors.toList())
        );
    }

    return list;
}
 
Example 34
Project: ClicketyClack   File: KeyFilterConfig.java   View source code 6 votes vote down vote up
public static IConfigElement createConfigurationCategory(Configuration config) {
    final Property property = getProperty(config);

    final TIntSet values = new TIntHashSet(property.getIntList());

    final List<IConfigElement> filterList = Lists.newArrayList();

    for (int keyCode = 0; keyCode < Keyboard.KEYBOARD_SIZE; keyCode++) {
        final String keyName = Keyboard.getKeyName(keyCode);
        if (keyName != null)
            filterList.add(new FlagArrayElement(property, values, keyCode, keyName));
    }

    final ConfigCategory category = config.getCategory(ConfigValues.CATEGORY_KEY_FILTER);
    return new DummyCategoryElement(category.getName(), category.getLanguagekey(), filterList);
}
 
Example 35
Project: Cauldron   File: ForgeGuiFactory.java   View source code 6 votes vote down vote up
/**
 * This method is called in the constructor and is used to set the childScreen field.
 */
@Override
protected GuiScreen buildChildScreen()
{
    List<IConfigElement> list = new ArrayList<IConfigElement>();
    
    list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", 
            AddModOverrideEntry.class));
    for (ConfigCategory cc : ForgeChunkManager.getModCategories())
        list.add(new ConfigElement(cc));
    
    return new GuiConfig(this.owningScreen, list, this.owningScreen.modID,
            this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
            this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, 
            I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig"));
}
 
Example 36
Project: Cauldron   File: ForgeGuiFactory.java   View source code 6 votes vote down vote up
/**
 * This method is called in the constructor and is used to set the childScreen field.
 */
@Override
protected GuiScreen buildChildScreen()
{
    List<IConfigElement> list = new ArrayList<IConfigElement>();
    
    list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", 
            AddModOverrideEntry.class));
    for (ConfigCategory cc : ForgeChunkManager.getModCategories())
        list.add(new ConfigElement(cc));
    
    return new GuiConfig(this.owningScreen, list, this.owningScreen.modID,
            this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
            this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, 
            I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig"));
}
 
Example 37
Project: Cauldron   File: ForgeGuiFactory.java   View source code 6 votes vote down vote up
/**
 * This method is called in the constructor and is used to set the childScreen field.
 */
@Override
protected GuiScreen buildChildScreen()
{
    List<IConfigElement> list = new ArrayList<IConfigElement>();
    
    list.add(new DummyCategoryElement("addForgeChunkLoadingModCfg", "forge.configgui.ctgy.forgeChunkLoadingAddModConfig", 
            AddModOverrideEntry.class));
    for (ConfigCategory cc : ForgeChunkManager.getModCategories())
        list.add(new ConfigElement(cc));
    
    return new GuiConfig(this.owningScreen, list, this.owningScreen.modID,
            this.configElement.requiresWorldRestart() || this.owningScreen.allRequireWorldRestart,
            this.configElement.requiresMcRestart() || this.owningScreen.allRequireMcRestart, this.owningScreen.title, 
            I18n.format("forge.configgui.ctgy.forgeChunkLoadingModConfig"));
}
 
Example 38
Project: MyEssentials-Core   File: ConfigTemplate.java   View source code 6 votes vote down vote up
/**
 * 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();
}
 
Example 39
Project: TwinTails   File: TwinTailsCommonProxy.java   View source code 6 votes vote down vote up
@Override
protected void registerConfig() {
	addConfigManager(new FileConfigManagerBuilder()
			.setFileName("twintails.cfg")
			.setDesc("TwinTails Configuration")
			.addCategory("general")
			.addValue("TwinTailsEffects", "false", Type.BOOLEAN,
					"Enable to get effects while wearing certain twintails", new Consumer<Property>() {
						@Override
						public void accept(Property property) {
							ItemHairBand.twinTailsEffects = property.getBoolean();
						}
					})
			.endCategory()
			.Update(new Consumer<Configuration>() {
				@Override
				public void accept(Configuration configuration) {
					ConfigCategory gralCat = configuration.getCategory("general");
					if (gralCat.containsKey("VersionCheck"))
						gralCat.remove("VersionCheck");
					if (gralCat.containsKey("VersionLatest"))
						gralCat.remove("VersionLatest");
				}
			}));
}
 
Example 40
Project: endernet   File: EnderNet.java   View source code 6 votes vote down vote up
private void startServerManager() {
	Property globalPermissions = config.get("comm", "globalPermissions", "");
	Property undefinedPermissions = config.get("comm", "undefinedReceivePermissions", "");
	servers = new EnderServerManager(globalPermissions.getString(), undefinedPermissions.getString());
	reloadServerFile();
	
	ConfigCategory serverC = config.getCategory("servers");
       serverC.setComment("List servers in S:name=ip form, see endernet-servers.json for more detailed config");
       for(String name: serverC.keySet()) {
           	if(servers.get(name) != null) continue;
               EnderServer es = new EnderServer(name, serverC.get(name).getString());
               servers.add(es);
       }
       
       saveServerFile();
}