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.-
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.@Unmodifiable Set
<ScriptEvent> This API is experimental and subject to change.<T extends ScriptEvent>
@Unmodifiable Set<T> This API is experimental and subject to change.<T extends ScriptEvent>
voidregisterEvent
(Class<T> eventType, T event) This API is experimental and subject to change. Adds the provided event to this Script.void
registerEvent
(ScriptEvent event) This API is experimental and subject to change. Adds the provided event to this Script.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) void
unregisterEvent
(ScriptEvent event) This API is experimental and subject to change. Removes the provided event from this Script.
-
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.
-
registerEvent
This API is experimental and subject to change. Adds the provided event to this Script.- Parameters:
event
- The event to add.
-
registerEvent
This API is experimental and subject to change. Adds the provided event to this Script.- Parameters:
eventType
- The type of event being added. This is useful for registering the event through lambdas.event
- The event to add.
-
unregisterEvent
This API is experimental and subject to change. Removes the provided event from this Script.- Parameters:
event
- The event to remove.
-
getEvents
This API is experimental and subject to change.- Returns:
- An unmodifiable set of all events.
-
getEvents
This API is experimental and subject to change.- Parameters:
type
- The type of events to get.- Returns:
- An unmodifiable set of all events of the specified type.
-