Class ExpressionScope
java.lang.Object
net.citizensnpcs.api.expr.ExpressionScope
A variable scope for expression evaluation with lazy binding support. Variables are only computed when accessed and
cached for the evaluation cycle.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidBinds a lazily-evaluated variable.Creates a child scope that inherits from this scope.Gets a variable value, computing lazy bindings if necessary.Gets the memory instance for this scope or parent scope if not present.getNPC()Gets the NPC for this scope or parent NPC if not present.Gets the Player for this scope or parent Player if not present.Supplier<?> getSupplier(String name) Gets the supplier for a lazy binding, if it exists.Gets all variable names currently in scope.booleanChecks if a variable exists in this scope or parent scopes.booleanisConstant(String name) Checks if a variable is a lazy binding (not eagerly evaluated).voidRemoves a variable from the scope.voidClears cached lazy values.voidSets an eager (immediate) value for a variable.voidSets the memory instance for this scope.voidSets the NPC for this scope.voidSets the Player for this scope.
-
Constructor Details
-
ExpressionScope
public ExpressionScope() -
ExpressionScope
-
-
Method Details
-
bind
-
createChild
Creates a child scope that inherits from this scope. -
get
-
getMemory
Gets the memory instance for this scope or parent scope if not present. -
getNPC
Gets the NPC for this scope or parent NPC if not present. -
getPlayer
Gets the Player for this scope or parent Player if not present. -
getSupplier
-
getVariableNames
-
has
Checks if a variable exists in this scope or parent scopes.- Parameters:
name- the variable name
-
isConstant
Checks if a variable is a lazy binding (not eagerly evaluated).- Parameters:
name- the variable name- Returns:
- true if the variable is a lazy binding
-
remove
Removes a variable from the scope. -
resetCache
public void resetCache()Clears cached lazy values. Call this between evaluation cycles to allow lazy values to be recomputed with fresh data. -
set
-
setMemory
Sets the memory instance for this scope. -
setNPC
Sets the NPC for this scope. -
setPlayer
Sets the Player for this scope.
-