Class SkriptRegistration

java.lang.Object
io.github.syst3ms.skriptparser.registration.SkriptRegistration

public class SkriptRegistration extends Object
A mutable object keeping track of all syntax and types registered by an addon Do not forget to call register() !
See Also:
  • Constructor Details

    • SkriptRegistration

      public SkriptRegistration(SkriptAddon registerer)
      Construct a SkriptRegistration around a SkriptAddon.
      Parameters:
      registerer - The SkriptAddon that this SkriptRegistration will be referencing.
    • SkriptRegistration

      public SkriptRegistration(SkriptAddon registerer, SkriptLogger logger)
      Construct a SkriptRegistration around a SkriptAddon and the defined SkriptLogger to use.
      Parameters:
      registerer - The SkriptAddon that this SkriptRegistration will be referencing.
      logger - the SkriptLogger used in the registration process.
  • Method Details

    • getExpressions

      public MultiMap<Class<?>, ExpressionInfo<?,?>> getExpressions()
      Returns:
      all currently registered expressions
    • getEffects

      public List<SyntaxInfo<? extends Effect>> getEffects()
      Returns:
      all currently registered effects
    • getSections

      public List<SyntaxInfo<? extends CodeSection>> getSections()
      Returns:
      all currently registered sections
    • getEvents

      public List<SkriptEventInfo<?>> getEvents()
      Returns:
      all currently registered events
    • getTypes

      public List<Type<?>> getTypes()
      Returns:
      all currently registered types
    • getConverters

      public List<ConverterInfo<?,?>> getConverters()
      Returns:
      all currently registered converters
    • getContextValues

      public List<ContextValue<?,?>> getContextValues()
      Returns:
      all currently registered context values
    • getTags

      public List<TagInfo<?>> getTags()
      Returns:
      all currently registered tags
    • getRegisterer

      public SkriptAddon getRegisterer()
      Returns:
      the addon handling this registration (may be Skript itself)
    • newExpression

      public <C extends Expression<T>, T> SkriptRegistration.ExpressionRegistrar<C,T> newExpression(Class<C> c, Class<T> returnType, boolean isSingle, String... patterns)
      Starts a registration process for an Expression
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      isSingle - whether the Expression is a single value
      patterns - the Expression's patterns
      Returns:
      an SkriptRegistration.ExpressionRegistrar to continue the registration process
    • addExpression

      public <C extends Expression<T>, T> void addExpression(Class<C> c, Class<T> returnType, String... patterns)
      Registers an Expression with the isSingle set to true by default. Mainly so you can override with Expression.isSingle()
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      patterns - the Expression's patterns
    • addExpression

      public <C extends Expression<T>, T> void addExpression(Class<C> c, Class<T> returnType, boolean isSingle, String... patterns)
      Registers an Expression
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      isSingle - whether the Expression is a single value
      patterns - the Expression's patterns
    • addExpression

      public <C extends Expression<T>, T> void addExpression(Class<C> c, Class<T> returnType, boolean isSingle, int priority, String... patterns)
      Registers an Expression
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      isSingle - whether the Expression is a single value
      priority - the parsing priority this Expression has. 5 by default, a lower number means lower priority
      patterns - the Expression's patterns
    • newPropertyExpression

      public <C extends PropertyExpression<?,T>, T> SkriptRegistration.ExpressionRegistrar<C,T> newPropertyExpression(Class<C> c, Class<T> returnType, String property, String owner)
      Starts a registration process for a PropertyExpression
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      property - the property
      owner - the owner in the pattern
      Returns:
      an SkriptRegistration.ExpressionRegistrar to continue the registration process
    • addPropertyExpression

      public <C extends PropertyExpression<?,T>, T> void addPropertyExpression(Class<C> c, Class<T> returnType, String property, String owner)
      Registers a PropertyExpression
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      property - the property
      owner - the owner in the pattern
    • addPropertyExpression

      public <C extends PropertyExpression<?,T>, T> void addPropertyExpression(Class<C> c, Class<T> returnType, int priority, String property, String owner)
      Registers a PropertyExpression
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      priority - the priority
      property - the property
      owner - the owner in the pattern
    • newPropertyConditional

      public <C extends PropertyConditional<?>> SkriptRegistration.ExpressionRegistrar<C,Boolean> newPropertyConditional(Class<C> c, String performer, ConditionalType conditionalType, String property)
      Starts a registration process for a PropertyConditional
      Type Parameters:
      C - the Expression
      Parameters:
      c - the Expression's class
      performer - the type of the performer
      conditionalType - the verb used in this conditional property
      property - the property
      Returns:
      an SkriptRegistration.ExpressionRegistrar to continue the registration process
    • addPropertyConditional

      public <C extends PropertyConditional<?>> void addPropertyConditional(Class<C> c, String performer, ConditionalType conditionalType, String property)
      Type Parameters:
      C - the Expression
      Parameters:
      c - the Expression's class
      performer - the type of the performer
      conditionalType - the verb used in this conditional property
      property - the property
    • addPropertyConditional

      public <C extends PropertyConditional<?>> void addPropertyConditional(Class<C> c, int priority, String performer, ConditionalType conditionalType, String property)
      Type Parameters:
      C - the Expression
      Parameters:
      c - the Expression's class
      priority - the parsing priority this Expression has. 5 by default, a lower number means lower priority
      performer - the type of the performer
      conditionalType - the verb used in this conditional property
      property - the property
    • addExecutableExpression

      public <C extends ExecutableExpression<T>, T> void addExecutableExpression(Class<C> c, Class<T> returnType, boolean isSingle, String... patterns)
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      isSingle - whether the Expression is a single value
      patterns - the Expression's patterns
    • addExecutableExpression

      public <C extends ExecutableExpression<T>, T> void addExecutableExpression(Class<C> c, Class<T> returnType, boolean isSingle, int priority, String... patterns)
      Type Parameters:
      C - the Expression
      T - the Expression's return type
      Parameters:
      c - the Expression's class
      returnType - the Expression's return type
      isSingle - whether the Expression is a single value
      patterns - the Expression's patterns
    • newEffect

      public <C extends Effect> SkriptRegistration.EffectRegistrar<C> newEffect(Class<C> c, String... patterns)
      Starts a registration process for an Effect
      Type Parameters:
      C - the Effect
      Parameters:
      c - the Effect's class
      patterns - the Effect's patterns
      Returns:
      an SkriptRegistration.EffectRegistrar to continue the registration process
    • addEffect

      public <C extends Effect> void addEffect(Class<C> c, String... patterns)
      Registers an Effect
      Type Parameters:
      C - the Effect
      Parameters:
      c - the Effect's class
      patterns - the Effect's patterns
    • addEffect

      public <C extends Effect> void addEffect(Class<C> c, int priority, String... patterns)
      Registers an Effect
      Type Parameters:
      C - the Effect
      Parameters:
      c - the Effect's class
      priority - the parsing priority this Effect has. 5 by default, a lower number means lower priority
      patterns - the Effect's patterns
    • newSection

      public <C extends CodeSection> SkriptRegistration.SectionRegistrar<C> newSection(Class<C> c, String... patterns)
      Starts a registration process for a CodeSection
      Type Parameters:
      C - the CodeSection
      Parameters:
      c - the CodeSection's class
      patterns - the CodeSection's patterns
      Returns:
      a SkriptRegistration.SectionRegistrar to continue the registration process
    • addSection

      public void addSection(Class<? extends CodeSection> c, String... patterns)
      Registers a CodeSection
      Parameters:
      c - the CodeSection's class
      patterns - the CodeSection's patterns
    • addSection

      public void addSection(Class<? extends CodeSection> c, int priority, String... patterns)
      Registers a CodeSection
      Parameters:
      c - the CodeSection's class
      priority - the parsing priority this CodeSection has. 5 by default, a lower number means lower priority
      patterns - the CodeSection's patterns
    • newEvent

      public <E extends SkriptEvent> SkriptRegistration.EventRegistrar<E> newEvent(Class<E> c, String... patterns)
      Starts a registration process for a SkriptEvent
      Type Parameters:
      E - the SkriptEvent
      Parameters:
      c - the SkriptEvent's class
      patterns - the SkriptEvent's patterns
      Returns:
      an SkriptRegistration.EventRegistrar to continue the registration process
    • addEvent

      public void addEvent(Class<? extends SkriptEvent> c, Class<? extends TriggerContext>[] handledContexts, String... patterns)
      Registers a SkriptEvent
      Parameters:
      c - the SkriptEvent's class
      handledContexts - the TriggerContexts this SkriptEvent can handle
      patterns - the SkriptEvent's patterns
    • addEvent

      public void addEvent(Class<? extends SkriptEvent> c, Class<? extends TriggerContext>[] handledContexts, int priority, String... patterns)
      Registers a SkriptEvent
      Parameters:
      c - the SkriptEvent's class
      handledContexts - the TriggerContexts this SkriptEvent can handle
      priority - the parsing priority this SkriptEvent has. 5 by default, a lower number means lower priority
      patterns - the SkriptEvent's patterns
    • newContextValue

      public <C extends TriggerContext, T> SkriptRegistration.ContextValueRegistrar<C,T> newContextValue(Class<C> context, Class<T> returnType, boolean isSingle, String pattern, Function<C,T[]> function)
      Starts a registration process for a ContextExpression
      Type Parameters:
      C - the TriggerContext class
      T - the ContextValue's return type
      Parameters:
      context - the TriggerContext class
      returnType - the returned type of this context value
      isSingle - whether or not the return value is single
      pattern - the pattern
      function - the function that needs to be applied in order to get the context value
      Returns:
      a SkriptRegistration.ContextValueRegistrar to continue the registration process
    • addContextValue

      public <C extends TriggerContext, T> void addContextValue(Class<C> context, Class<T> returnType, boolean isSingle, String pattern, Function<C,T[]> function)
      Registers a ContextValue
      Type Parameters:
      C - the TriggerContext class
      T - the ContextValue's return type
      Parameters:
      context - the TriggerContext class
      returnType - the returned type of this context value
      isSingle - whether or not the return value is single
      pattern - the pattern
      function - the function that needs to be applied in order to get the context value
    • addContextType

      public <C extends TriggerContext, T> void addContextType(Class<C> context, Class<T> returnType, Function<C,T> function)
      Registers a ContextValue that returns a single value. The base name of the return type will be used as pattern. There will be a leading '[the] ' in the pattern if the context value can be used alone.
      Type Parameters:
      C - the TriggerContext class
      T - the ContextValue's return type
      Parameters:
      context - the TriggerContext class
      returnType - the returned type of this context value
      function - the function that needs to be applied in order to get the context value
    • addContextType

      public <C extends TriggerContext, T> void addContextType(Class<C> context, Class<T> returnType, Function<C,T> function, ContextValue.State state)
      Registers a ContextValue that returns a single value. The base name of the return type will be used as pattern. There will be a leading '[the] ' in the pattern if the context value can be used alone.
      Type Parameters:
      C - the TriggerContext class
      T - the ContextValue's return type
      Parameters:
      context - the TriggerContext class
      returnType - the returned type of this context value
      function - the function that needs to be applied in order to get the context value
      state - the time state
      See Also:
    • addContextType

      public <C extends TriggerContext, T> void addContextType(Class<C> context, Class<T> returnType, Function<C,T> function, ContextValue.State state, ContextValue.Usage usage)
      Registers a ContextValue that returns a single value. The base name of the return type will be used as pattern. There will be a leading '[the] ' in the pattern if the context value can be used alone.
      Type Parameters:
      C - the TriggerContext class
      T - the ContextValue's return type
      Parameters:
      context - the TriggerContext class
      returnType - the returned type of this context value
      function - the function that needs to be applied in order to get the context value
      state - the time state
      usage - the usage
      See Also:
    • newType

      public <T> SkriptRegistration.TypeRegistrar<T> newType(Class<T> c, String name, String pattern)
      Starts a registration process for a Type
      Type Parameters:
      T - the represented class
      Parameters:
      c - the class the Type represents
      pattern - the Type's pattern
      Returns:
      an SkriptRegistration.TypeRegistrar
    • addType

      public <T> void addType(Class<T> c, String name, String pattern)
      Registers a Type
      Type Parameters:
      T - the represented class
      Parameters:
      c - the class the Type represents
      pattern - the Type's pattern
    • addConverter

      public <F,T> void addConverter(Class<F> from, Class<T> to, Function<? super F, Optional<? extends T>> converter)
      Registers a converter
      Type Parameters:
      F - from
      T - to
      Parameters:
      from - the class it converts from
      to - the class it converts to
      converter - the converter
    • addConverter

      public <F,T> void addConverter(Class<F> from, Class<T> to, Function<? super F, Optional<? extends T>> converter, int options)
      Registers a converter
      Type Parameters:
      F - from
      T - to
      Parameters:
      from - the class it converts from
      to - the class it converts to
      converter - the converter
      options - see Converters
    • addTag

      public void addTag(Class<? extends Tag> c)
      Registers a Tag.
      Parameters:
      c - the Tag's class
    • addTag

      public void addTag(Class<? extends Tag> c, int priority)
      Registers a Tag.
      Parameters:
      c - the Tag's class
      priority - the parsing priority this Tag has. 5 by default, a lower number means lower priority
    • register

      public List<LogEntry> register()
      Adds all currently registered syntaxes to Skript's usable database.
      Returns:
      all possible errors, warnings and other logs that occurred while parsing the patterns
    • register

      public List<LogEntry> register(boolean ignoreLogs)
      Adds all currently registered syntaxes to Skript's usable database.
      Parameters:
      ignoreLogs - whether to return the logs and close the logger, or just ignore and clear them while keeping the logger open
      Returns:
      all possible errors, warnings and other logs that occurred while parsing the patterns
    • getLogger

      public SkriptLogger getLogger()
    • onFinishRegistration

      public void onFinishRegistration(Consumer<SkriptAddon> consumer)
      Add a consumer to be called when this SkriptRegistration finishes registration.
      Parameters:
      consumer - the consumer with the SkriptAddon reference.