Class ItemSetting<T>

java.lang.Object
io.github.thebusybiscuit.slimefun4.api.items.ItemSetting<T>
Type Parameters:
T - The type of data stored under this ItemSetting
Direct Known Subclasses:
DoubleRangeSetting, EnumSetting, GoldPanDrop, IntRangeSetting, MaterialTagSetting, TalismanEnchantment

public class ItemSetting<T> extends Object
This class represents a Setting for a SlimefunItem that can be modified via the Items.yml Config file.
Author:
TheBusyBiscuit
  • Constructor Details

    • ItemSetting

      @ParametersAreNonnullByDefault public ItemSetting(SlimefunItem item, String key, T defaultValue)
      This creates a new ItemSetting with the given key and default value
      Parameters:
      item - The SlimefunItem this ItemSetting belongs to
      key - The key under which this setting will be stored (relative to the SlimefunItem)
      defaultValue - The default value for this ItemSetting
  • Method Details

    • validateInput

      public boolean validateInput(T input)
      This method checks if a given input would be valid as a value for this ItemSetting. 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

      public void update(@Nonnull T newValue)
      This method updates this ItemSetting 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 this ItemSetting
    • getKey

      @Nonnull public String getKey()
      This returns the key of this ItemSetting.
      Returns:
      The key under which this setting is stored (relative to the SlimefunItem)
    • getItem

      @Nonnull protected SlimefunItem getItem()
      This returns the associated SlimefunItem for this ItemSetting.
      Returns:
      The associated SlimefunItem
    • getValue

      @Nonnull public T getValue()
      This returns the current value of this ItemSetting.
      Returns:
      The current value
    • getDefaultValue

      @Nonnull public T getDefaultValue()
      This returns the default value of this ItemSetting.
      Returns:
      The default value
    • isType

      public boolean isType(@Nonnull Class<?> c)
      This method checks if this ItemSetting 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

      @Nonnull protected String 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()
      This method is called by a SlimefunItem which wants to load its ItemSetting from the Config file.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object