Class Variables

java.lang.Object
io.github.syst3ms.skriptparser.variables.Variables

public class Variables extends Object
A class handling operations on variables.
  • Field Details

  • Constructor Details

    • Variables

      public Variables()
  • Method Details

    • hasStorages

      public static boolean hasStorages()
    • getLock

      public static ReentrantLock getLock()
    • shutdown

      public static void shutdown()
    • registerStorage

      public static <T extends VariableStorage> boolean registerStorage(Class<T> storage, String... names)
      Register a VariableStorage class.
      Type Parameters:
      T - Generic representing class that extends VariableStorage.
      Parameters:
      storage - The class of the VariableStorage implementation.
      names - The names used to reference this storage.
      Returns:
      if the storage was registered, false if it's already registered.
    • load

      public static void load(SkriptLogger logger, Config.ConfigSection section) throws IllegalArgumentException
      Loads a section configuration containing all the database info. Parent section node name must be 'databases:'.
      Parameters:
      logger - the SkriptLogger to print errors to.
      section - the ConfigSection to load for the databases.
      Throws:
      IllegalArgumentException - throws when the section is not valid.
    • parseVariable

      public static <T> Optional<? extends Expression<T>> parseVariable(String input, Class<? extends T> types, ParserState parserState, SkriptLogger logger)
    • isValidVariableName

      public static boolean isValidVariableName(String name, boolean printErrors, SkriptLogger logger)
      Checks whether a string is a valid variable name.
      Parameters:
      name - The name to test
      printErrors - Whether to print errors when they are encountered
      logger - the logger
      Returns:
      true if the name is valid, false otherwise.
    • getVariable

      public static Optional<Object> getVariable(String name, TriggerContext e, boolean local)
      Returns the internal value of the requested variable.

      Do not modify the returned value!

      Parameters:
      name - the name of the variable
      Returns:
      an Object for a normal Variable or a Mapinvalid input: '<'String, Object> for a list variable, or null if the variable is not set.
    • setVariable

      public static void setVariable(String name, @Nullable @Nullable Object value, @Nullable @Nullable TriggerContext e, boolean local)
      Sets a variable.
      Parameters:
      name - The variable's name. Can be a "list variable::*" (value must be null in this case)
      value - The variable's value. Use null to delete the variable.
    • clearVariables

      public static void clearVariables()
    • copyLocalVariables

      public static void copyLocalVariables(TriggerContext from, TriggerContext to)
      Copy local variables from one TriggerContext to another.
      Parameters:
      from - The source TriggerContext
      to - The destination TriggerContext
    • clearLocalVariables

      public static void clearLocalVariables(TriggerContext ctx)
      Clear local variables for a specific TriggerContext.
      Parameters:
      ctx - The TriggerContext to clear variables for