Class ItemSetting<T>
java.lang.Object
io.github.thebusybiscuit.slimefun4.api.items.ItemSetting<T>
- Type Parameters:
T
- The type of data stored under thisItemSetting
- Direct Known Subclasses:
DoubleRangeSetting
,EnumSetting
,GoldPanDrop
,IntRangeSetting
,MaterialTagSetting
,TalismanEnchantment
This class represents a Setting for a
SlimefunItem
that can be modified via
the Items.yml
Config
file.- Author:
- TheBusyBiscuit
-
Constructor Summary
ConstructorDescriptionItemSetting
(SlimefunItem item, String key, T defaultValue) This creates a newItemSetting
with the given key and default value -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
This returns the default value of thisItemSetting
.protected String
This is an error message which should provide further context on what values are allowed.protected SlimefunItem
getItem()
This returns the associatedSlimefunItem
for thisItemSetting
.getKey()
This returns the key of thisItemSetting
.getValue()
This returns the current value of thisItemSetting
.final int
hashCode()
boolean
This method checks if thisItemSetting
stores the given data type.void
reload()
toString()
void
This method updates thisItemSetting
with the given value.boolean
validateInput
(T input) This method checks if a given input would be valid as a value for thisItemSetting
.
-
Constructor Details
-
ItemSetting
This creates a newItemSetting
with the given key and default value- Parameters:
item
- TheSlimefunItem
thisItemSetting
belongs tokey
- The key under which this setting will be stored (relative to theSlimefunItem
)defaultValue
- The default value for thisItemSetting
-
-
Method Details
-
validateInput
This method checks if a given input would be valid as a value for thisItemSetting
. You can override this method to implement your own checks.- Parameters:
input
- The input value to validate- Returns:
- Whether the given input was valid
-
update
This method updates thisItemSetting
with the given value. Override this method to catch changes of a value. A value may never be null.- Parameters:
newValue
- The new value for thisItemSetting
-
getKey
This returns the key of thisItemSetting
.- Returns:
- The key under which this setting is stored (relative to the
SlimefunItem
)
-
getItem
This returns the associatedSlimefunItem
for thisItemSetting
.- Returns:
- The associated
SlimefunItem
-
getValue
This returns the current value of thisItemSetting
.- Returns:
- The current value
-
getDefaultValue
This returns the default value of thisItemSetting
.- Returns:
- The default value
-
isType
This method checks if thisItemSetting
stores the given data type.- Parameters:
c
- The class of data type you want to compare- Returns:
- Whether this
ItemSetting
stores the given type
-
getErrorMessage
This is an error message which should provide further context on what values are allowed.- Returns:
- An error message which is displayed when this
ItemSetting
is misconfigured.
-
reload
public void reload() -
toString
-
hashCode
public final int hashCode() -
equals
-