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

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:
      EventValueExpression, SimpleLiteral
    • 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

      public <R> ClassInfo<T> math(Class<R> relativeType, Arithmetic<? super T,​R> math)
    • 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

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

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

      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

      public @Nullable Pattern[] getUserInputPatterns()
    • getChanger

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

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

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

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

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

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

      public @Nullable String[] getDescription()
    • getUsage

      public @Nullable String[] getUsage()
    • getExamples

      public @Nullable String[] getExamples()
    • getSince

      public @Nullable String getSince()
    • getDocName

      public @Nullable String getDocName()
    • getRequiredPlugins

      public @Nullable String[] getRequiredPlugins()
    • getDocumentationID

      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.
    • 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

      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

      public @NonNull 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

      public @NonNull String toString(@Nullable org.bukkit.event.Event e, boolean debug)
      Specified by:
      toString in interface Debuggable
      Parameters:
      e - The event to get information to. 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