本文整理汇总了Java中net.minecraftforge.common.config.ConfigCategory.put方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigCategory.put方法的具体用法?Java ConfigCategory.put怎么用?Java ConfigCategory.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.common.config.ConfigCategory
的用法示例。
在下文中一共展示了ConfigCategory.put方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
@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;
}
示例2: 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()));
}
}
示例3: 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();
}
示例4: serializeRecursive
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public void serializeRecursive(ConfigCategory categoryCurrent, Object toSerialize)
{
try
{
for (Field f : toSerialize.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))
{
categoryCurrent.put(f.getName(), new Property(f.getName(), f.get(toSerialize).toString(), fromJavaPrimitiveType(f.getType())));
}
else
{
boolean hasAdapter = false;
for (ConfigAdapter<Object> a : adapters)
{
if (a.accepts(f.get(toSerialize)))
{
a.serialize(f.get(toSerialize), new ConfigCategory(f.getName(), categoryCurrent));
hasAdapter = true;
break;
}
}
if (!hasAdapter)
{
serializeRecursive(new ConfigCategory(f.getName(), categoryCurrent), f.get(toSerialize));
}
}
}
}
}
catch (Exception ex)
{
VCLoggers.loggerErrors.log(LogLevel.Error, "Caught an exception trying to serialize a configuration file!", ex);
}
}
示例5: addConfigProperty
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public static void addConfigProperty(Object mod, String propertyName, String value, Property.Type type)
{
ModContainer container = getContainer(mod);
if (container != null)
{
ConfigCategory cat = config.getCategory(container.getModId());
Property prop = new Property(propertyName, value, type).setLanguageKey("forge.configgui." + propertyName);
if (type == Property.Type.INTEGER)
{
prop.setMinValue(0);
}
cat.put(propertyName, prop);
}
}
示例6: generateSoundList
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
protected void generateSoundList(final ConfigCategory cat) {
cat.setRequiresMcRestart(false);
cat.setRequiresWorldRestart(false);
final SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
final List<String> sounds = new ArrayList<String>();
for (final Object resource : handler.soundRegistry.getKeys())
sounds.add(resource.toString());
Collections.sort(sounds);
final SoundRegistry registry = RegistryManager.get(RegistryType.SOUND);
for (final String sound : sounds) {
final Property prop = new Property(sound, "", Property.Type.STRING);
prop.setDefaultValue("");
prop.setRequiresMcRestart(false);
prop.setRequiresWorldRestart(false);
prop.setConfigEntryClass(SoundConfigEntry.class);
final StringBuilder builder = new StringBuilder();
if (registry.isSoundBlocked(sound))
builder.append(GuiConstants.TOKEN_BLOCK).append(' ');
if (registry.isSoundCulled(sound))
builder.append(GuiConstants.TOKEN_CULL).append(' ');
final float v = registry.getVolumeScale(sound);
if (v != 1.0F)
builder.append((int) (v * 100F));
prop.setValue(builder.toString());
cat.put(sound, prop);
}
}
示例7: saveConfig
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
public void saveConfig() {
ConfigCategory cat = config.getCategory(CATEGORY_GENERAL);
Property prop = cat.get(REPLACE_KEY);
prop.setValue(ModItems.replaceRecipes);
cat.put(REPLACE_KEY, prop);
if (config.hasChanged())
config.save();
}
示例8: addBiomes
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
private static void addBiomes(String[] included, String[] excluded, ConfigCategory parent) {
ConfigCategory biomes = new ConfigCategory("biometypes", parent);
biomes.put("1", new Property("Included", included, Property.Type.STRING));
biomes.put("2", new Property("Excluded", excluded, Property.Type.STRING));
}
示例9: addOverriddenBiomes
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
private static void addOverriddenBiomes(String[] biomeNames, ConfigCategory parent) {
ConfigCategory biomes = new ConfigCategory("biometypes", parent);
biomes.put("1", new Property("Specific", biomeNames, Property.Type.STRING));
}
示例10: addPropertiesToCategory
import net.minecraftforge.common.config.ConfigCategory; //导入方法依赖的package包/类
private static void addPropertiesToCategory(ConfigCategory category, Property ... properties) {
int index = 1;
for (Property property : properties) {
category.put(Integer.toString(index++), property);
}
}