Class ClassInfo<T>

java.lang.Object
ch.njol.skript.classes.ClassInfo<T>
Type Parameters:
T - The class this info is for
All Implemented Interfaces:
Debuggable
Direct Known Subclasses:
EnumClassInfo, RegistryClassInfo

public class ClassInfo<T> extends Object implements Debuggable
  • Field Details

    • NO_DOC

      public static final String NO_DOC
      Use this as name(String) to suppress warnings about missing documentation.
  • Constructor Details

    • ClassInfo

      public ClassInfo(Class<T> c, String codeName)
      Parameters:
      c - The class
      codeName - The name used in patterns
  • Method Details

    • isVaildCodeName

      @Deprecated public static boolean isVaildCodeName(String name)
      Deprecated.
      Incorrect spelling in method name. This will be removed in the future.
    • isValidCodeName

      public static boolean isValidCodeName(String name)
    • parser

      public ClassInfo<T> parser(Parser<? extends T> parser)
      Parameters:
      parser - A parser to parse values of this class or null if not applicable
    • cloner

      public ClassInfo<T> cloner(Cloner<T> cloner)
      Parameters:
      cloner - A Cloner to clone values when setting variables or passing function arguments.
    • user

      public ClassInfo<T> user(String... userInputPatterns) throws PatternSyntaxException
      Parameters:
      userInputPatterns - Regex patterns to match this class, e.g. in the expressions loop-[type], random [type] out of ..., or as command arguments. These patterns must be english and match singular and plural.
      Throws:
      PatternSyntaxException - If any of the patterns' syntaxes is invalid
    • defaultExpression

      public ClassInfo<T> defaultExpression(DefaultExpression<T> defaultExpression)
      Parameters:
      defaultExpression - The default (event) value of this class or null if not applicable
      See Also:
    • supplier

      public ClassInfo<T> supplier(Supplier<Iterator<T>> supplier)
      Used for dynamically getting all the possible values of a class
      Parameters:
      supplier - The supplier of the values
      Returns:
      This ClassInfo object
      See Also:
    • supplier

      public ClassInfo<T> supplier(T[] values)
      Used for getting all the possible constants of a class
      Parameters:
      values - The array of the values
      Returns:
      This ClassInfo object
      See Also:
    • serializer

      public ClassInfo<T> serializer(Serializer<? super T> serializer)
    • serializeAs

      public ClassInfo<T> serializeAs(Class<?> serializeAs)
    • changer

      @Deprecated public ClassInfo<T> changer(SerializableChanger<? super T> changer)
      Deprecated.
    • changer

      public ClassInfo<T> changer(Changer<? super T> changer)
    • math

      @Deprecated public <R> ClassInfo<T> math(Class<R> relativeType, Arithmetic<? super T,R> math)
      Deprecated.
    • name

      public ClassInfo<T> name(String name)
      Only used for Skript's documentation.
      Parameters:
      name -
      Returns:
      This ClassInfo object
    • description

      public ClassInfo<T> description(String... description)
      Only used for Skript's documentation.
      Parameters:
      description -
      Returns:
      This ClassInfo object
    • usage

      public ClassInfo<T> usage(String... usage)
      Only used for Skript's documentation.
      Parameters:
      usage -
      Returns:
      This ClassInfo object
    • examples

      public ClassInfo<T> examples(String... examples)
      Only used for Skript's documentation.
      Parameters:
      examples -
      Returns:
      This ClassInfo object
    • since

      public ClassInfo<T> since(String since)
      Only used for Skript's documentation.
      Parameters:
      since -
      Returns:
      This ClassInfo object
    • requiredPlugins

      public ClassInfo<T> requiredPlugins(String... pluginNames)
      Other plugin dependencies for this ClassInfo. Only used for Skript's documentation.
      Parameters:
      pluginNames -
      Returns:
      This ClassInfo object
    • documentationId

      public ClassInfo<T> documentationId(String id)
      Overrides default documentation id, which is assigned from class name. This is especially useful for inner classes whose names are useless without parent class name as a context.
      Parameters:
      id - Documentation id override.
      Returns:
      This ClassInfo object.
    • getC

      public Class<T> getC()
    • getName

      public Noun getName()
    • getCodeName

      public String getCodeName()
    • getDefaultExpression

      @Nullable public @Nullable DefaultExpression<T> getDefaultExpression()
    • getParser

      @Nullable public @Nullable Parser<? extends T> getParser()
    • getCloner

      @Nullable public @Nullable Cloner<? extends T> getCloner()
    • clone

      public T clone(T t)
      Clones the given object using cloner, returning the given object if no Cloner is registered.
    • getUserInputPatterns

      @Nullable public @Nullable Pattern[] getUserInputPatterns()
    • getChanger

      @Nullable public @Nullable Changer<? super T> getChanger()
    • getSupplier

      @Nullable public @Nullable Supplier<Iterator<T>> getSupplier()
    • getSerializer

      @Nullable public @Nullable Serializer<? super T> getSerializer()
    • getSerializeAs

      @Nullable public @Nullable Class<?> getSerializeAs()
    • getMath

      @Nullable @Deprecated public @Nullable Arithmetic<? super T,?> getMath()
      Deprecated.
    • getRelativeMath

      @Nullable @Deprecated public <R> @Nullable Arithmetic<T,R> getRelativeMath()
      Deprecated.
    • getMathRelativeType

      @Nullable @Deprecated public @Nullable Class<?> getMathRelativeType()
      Deprecated.
    • getDescription

      @Nullable public @Nullable String[] getDescription()
    • getUsage

      @Nullable public @Nullable String[] getUsage()
    • getExamples

      @Nullable public @Nullable String[] getExamples()
    • getSince

      @Nullable public @Nullable String getSince()
    • getDocName

      @Nullable public @Nullable String getDocName()
    • getRequiredPlugins

      @Nullable public @Nullable String[] getRequiredPlugins()
    • getDocumentationID

      @Nullable public @Nullable String getDocumentationID()
      Gets overridden documentation id of this this type. If no override has been set, null is returned and the caller may try to derive this from name of #getC().
      Returns:
      Documentation id override, or null.
    • hasDocs

      public boolean hasDocs()
    • before

      public ClassInfo<T> before(String... before)
      Sets one or more classes that this class should occur before in the class info list. This only affects the order in which classes are parsed if it's unknown of which type the parsed string is.

      Please note that subclasses will always be registered before superclasses, no matter what is defined here or in after(String...).

      This list can safely contain classes that may not exist.

      Parameters:
      before -
      Returns:
      this ClassInfo
    • after

      public ClassInfo<T> after(String... after)
      Sets one or more classes that this class should occur after in the class info list. This only affects the order in which classes are parsed if it's unknown of which type the parsed string is.

      Please note that subclasses will always be registered before superclasses, no matter what is defined here or in before(String...).

      This list can safely contain classes that may not exist.

      Parameters:
      after -
      Returns:
      this ClassInfo
    • before

      @Nullable public @Nullable Set<String> before()
      Returns:
      Set of classes that should be after this one. May return null.
    • after

      public Set<String> after()
      Returns:
      Set of classes that should be before this one. Never returns null.
    • toString

      @NotNull public @NotNull String toString()
      Description copied from interface: Debuggable
      Should return toString(null, false)
      Specified by:
      toString in interface Debuggable
      Overrides:
      toString in class Object
    • toString

      public String toString(int flags)
    • toString

      @NotNull public @NotNull String toString(@Nullable @Nullable org.bukkit.event.Event event, boolean debug)
      Specified by:
      toString in interface Debuggable
      Parameters:
      event - The event to get information from. This is always null if debug == false.
      debug - If true this should print more information, if false this should print what is shown to the end user
      Returns:
      String representation of this object