Class Script
java.lang.Object
org.skriptlang.skript.lang.script.Script
Scripts are the primary container of all code.
Every script is made up of one or more
Structure
s, which contain user-defined instructions and information.
Every script also has its own internal information, such as
custom data, suppressed warnings, and associated event handlers.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Used for listening to events involving a Script. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addData
(ScriptData data) This API is experimental and subject to change. Adds new ScriptData to this Script's data map.void
allowWarning
(ScriptWarning warning) void
This API is experimental and subject to change. Clears the data stored for this script.<Value extends ScriptData>
ValueThis API is experimental and subject to change. A method that always obtains ScriptData matching the specified data type.<Type extends ScriptData>
TypeThis API is experimental and subject to change. A method to obtain ScriptData matching the specified data type.void
removeData
(Class<? extends ScriptData> dataType) This API is experimental and subject to change. Removes the ScriptData matching the specified data type.boolean
suppressesWarning
(ScriptWarning warning) void
suppressWarning
(ScriptWarning warning)
-
Constructor Details
-
Script
Creates a new Script to be used across the API. Only one Script should be created per Config. A loaded Script may be obtained throughScriptLoader
.- Parameters:
config
- The Config containing the contents of this Script.structures
- The list of Structures contained in this Script.
-
-
Method Details
-
getConfig
- Returns:
- The Config representing the structure of this Script.
-
getStructures
- Returns:
- An unmodifiable list of all Structures within this Script.
-
suppressWarning
- Parameters:
warning
- Suppresses the provided warning for this Script.
-
allowWarning
- Parameters:
warning
- Allows the provided warning for this Script.
-
suppressesWarning
- Parameters:
warning
- The warning to check.- Returns:
- Whether this Script suppresses the provided warning.
-
addData
This API is experimental and subject to change. Adds new ScriptData to this Script's data map.- Parameters:
data
- The data to add.
-
removeData
This API is experimental and subject to change. Removes the ScriptData matching the specified data type.- Parameters:
dataType
- The type of the data to remove.
-
clearData
@Experimental public void clearData()This API is experimental and subject to change. Clears the data stored for this script. -
getData
This API is experimental and subject to change. A method to obtain ScriptData matching the specified data type.- Parameters:
dataType
- The class representing the ScriptData to obtain.- Returns:
- ScriptData found matching the provided class, or null if no data is present.
-
getData
@Experimental public <Value extends ScriptData> Value getData(Class<? extends Value> dataType, Supplier<Value> mapper) This API is experimental and subject to change. A method that always obtains ScriptData matching the specified data type. By using the mapping supplier, it will also add ScriptData of the provided type if it is not already present.- Parameters:
dataType
- The class representing the ScriptData to obtain.mapper
- A supplier to create ScriptData of the provided type if such ScriptData is not already present.- Returns:
- Existing ScriptData found matching the provided class, or new data provided by the mapping function.
-
eventRegistry
- Returns:
- An EventRegistry for this Script's events.
-