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:
GoldPan.GoldPanDrop
,MagicianTalisman.TalismanEnchantment
public class ItemSetting<T> extends Object
This class represents a Setting for aSlimefunItem
that can be modified via theItems.yml
Config
file.- Author:
- TheBusyBiscuit
-
-
Constructor Summary
Constructors Constructor Description ItemSetting(String key, T defaultValue)
This creates a newItemSetting
with the given key and default value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getDefaultValue()
This returns the default value of thisItemSetting
.String
getKey()
This returns the key of thisItemSetting
.T
getValue()
This returns the current value of thisItemSetting
.boolean
isType(Class<?> c)
This method checks if thisItemSetting
stores the given data type.void
load(SlimefunItem item)
void
update(T newValue)
This method updates thisItemSetting
with the given value.
-
-
-
Constructor Detail
-
ItemSetting
public ItemSetting(String key, T defaultValue)
This creates a newItemSetting
with the given key and default value- Parameters:
key
- The key under which this setting will be stored (relative to theSlimefunItem
)defaultValue
- The default value for thisItemSetting
-
-
Method Detail
-
update
public void update(T newValue)
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
public String getKey()
This returns the key of thisItemSetting
.- Returns:
- The key under which this setting is stored (relative to the
SlimefunItem
)
-
getValue
public T getValue()
This returns the current value of thisItemSetting
.- Returns:
- The current value
-
getDefaultValue
public T getDefaultValue()
This returns the default value of thisItemSetting
.- Returns:
- The default value
-
isType
public boolean isType(Class<?> c)
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
-
load
public void load(SlimefunItem item)
- Parameters:
item
- TheSlimefunItem
who called this method
-
-