Class ConfigValueImpl
- All Implemented Interfaces:
ConfigTag,ConfigValue
Created by covers1624 on 18/4/22.
-
Field Summary
Fields inherited from class codechicken.lib.config.AbstractConfigTag
comment, dirty, networkSynthetic, syncToClient -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopy(@Nullable ConfigCategoryImpl parent) booleanGets thebooleanvalue of this tag.booleanGets the defaultbooleanvalue of this tag.doubleGets the defaultdoublevalue of this tag.intGets the defaultintvalue stored as a Hex String of this tag.intGets the defaultintvalue of this tag.longGets the defaultlongvalue of this tag.Gets the defaultStringvalue of this tag.doubleGets thedoublevalue of this tag.intgetHex()Gets theintvalue stored as a Hex String of this tag.intgetInt()Gets theintvalue of this tag.longgetLong()Gets thelongvalue of this tag.@Nullable RestrictionGets theRestrictionpredicate for this tag.Gets theStringvalue of this tag.getType()Gets the type of theConfigValue.voidread(MCDataInput in) Read this tag from aMCDataInput.voidreset()Reset this tag back to the default.voidResets all network tags back to their original value.setBoolean(boolean value) Sets thebooleanvalue of this tag.setDefaultBoolean(boolean value) Sets the defaultbooleanvalue of this tag.setDefaultDouble(double value) Sets the defaultdoublevalue of this tag.setDefaultHex(int value) Sets the defaultintvalue represented as a hex String of this tag.setDefaultInt(int value) Sets the defaultintvalue of this tag.setDefaultLong(long value) Sets the defaultlongvalue of this tag.setDefaultString(String value) Sets the defaultStringvalue of this tag.setDefaultValue(Object value) setDouble(double value) Sets thedoublevalue of this tag.setHex(int value) Sets theintvalue represented as a hex String of this tag.setInt(int value) Sets theintvalue of this tag.voidsetKnownType(ValueType type) setLong(long value) Sets thelongvalue of this tag.setRestriction(Restriction restriction) Set theRestrictionfor thisConfigValue.Sets theStringvalue of this tag.voidwrite(MCDataOutput out) Write this tag to aMCDataOutput.Methods inherited from class codechicken.lib.config.AbstractConfigTag
clearDirty, copy, getComment, getName, getParent, isDirty, isNetworkTag, onSync, requiresClientSync, runSync, setComment, setComment, setComment, syncTagToClientMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface codechicken.lib.config.ConfigTag
copy, delete, forceSync, getComment, getDesc, getName, getParent, isDirty, isNetworkTag, requiresClientSync, runSync, saveMethods inherited from interface codechicken.lib.config.ConfigValue
onSync, setComment, setComment, setComment, syncTagToClient
-
Constructor Details
-
ConfigValueImpl
-
-
Method Details
-
getType
Description copied from interface:ConfigValueGets the type of theConfigValue.- Specified by:
getTypein interfaceConfigValue- Returns:
- The
ValueTypeof this tag.
-
getBoolean
public boolean getBoolean()Description copied from interface:ConfigValueGets thebooleanvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getBooleanin interfaceConfigValue- Returns:
- The boolean value or the default.
-
getString
Description copied from interface:ConfigValueGets theStringvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getStringin interfaceConfigValue- Returns:
- The String value or the default.
-
getInt
public int getInt()Description copied from interface:ConfigValueGets theintvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getIntin interfaceConfigValue- Returns:
- The int value or the default.
-
getLong
public long getLong()Description copied from interface:ConfigValueGets thelongvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getLongin interfaceConfigValue- Returns:
- The long value or the default.
-
getHex
public int getHex()Description copied from interface:ConfigValueGets theintvalue stored as a Hex String of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getHexin interfaceConfigValue- Returns:
- The int value or the default.
-
getDouble
public double getDouble()Description copied from interface:ConfigValueGets thedoublevalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDoublein interfaceConfigValue- Returns:
- The double value or the default.
-
setBoolean
Description copied from interface:ConfigValueSets thebooleanvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setBooleanin interfaceConfigValue- Parameters:
value- Thebooleanvalue.- Returns:
- The same
ConfigValue.
-
setString
Description copied from interface:ConfigValueSets theStringvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setStringin interfaceConfigValue- Parameters:
value- TheStringvalue.- Returns:
- The same
ConfigValue.
-
setInt
Description copied from interface:ConfigValueSets theintvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setIntin interfaceConfigValue- Parameters:
value- Theintvalue.- Returns:
- The same
ConfigValue.
-
setLong
Description copied from interface:ConfigValueSets thelongvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setLongin interfaceConfigValue- Parameters:
value- Thelongvalue.- Returns:
- The same
ConfigValue.
-
setHex
Description copied from interface:ConfigValueSets theintvalue represented as a hex String of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setHexin interfaceConfigValue- Parameters:
value- Theintvalue.- Returns:
- The same
ConfigValue.
-
setDouble
Description copied from interface:ConfigValueSets thedoublevalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDoublein interfaceConfigValue- Parameters:
value- Thedoublevalue.- Returns:
- The same
ConfigValue.
-
getDefaultBoolean
public boolean getDefaultBoolean()Description copied from interface:ConfigValueGets the defaultbooleanvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDefaultBooleanin interfaceConfigValue- Returns:
- The default boolean value.
-
getDefaultString
Description copied from interface:ConfigValueGets the defaultStringvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDefaultStringin interfaceConfigValue- Returns:
- The default
Stringvalue.
-
getDefaultInt
public int getDefaultInt()Description copied from interface:ConfigValueGets the defaultintvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDefaultIntin interfaceConfigValue- Returns:
- The default int value.
-
getDefaultLong
public long getDefaultLong()Description copied from interface:ConfigValueGets the defaultlongvalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDefaultLongin interfaceConfigValue- Returns:
- The default long value.
-
getDefaultHex
public int getDefaultHex()Description copied from interface:ConfigValueGets the defaultintvalue stored as a Hex String of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDefaultHexin interfaceConfigValue- Returns:
- The default int value.
-
getDefaultDouble
public double getDefaultDouble()Description copied from interface:ConfigValueGets the defaultdoublevalue of this tag.No attempt to convert between tag types is made, this must be called on a tag which has a non
ValueType.UNKNOWNtype.- Specified by:
getDefaultDoublein interfaceConfigValue- Returns:
- The default double value.
-
setDefaultBoolean
Description copied from interface:ConfigValueSets the defaultbooleanvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDefaultBooleanin interfaceConfigValue- Parameters:
value- Thebooleanvalue.- Returns:
- The same
ConfigValue.
-
setDefaultString
Description copied from interface:ConfigValueSets the defaultStringvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDefaultStringin interfaceConfigValue- Parameters:
value- TheStringvalue.- Returns:
- The same
ConfigValue.
-
setDefaultInt
Description copied from interface:ConfigValueSets the defaultintvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDefaultIntin interfaceConfigValue- Parameters:
value- Theintvalue.- Returns:
- The same
ConfigValue.
-
setDefaultLong
Description copied from interface:ConfigValueSets the defaultlongvalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDefaultLongin interfaceConfigValue- Parameters:
value- Thelongvalue.- Returns:
- The same
ConfigValue.
-
setDefaultHex
Description copied from interface:ConfigValueSets the defaultintvalue represented as a hex String of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDefaultHexin interfaceConfigValue- Parameters:
value- Theintvalue.- Returns:
- The same
ConfigValue.
-
setDefaultDouble
Description copied from interface:ConfigValueSets the defaultdoublevalue of this tag.If the tag has an
ValueType.UNKNOWNvalue type, this function will set it appropriately.- Specified by:
setDefaultDoublein interfaceConfigValue- Parameters:
value- Thedoublevalue.- Returns:
- The same
ConfigValue.
-
setRestriction
Description copied from interface:ConfigValueSet theRestrictionfor thisConfigValue.A restriction is just a
Predicate, and can be used for anything, but is most commonly used for int/float value ranges on tags.If the restriction is violated, either by the tag being loaded from disk, or via a set method, it will be reset to default.
TODO, in the future, provide a function to choose what to do when a value is invalid, allow the value to be altered (clamped), removed, or reset entirely to default. It is invalid for the restriction to not accept the tag's default value, if the restriction does not, it will throw an
IllegalArgumentExceptioneither when the restriction is set, or the default is set, whichever comes last.See
Restrictionfor more information.- Specified by:
setRestrictionin interfaceConfigValue- Parameters:
restriction- The restriction to set.- Returns:
- The same
ConfigValue. - See Also:
-
getRestriction
Description copied from interface:ConfigValueGets theRestrictionpredicate for this tag.- Specified by:
getRestrictionin interfaceConfigValue- Returns:
- The
Restriction
-
reset
public void reset()Description copied from interface:ConfigTagReset this tag back to the default.In the event that this is a
ConfigCategorysets all descendant values to their default. -
copy
- Specified by:
copyin classAbstractConfigTag<ConfigValue>
-
write
Description copied from interface:ConfigTagWrite this tag to aMCDataOutput. Only categories and/or tags which haveConfigTag.syncTagToClient()set will be written. -
read
Description copied from interface:ConfigTagRead this tag from aMCDataInput. All tags and values will be read and inserted into the tree.If a tag does not already exist in the tree, one will be added and marked as a 'network tag',
ConfigTag.isNetworkTag().All tags with a network value will be reset to default when
ConfigTag.resetFromNetwork()is called, whilst any 'network only' tags will be deleted. -
resetFromNetwork
public void resetFromNetwork()Description copied from interface:ConfigTagResets all network tags back to their original value.Whilst a tag is set from the network, it is effectively immutable and may not be set.
Any tags which are 'network only' are deleted during this operation.
- Specified by:
resetFromNetworkin interfaceConfigTag
-
setValue
-
setDefaultValue
-
getRawValue
-
setKnownType
-