Class Script

java.lang.Object
org.skriptlang.skript.lang.script.Script

public final class Script extends Object
Scripts are the primary container of all code. Every script is made up of one or more Structures, 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 Details

    • Script

      @Internal public Script(Config config, List<Structure> structures)
      Creates a new Script to be used across the API. Only one Script should be created per Config. A loaded Script may be obtained through ScriptLoader.
      Parameters:
      config - The Config containing the contents of this Script.
      structures - The list of Structures contained in this Script.
  • Method Details

    • getConfig

      public Config getConfig()
      Returns:
      The Config representing the structure of this Script.
    • getStructures

      public @Unmodifiable List<Structure> getStructures()
      Returns:
      An unmodifiable list of all Structures within this Script.
    • suppressWarning

      public void suppressWarning(ScriptWarning warning)
      Parameters:
      warning - Suppresses the provided warning for this Script.
    • allowWarning

      public void allowWarning(ScriptWarning warning)
      Parameters:
      warning - Allows the provided warning for this Script.
    • suppressesWarning

      public boolean suppressesWarning(ScriptWarning warning)
      Parameters:
      warning - The warning to check.
      Returns:
      Whether this Script suppresses the provided warning.
    • addData

      @Experimental public void addData(ScriptData data)
      This API is experimental and subject to change. Adds new ScriptData to this Script's data map.
      Parameters:
      data - The data to add.
    • removeData

      @Experimental public void removeData(Class<? extends ScriptData> dataType)
      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

      @Experimental @Nullable public <Type extends ScriptData> Type getData(Class<Type> dataType)
      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

      public EventRegistry<Script.Event> eventRegistry()
      Returns:
      An EventRegistry for this Script's events.