Class Variables
java.lang.Object
io.github.syst3ms.skriptparser.variables.Variables
A class handling operations on variables.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClear local variables for a specific TriggerContext.static voidstatic voidcopyLocalVariables(TriggerContext from, TriggerContext to) Copy local variables from one TriggerContext to another.static ReentrantLockgetLock()getVariable(String name, TriggerContext e, boolean local) Returns the internal value of the requested variable.static booleanstatic booleanisValidVariableName(String name, boolean printErrors, SkriptLogger logger) Checks whether a string is a valid variable name.static voidload(SkriptLogger logger, Config.ConfigSection section) Loads a section configuration containing all the database info.static <T> Optional<? extends Expression<T>> parseVariable(String input, Class<? extends T> types, ParserState parserState, SkriptLogger logger) static <T extends VariableStorage>
booleanregisterStorage(Class<T> storage, String... names) Register a VariableStorage class.static voidsetVariable(String name, @Nullable Object value, @Nullable TriggerContext e, boolean local) Sets a variable.static voidshutdown()
-
Field Details
-
REGEX_PATTERN
-
LOCAL_VARIABLE_TOKEN
- See Also:
-
LIST_SEPARATOR
- See Also:
-
-
Constructor Details
-
Variables
public Variables()
-
-
Method Details
-
hasStorages
public static boolean hasStorages() -
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
Checks whether a string is a valid variable name.- Parameters:
name- The name to testprintErrors- Whether to print errors when they are encounteredlogger- the logger- Returns:
- true if the name is valid, false otherwise.
-
getVariable
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
Copy local variables from one TriggerContext to another.- Parameters:
from- The source TriggerContextto- The destination TriggerContext
-
clearLocalVariables
Clear local variables for a specific TriggerContext.- Parameters:
ctx- The TriggerContext to clear variables for
-