Script
Class
A handle representation of a script containing its metadata and defined classes.
This can be used to find insights about a script or find a particular function handle.
These should not be stored - they can be arbitrarily graveyarded without any notification by the unloader, in which case this will become a dead spot in memory.
Object
public final
final PostCompileClass data = skript.compileScript(code, "skript.myscript");
final Script script = skript.loadScript(data);
final Member function = script.getFunction("my_func");
function.run();
final PostCompileClass data = skript.compileScript(code, "skript.myscript");
final Script script = skript.loadScript(data);
skript.runEvent(new MyEvent(), script);
Methods
getSimpleName ()
MethodThe simple name of the main class for this script.
This will be something in the format script
.
String
public
// Randomly-generated example
final String string = script.getSimpleName();
assert string.equals(anObject);
assert string.length() == 37;
string.toString();
classes ()
MethodReturns the known classes for this script. This will include the main class and any custom types, etc.
Class[]
public
getFunction (String)
MethodReturns a handle for the function with this name. Multiple functions may have the same name, this will return an arbitrary one.
Index | Type | Name |
---|---|---|
1 | String | name |
Member
public
// Randomly-generated example
final Member member = script.getFunction(name);
member.invoke(arguments);
member.run(arguments);
member.run(skript, arguments);
getMembers ()
MethodReturns the structures for all members, used for data collection.
Structure[]
public
getPath ()
MethodThe path of the main class for this script.
This will be something in the format skript.path.to.script
String
public
assert script.getPath().startsWith(myPathName);
mainClass ()
MethodGets the main class of this script, which root-level members occupy. Custom types and other members may be moved to other classes, depending on the compiler used.
This should not be stored - it will prevent the script unloading safely.
Class
public
sourceFile ()
MethodReturns the known source file for this script. This may not exist for some implementations.
File
public
// Randomly-generated example
final File file = script.sourceFile();
file.getName();
assert file.equals(obj);
assert file.length() == 74;
skriptInstance ()
MethodReturns the Skript runtime that created this script.
Skript
public
// Randomly-generated example
final Skript skript = script.skriptInstance();
skript.getCompiler();
assert skript.println(object) == null;
skript.getClass(name);
ownsClass (Class)
MethodIndex | Type | Name |
---|---|---|
1 | Class | cls |
boolean
hasSourceFile ()
MethodWhether this script has a known source file.
boolean
public
// Randomly-generated example
assert script.hasSourceFile();
getMemberData ()
MethodFinds source data annotations for members in this script.
Collection
public