Class DefaultValueData

java.lang.Object
ch.njol.skript.lang.parser.ParserInstance.Data
ch.njol.skript.lang.parser.DefaultValueData

public class DefaultValueData extends ParserInstance.Data
A Parser Data that stores custom default values that should be given preference over event-values and other traditional default values.
These do not apply to arithmetic or other dynamic default values, they're only supplied during parsing.
See Also:
  • SecCustomDefault for example usage
  • Constructor Details

    • DefaultValueData

      public DefaultValueData(ParserInstance parserInstance)
  • Method Details

    • addDefaultValue

      public <T> void addDefaultValue(Class<T> type, DefaultExpression<T> value)
      Sets the default value for type to value.
      Any custom default values should be removed after they go out of scope. It will not be done automatically.
      Type Parameters:
      T - The class of this value.
      Parameters:
      type - The class which this value applies to.
      value - The value to use.
      See Also:
    • getDefaultValue

      @Nullable public <T> @Nullable DefaultExpression<T> getDefaultValue(Class<T> type)
      Gets the default value for the given type.
      Type Parameters:
      T - The class of this value.
      Parameters:
      type - The class which this value applies to.
      Returns:
      The default value for type, or null if none is set.
    • removeDefaultValue

      public void removeDefaultValue(Class<?> type)
      Removes a default value from the data.
      Default values are handled using stacks, so be sure to remove only what you have added. Nothing more, nothing less.
      Parameters:
      type - Which class to remove the default value of.