mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-14 04:09:09 +01:00
Now configuration doesn't ignores minimum and maximum values
This commit is contained in:
parent
efb642cefe
commit
c8ab72e550
6 changed files with 58 additions and 7 deletions
|
@ -25,23 +25,23 @@ public final class ConfigValues{
|
|||
|
||||
public static void defineConfigValues(Configuration config){
|
||||
for(ConfigIntValues currConf : ConfigIntValues.values()){
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getInt();
|
||||
currConf.initializeValue(config);
|
||||
}
|
||||
|
||||
for(ConfigDoubleValues currConf : ConfigDoubleValues.values()){
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc, currConf.min, currConf.max).getDouble();
|
||||
currConf.initializeValue(config);
|
||||
}
|
||||
|
||||
for(ConfigBoolValues currConf : ConfigBoolValues.values()){
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getBoolean();
|
||||
currConf.initializeValue(config);
|
||||
}
|
||||
|
||||
for(ConfigIntListValues currConf : ConfigIntListValues.values()){
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getIntList();
|
||||
currConf.initializeValue(config);
|
||||
}
|
||||
|
||||
for(ConfigStringListValues currConf : ConfigStringListValues.values()){
|
||||
currConf.currentValue = config.get(currConf.category, currConf.name, currConf.defaultValue, currConf.desc).getStringList();
|
||||
currConf.initializeValue(config);
|
||||
}
|
||||
|
||||
parseConfiguratorConfig();
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.config.values;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public enum ConfigBoolValues{
|
||||
|
||||
|
@ -72,6 +73,10 @@ public enum ConfigBoolValues{
|
|||
this.desc = desc;
|
||||
}
|
||||
|
||||
public void initializeValue(Configuration config){
|
||||
this.currentValue = config.get(this.category, this.name, this.defaultValue, this.desc).getBoolean();
|
||||
}
|
||||
|
||||
public boolean isEnabled(){
|
||||
return this.currentValue;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.config.values;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
public enum ConfigDoubleValues
|
||||
{
|
||||
|
@ -31,6 +33,22 @@ public enum ConfigDoubleValues
|
|||
this.desc = desc;
|
||||
}
|
||||
|
||||
public void initializeValue(Configuration config){
|
||||
Property property = config.get(this.category, this.name, this.defaultValue, this.desc, this.min, this.max);
|
||||
double value = property.getDouble();
|
||||
if (value < this.min)
|
||||
{
|
||||
value = this.min;
|
||||
property.set(this.min);
|
||||
}
|
||||
if (value > this.max)
|
||||
{
|
||||
value = this.max;
|
||||
property.set(this.max);
|
||||
}
|
||||
this.currentValue = value;
|
||||
}
|
||||
|
||||
public double getValue(){
|
||||
return this.currentValue;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.config.values;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public enum ConfigIntListValues{
|
||||
|
||||
|
@ -33,8 +34,12 @@ public enum ConfigIntListValues{
|
|||
this.desc = desc;
|
||||
}
|
||||
|
||||
public void initializeValue(Configuration config){
|
||||
this.currentValue = config.get(this.category, this.name, this.defaultValue, this.desc).getIntList();
|
||||
}
|
||||
|
||||
public int[] getValue(){
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
package de.ellpeck.actuallyadditions.mod.config.values;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
public enum ConfigIntValues{
|
||||
|
||||
|
@ -79,6 +81,22 @@ public enum ConfigIntValues{
|
|||
this.desc = desc;
|
||||
}
|
||||
|
||||
public void initializeValue(Configuration config){
|
||||
Property property = config.get(this.category, this.name, this.defaultValue, this.desc, this.min, this.max);
|
||||
int value = property.getInt();
|
||||
if (value < this.min)
|
||||
{
|
||||
value = this.min;
|
||||
property.set(this.min);
|
||||
}
|
||||
if (value > this.max)
|
||||
{
|
||||
value = this.max;
|
||||
property.set(this.max);
|
||||
}
|
||||
this.currentValue = value;
|
||||
}
|
||||
|
||||
public int getValue(){
|
||||
return this.currentValue;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
package de.ellpeck.actuallyadditions.mod.config.values;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.config.ConfigCategories;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
public enum ConfigStringListValues{
|
||||
|
||||
|
@ -41,8 +42,12 @@ public enum ConfigStringListValues{
|
|||
this.desc = desc;
|
||||
}
|
||||
|
||||
public void initializeValue(Configuration config){
|
||||
this.currentValue = config.get(this.category, this.name, this.defaultValue, this.desc).getStringList();
|
||||
}
|
||||
|
||||
public String[] getValue(){
|
||||
return this.currentValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue