Java 类net.minecraftforge.common.config.Property 实例源码
项目:ProgressiveDifficulty
文件:PotionCloudModifier.java
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));
}
}
项目:harshencastle
文件:BaseConfig.java
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;
}
项目:creativezone
文件:CreativeZoneMod.java
@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();
}
项目:TRAPPIST-1
文件:TPBiomeConfig.java
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.");
}
}
项目:TRAPPIST-1
文件:TPDimensionConfig.java
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.");
}
}
项目:VoidApi
文件:SerializableConfig.java
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;
}
项目:ItemZoom
文件:Config.java
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();
}
}
}
}
项目:GlobalXP
文件:Config.java
/**
* 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();
}
项目:AuthlibLoginHelper
文件:AuthlibLoginHelperGuiFactory.java
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);
}
}
}
}
项目:AuthlibLoginHelper
文件:AuthlibLoginHelperGuiFactory.java
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();
}
项目:Lector
文件:GeneralConfiguration.java
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());
}
}
}
项目:TFCPrimitiveTech
文件:ModOptions.java
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;
}
项目:TFCPrimitiveTech
文件:ModOptions.java
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;
}
项目:TFCPrimitiveTech
文件:ModOptions.java
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;
}
项目:CustomWorldGen
文件:ForgeChunkManager.java
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();
}
}
项目:Device-Mod-Apps
文件:ModConfig.java
public static void initConfig(File configFile) { // Gets called from preInit
try {
// Ensure that the config file exists
if (!configFile.exists()) configFile.createNewFile();
// Create the config object
config = new Configuration(configFile);
// Load config
config.load();
// Read props from config
Property debugModeProp = config.get(Configuration.CATEGORY_GENERAL, // What category will it be saved to, can be any string
"debug_mode", // Property name
"false", // Default value
"Enable the debug mode (useful for reporting issues)"); // Comment
DEBUG_MODE = debugModeProp.getBoolean(); // Get the boolean value, also set the property value to boolean
} catch (Exception e) {
// Failed reading/writing, just continue
} finally {
// Save props to config IF config changed
if (config.hasChanged()) config.save();
}
}
项目:muon
文件:MuonConfig.java
public static void loadFile(File file) {
FMLLog.info("[Muon] %s", "Loading config from "+file.getName());
// Sets up a new config
config = new Configuration(file);
config.load();
config.setCategoryComment(CATEGORY_GENERATION, "Options controlling generation of new villages.\nThese only take effect as new chunks are generated.");
properties.put("enable_new_by_default", config.get(CATEGORY_GENERATION, "enable_new_by_default", false, "Enable features of new versions by default"));
properties.put("fix_buried_doors", config.get(CATEGORY_GENERATION, "fix_buried_doors", true, "Align village buildings with the path only"));
properties.put("better_paths", config.get(CATEGORY_GENERATION, "better_paths", true, "Use alternate function for creating village paths"));
properties.put("smooth_village_terrain", config.get(CATEGORY_GENERATION, "smooth_village_terrain", true, "Smooth terrain within village boundaries"));
properties.put("fix_scattered_features", config.get(CATEGORY_GENERATION, "fix_scattered_features", true, "Ensure scattered features (e.g. Desert temples and Igloos) are accessible."));
int village_grove_frequency_default = 0;
if (getBoolean("enable_new_by_default")) {
if (!config.hasKey(CATEGORY_GENERATION, "village_grove_frequency")) {
village_grove_frequency_default = 100;
}
}
Property village_grove_frequency = config.get(CATEGORY_GENERATION, "village_grove_frequency", village_grove_frequency_default, "Add stands of trees to villages.");
village_grove_frequency.setMinValue(0);
village_grove_frequency.setMaxValue(100);
properties.put("village_grove_frequency", village_grove_frequency);
// write out default config if necessary
config.save();
}
项目:TRHS_Club_Mod_2016
文件:ForgeChunkManager.java
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();
}
}
项目:EnchantmentRevealer
文件:EnchantmentRevealer.java
@EventHandler
public void init(FMLPreInitializationEvent event)
{
Configuration config = new Configuration(new File(event.getModConfigurationDirectory(), NAME + ".cfg"));
config.load();
Property prop = config.get(Configuration.CATEGORY_CLIENT, "verboseDebug", false,
"If true, verbose debugging will be written to the log.");
verbose = prop.getBoolean();
if (verbose) {
out = System.out;
}
prop = config.get(Configuration.CATEGORY_GENERAL, "enableCommand", false,
"If true, the /xpseed command will be enabled, allowing you to retrieve "
+ "and set players' enchantment seeds directly.");
enableCommand = prop.getBoolean();
if (config.hasChanged()) {
config.save();
}
EnchantmentRevealer.out.println("EnchantmentRevealer initialized.");
MinecraftForge.EVENT_BUS.register(events);
}
项目:TerraFirmaProgressivePack
文件:TFCPPOptions.java
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("[" + TFCPPDetails.ModName + "] Error while trying to add Integer, config wasn't loaded properly!");
}
return value;
}
项目:Geographicraft
文件:Settings.java
public void setValue(Property inFile) {
Type oldValue = value();
set = inFile.wasRead();
if (set) {
try {
value = dataFrom(inFile);
} catch (NullPointerException e) {
value = value();
}
} else {
value = value();
}
if ((oldValue ==null&&value()!=null)) {
//ConfigManager.logger.info("updating null to "+value().toString());
update(value());
} else {
if (!oldValue.equals(value())) {
//ConfigManager.logger.info("updating "+this.key+ " to "+value().toString());
update(value());
}
}
}
项目:InspiringWorld
文件:ConfigDelegate.java
private Property.Type parseType(PrimitiveType primitiveType)
{
Property.Type propType = null;
switch (primitiveType)
{
case BOOL:
propType = Property.Type.BOOLEAN;
break;
case BYTE:
case SHORT:
case INT:
case LONG:
propType = Property.Type.INTEGER;
break;
case FLOAT:
case DOUBLE:
propType = Property.Type.DOUBLE;
break;
}
return propType;
}
项目:Survivalist
文件:ConfigurationCondition.java
@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;
}
项目:BIGB
文件:Settings.java
public void setValue(Property inFile) {
Type oldValue = value();
set = inFile.wasRead();
if (set) {
value = dataFrom(inFile);
} else {
value = defaultValue;
}
if ((oldValue ==null&&value()!=null)) {
ConfigManager.logger.info("updating null to "+value().toString());
update(value());
} else {
if (!oldValue.equals(value())) {
ConfigManager.logger.info("updating "+this.key+ " to "+value().toString());
update(value());
}
}
}
项目:TerraFirmaProgressivePack
文件:TFCPPOptions.java
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("[" + TFCPPDetails.ModName + "] Error while trying to add Double, config wasn't loaded properly!");
}
return value;
}
项目:Enderthing
文件:Enderthing.java
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
logger = event.getModLog();
config = new Configuration(event.getSuggestedConfigurationFile());
Property breakChest = config.get("Balance", "BreakChestOnHarvest", true);
if (!breakChest.wasRead())
config.save();
else
breakChestOnHarvest = breakChest.getBoolean();
registerTileEntities();
NetworkRegistry.INSTANCE.registerGuiHandler(this, guiHandler);
channel = NetworkRegistry.INSTANCE.newSimpleChannel(CHANNEL);
int messageNumber = 0;
channel.registerMessage(UpdatePlayersUsing.Handler.class, UpdatePlayersUsing.class, messageNumber++, Side.CLIENT);
logger.debug("Final message number: " + messageNumber);
proxy.preInit();
}
项目:Survivalist
文件:ConfigManager.java
public double getAxeLevelMultiplier(int axeLevel)
{
if (axeLevelMap.containsKey(axeLevel))
return axeLevelMap.get(axeLevel);
double value = 1 + axeLevel;
if (axeMultipliers != null)
{
Property p = axeMultipliers.get("AxeLevel" + axeLevel);
if (p != null && p.wasRead())
{
value = p.getDouble();
}
}
axeLevelMap.put(axeLevel, value);
return value;
}
项目:TFCTech
文件:ModOptions.java
public static int getIntFor(Configuration config, String heading, String item, int value, int minValue, int maxValue, String comment) {
if (config == null)
return value;
try {
Property prop = config.get(heading, item, value);
prop.comment = comment + " [range: " + minValue + " ~ " + maxValue + ", default: " + value + "]";
prop.setMinValue(minValue);
prop.setMaxValue(maxValue);
if (prop.getInt(value) < minValue || prop.getInt(value) > maxValue) {
TFCTech.LOG.info("An invalid value has been entered for " + item
+ " in the config file. Reverting to the default value.");
prop.set(value);
return value;
}
return prop.getInt(value);
} catch (Exception e) {
TFCTech.LOG.error("Error while trying to add Integer, config wasn't loaded properly!");
}
return value;
}
项目:HeroUtils
文件:ConfigAccessor.java
public static Property getOption(EMod mod, String name) {
if (mods.containsKey(mod)) {
return mods.get(mod).getOption(name);
} else {
return null;
}
}
项目:HeroUtils
文件:ConfigAccessor.java
public static boolean getBoolean(EMod mod, String name, boolean defaultBoolean) {
Property prop = getOption(mod, name);
if (prop == null) {
return defaultBoolean;
} else {
return prop.getBoolean(defaultBoolean);
}
}
项目:harshencastle
文件:BaseEnabledConfig.java
@Override
public void read() {
for(T componant: allComponants)
{
if(!testIfLegit(componant))
{
continue;
}
Property property = config.get(CATEGORY, getComponantPathInConfig(componant), true);
property.setComment(new TextComponentTranslation("config.isEnabled", getComponantCommentName(componant)).getUnformattedText());
enabledMap.put(componant, property.getBoolean());
}
}
项目:j6502
文件:MainClass.java
private static int[] getTierBasedIntList(Configuration cfg, String name, String category, int[] def, String comment) {
Property prop = cfg.get(category, name, def, comment);
int[] ret = prop.getIntList();
if(ret == null || ret.length < 3) {
ret = def;
prop.set(ret);
}
return ret;
}
项目:TRAPPIST-1
文件:TPBiomeConfig.java
public static int getIntegerConfigNode(Configuration conf, Property prop, List<String> propOrder, String category, String key, String discription, int defaultInt) {
int out;
prop = conf.get(category, key, defaultInt);
prop.comment = discription;
prop.setLanguageKey("gc.configgui.dimensionIDMars").setRequiresMcRestart(true);
out = prop.getInt();
propOrder.add(prop.getName());
return out;
}
项目:TRAPPIST-1
文件:TPDimensionConfig.java
public static int getIntegerConfigNode(Configuration conf, Property prop, List<String> propOrder, String category, String key, String discription, int defaultInt) {
int out;
prop = conf.get(category, key, defaultInt);
prop.comment = discription;
prop.setLanguageKey("gc.configgui.dimensionIDMars").setRequiresMcRestart(true);
out = prop.getInt();
propOrder.add(prop.getName());
return out;
}
项目:VoidApi
文件:SerializableConfig.java
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);
}
}
项目:Genesis
文件:Config.java
private static void syncConfig() {
Property prop;
prop = config.get(Configuration.CATEGORY_GENERAL, "dimensionId", 37);
prop.setComment("ID for the dimension used by Genesis");
prop.setRequiresMcRestart(true);
prop.setLanguageKey("genesis.configgui.dimension_id");
dimensionId = prop.getInt();
if (config.hasChanged()) {
config.save();
}
}
项目:EmergentVillages
文件:ConfigHandler.java
public static void handleConfig(Configuration config){
Property current;
int chunkRange; double maxSpawnTime;
String[] dimensionArray = {"0"};
config.load();
current = config.get(Configuration.CATEGORY_GENERAL, "Logging", false);
current.setComment("Enable this to receive server messages whenever a villager tries to spawn. Default false.");
LOGGING = current.getBoolean();
current = config.get("SpawnValues", "Chunk check range", 2);
current.setComment("This is the range in chunks from each player that Emergent Villages checks for valid spawn positions. Default 2.");
chunkRange = current.getInt();
current = config.get("SpawnValues", "Inhabited time for maximum spawn chance", 3600000.0d);
current.setComment("This is the time in ticks at which the spawn chance for a villager for any given chunk is 100%. Minecraft increments this timer for each player "
+ "in a chunk once per tick. Increase this value for a slower spawn rate, and decrease it for a faster spawn rate. "
+ "Default 3600000.0f.");
maxSpawnTime = current.getDouble();
current = config.get(Configuration.CATEGORY_GENERAL, "Max villagers per chunk", 1);
current.setComment("This is the maximum amount of villagers that Emergent Villages spawns per chunk. Default 1.");
SpawnHandler.initConfig(chunkRange, current.getInt(), maxSpawnTime);
current = config.get(Configuration.CATEGORY_GENERAL , "Dimensions", dimensionArray);
current.setComment("These are the dimensions that Emergent Villages will spawn villagers in. Default 0 (Overworld).");
dimensionArray = current.getStringList();
current = config.get(Configuration.CATEGORY_GENERAL, "Tick speed", 600);
current.setComment("This is the amount of time that Emergent Villages waits between checks. Minecraft ticks 20 times per second. Higher numbers means that even if "
+ "the regional difficulty is high it will take a while to spawn villagers, but the impact on the server will be low. Lower numbers means villagers spawn "
+ "faster, up to the limit, but there will be a performance hit. Default 600.");
TickHandler.initConfig(current.getInt(), dimensionArray);
config.save();
}
项目:VanillaExtras
文件:VExConfig.java
private static void syncConfig(boolean loadFromConfigFile, boolean readFieldsFromConfig) {
if (loadFromConfigFile)
config.load();
Property propertyMachineCooldownBasic = config.get(CATEGORY_NAME_BLOCKS, "machine_cooldown_basic", 100);
propertyMachineCooldownBasic.setLanguageKey("gui.config.blocks.machine_cooldown_basic.name");
propertyMachineCooldownBasic.setComment(I18n.format("gui.config.blocks.machine_cooldown_basic.comment"));
propertyMachineCooldownBasic.setMinValue(10);
propertyMachineCooldownBasic.setMaxValue(200);
Property propertyMachineCooldownAdvanced = config.get(CATEGORY_NAME_BLOCKS, "machine_cooldown_advanced", 50);
propertyMachineCooldownAdvanced.setLanguageKey("gui.config.blocks.machine_cooldown_advanced.name");
propertyMachineCooldownAdvanced.setComment(I18n.format("gui.config.blocks.machine_cooldown_advanced.comment"));
propertyMachineCooldownAdvanced.setMinValue(10);
propertyMachineCooldownAdvanced.setMaxValue(200);
List<String> propertyOrderBlocks = new ArrayList<String>();
propertyOrderBlocks.add(propertyMachineCooldownBasic.getName());
propertyOrderBlocks.add(propertyMachineCooldownAdvanced.getName());
config.setCategoryPropertyOrder(CATEGORY_NAME_BLOCKS, propertyOrderBlocks);
if (readFieldsFromConfig) {
machineCooldownBasic = propertyMachineCooldownBasic.getInt();
machineCooldownAdvanced = propertyMachineCooldownAdvanced.getInt();
}
propertyMachineCooldownBasic.set(machineCooldownBasic);
propertyMachineCooldownAdvanced.set(machineCooldownAdvanced);
if (config.hasChanged())
config.save();
}
项目:ItemZoom
文件:Config.java
public static void toggleEnabled() {
toggledEnabled = !toggledEnabled;
if (config != null) {
String configComment = I18n.format("config.itemzoom.toggle.enabled");
Property property = config.get(category, "toggled.enabled", true, configComment);
property.set(toggledEnabled);
if (config.hasChanged()) {
config.save();
}
}
}
项目:Mods
文件:SpinToWin.java
@SideOnly(Side.CLIENT)
public boolean addToBlacklist(ItemStack stack){
if(stack.useItemRightClick(Minecraft.getMinecraft().world, new EntityOtherPlayerMP(Minecraft.getMinecraft().world, new GameProfile(null, "fake")), EnumHand.MAIN_HAND).getType()!=EnumActionResult.PASS){
Property blackList=conf.get("config", "Blacklist items", new String[0]);
blackList.set(Arrays.copyOf(blackList.getStringList(),blackList.getStringList().length+1));
blackList.getStringList()[blackList.getStringList().length-1]=stack.getItem().getRegistryName().toString();
syncConfig();
return true;
}
return false;
}