Class Script

java.lang.Object
net.botwithus.rs3.script.Script
All Implemented Interfaces:
Runnable, ImmutableScript, ItemInputProvider, ItemOutputProvider, ItemProvider
Direct Known Subclasses:
GlobalScript, LoopingScript, TickingScript

public abstract class Script extends Object implements Runnable, ImmutableScript, ItemProvider
The abstract script, this class represents the common traits and behaviour between scripts.
  • Constructor Details

  • Method Details

    • isLocal

      public boolean isLocal()
      Checks if the script is local or from the SDN
      Returns:
      True if the script is locally loaded
    • pause

      public void pause()
    • resume

      public void resume()
    • onActivation

      public void onActivation()
    • onDeactivation

      public void onDeactivation()
    • onPropertyChangeRequest

      public void onPropertyChangeRequest(PropertyUpdateRequestEvent event)
    • getAuthor

      public String getAuthor()
      Specified by:
      getAuthor in interface ImmutableScript
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface ImmutableScript
    • run

      public abstract void run()
      Specified by:
      run in interface Runnable
    • getGraphicsContext

      public ScriptGraphicsContext getGraphicsContext()
      Gets the current graphics context or creates one if none are present.
      Returns:
      The current graphics context
    • getName

      public final String getName()
      The name of the script, mainly for visual purposes.
      Specified by:
      getName in interface ImmutableScript
      Returns:
      The name of the script.
    • isActive

      public final boolean isActive()
      If the script is active, when the script is active is running
      Specified by:
      isActive in interface ImmutableScript
      Returns:
      If the script is active or not
    • unsubscribeAll

      public void unsubscribeAll()
    • isPaused

      public boolean isPaused()
      Specified by:
      isPaused in interface ImmutableScript
    • setActive

      public final void setActive(boolean active)
      Sets if the script will be in active state or not.
      Parameters:
      active - The state of being active or not
    • print

      public final void print(Object object)
      Logs the given object's toString to the console on the same line.
      Specified by:
      print in interface ImmutableScript
      Parameters:
      object - The message to be logged to the console.
    • println

      public final void println(Object object)
      Logs the given object's toString to the console.
      Specified by:
      println in interface ImmutableScript
      Parameters:
      object - The message to be logged to the console.
    • print

      public final void print(String message)
      Logs the given message to the console on the same line.
      Specified by:
      print in interface ImmutableScript
      Parameters:
      message - The message to be logged to the console.
    • print

      public final void print(String message, Object... args)
      Logs the given message on the same line.
      Specified by:
      print in interface ImmutableScript
      Parameters:
      message - the message to log
      args - the arguments to format the message with
    • println

      public final void println(String message)
      Logs a message to the console.
      Specified by:
      println in interface ImmutableScript
      Parameters:
      message - The message to be logged.
    • print

      public void print(Throwable t)
      Description copied from interface: ImmutableScript
      Logs a formatted string.
      Specified by:
      print in interface ImmutableScript
      Parameters:
      t - the throwable to log
    • println

      public final void println(String format, Object... args)
      Logs a formatted string.
      Specified by:
      println in interface ImmutableScript
      Parameters:
      format - the format string
      args - the arguments referenced by the format specifiers in the format string
    • getConfiguration

      public final ImmutableConfig getConfiguration()
      Gets the configuration ScriptConfig
      Specified by:
      getConfiguration in interface ImmutableScript
      Returns:
      The ScriptConfig
    • subscribe

      public final <T> void subscribe(Class<T> eventType, Consumer<T> listener)
      Subscribes the given event with this script as owner
      Type Parameters:
      T - The generic event Type
      Parameters:
      eventType - The event type
      listener - The listener
    • initialize

      public boolean initialize()
      Initializes the script, this method loads the script configuration.
      Returns:
      If the script should be active
    • onUninitialize

      public void onUninitialize()
    • uninitialize

      public final void uninitialize()
      Uninitializes the Script
    • syncConfig

      public void syncConfig()
      Syncs the configuration with the script state
    • isBackgroundScript

      public boolean isBackgroundScript()
      Specified by:
      isBackgroundScript in interface ImmutableScript
    • delay

      public void delay(long ms)
    • delayUntil

      public void delayUntil(long ms, Supplier<Boolean> condition)
    • delayUtil

      public void delayUtil(long timeout, Supplier<Boolean> condition, long postDelay)
    • getInput

      public List<ProvidedItem> getInput()
      Specified by:
      getInput in interface ItemInputProvider
    • getOutput

      public List<ProvidedItem> getOutput()
      Specified by:
      getOutput in interface ItemOutputProvider
    • getDefinition

      public final ImmutableScriptDefinition getDefinition()
      Specified by:
      getDefinition in interface ImmutableScript
    • getLog

      public com.google.common.flogger.FluentLogger getLog()