Package org.dreambot.api.script
Class AbstractScript
- java.lang.Object
-
- org.dreambot.api.methods.MethodProvider
-
- org.dreambot.api.script.AbstractScript
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.EventListener
,PaintListener
- Direct Known Subclasses:
TaskScript
,TreeScript
public abstract class AbstractScript extends MethodProvider implements java.lang.Runnable, PaintListener
This is the base class of any script to be run on the client.Please note that this class requires a
ScriptManifest
to be present in order to show up in the client.What happens when a script is started:
onStart(String...)
is called if script parameters are passed, otherwiseonStart()
will be called- The
RandomManager
is started, which will fireonSolverStart(RandomSolver)
when those are wanting to run onLoop()
is then repeatedly called until the script is stopped- After the script has stopped,
onExit()
is finally called
-
-
Constructor Summary
Constructors Constructor Description AbstractScript()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
buildRandomManager()
Creates the random manager and thread for this scriptScriptManager.State
getCurrentState()
ScriptManifest
getManifest()
RandomManager
getRandomManager()
java.lang.Thread
getRandomThread()
java.lang.String
getSDNName()
java.lang.String
getSDNParameters()
This is arbitrary data you've included in the SDN as a StringTile
getStartTile()
int
getStoreId()
java.lang.String
getThreadURL()
double
getVersion()
boolean
isPaused()
void
onExit()
Called when the script ends.abstract int
onLoop()
This is the script's primary loop that runs as long as the script does.void
onPaint(java.awt.Graphics graphics)
Handles the graphic for the script.void
onPaint(java.awt.Graphics2D graphics)
Handles the graphic for the script.void
onPause()
Called when the script is paused.void
onResume()
Called when the script is resumed.boolean
onSolverStart(RandomSolver solver)
Called during the random solver reset stage, before solver.onStart is called.void
onStart()
Called when the script starts with no script parameters passed in.void
onStart(java.lang.String... params)
Called when the script is started with parametersvoid
run()
void
setState(ScriptManager.State state)
void
stop()
-
Methods inherited from class org.dreambot.api.methods.MethodProvider
debug, error, getScriptManager, info, isUserSponsor, isUserVIP, log, print, sleep, sleep, sleepUntil, sleepUntil, sleepWhile, sleepWhile
-
-
-
-
Method Detail
-
getStartTile
public Tile getStartTile()
-
getRandomThread
public java.lang.Thread getRandomThread()
-
onStart
public void onStart()
Called when the script starts with no script parameters passed in.
-
onStart
public void onStart(java.lang.String... params)
Called when the script is started with parameters
-
onSolverStart
public boolean onSolverStart(RandomSolver solver)
Called during the random solver reset stage, before solver.onStart is called. Must return true in order for the solver.onStart to be called, and the solver to begin.- Parameters:
solver
- The Random Solver that is about to be activated- Returns:
- True starts the solver, false will delay the start.
-
onLoop
public abstract int onLoop()
This is the script's primary loop that runs as long as the script does.- Returns:
- How long to wait in milliseconds before onLoop is called again. Note that returning a number less than 0 will result in the script being stopped.
-
onExit
public void onExit()
Called when the script ends.
-
onPause
public void onPause()
Called when the script is paused.
-
onResume
public void onResume()
Called when the script is resumed.
-
onPaint
public void onPaint(java.awt.Graphics graphics)
Handles the graphic for the script.- Specified by:
onPaint
in interfacePaintListener
- Parameters:
graphics
- The Graphics instance sent from the canvas.
-
onPaint
public void onPaint(java.awt.Graphics2D graphics)
Handles the graphic for the script.- Specified by:
onPaint
in interfacePaintListener
- Parameters:
graphics
- The Graphics2D instance sent from the canvas.
-
buildRandomManager
public final void buildRandomManager()
Creates the random manager and thread for this script
-
stop
public void stop()
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
isPaused
public boolean isPaused()
-
setState
public void setState(ScriptManager.State state)
-
getCurrentState
public ScriptManager.State getCurrentState()
-
getManifest
public final ScriptManifest getManifest()
-
getRandomManager
public RandomManager getRandomManager()
- Overrides:
getRandomManager
in classMethodProvider
-
getVersion
public double getVersion()
-
getSDNName
public java.lang.String getSDNName()
-
getThreadURL
public java.lang.String getThreadURL()
-
getStoreId
public int getStoreId()
-
getSDNParameters
public java.lang.String getSDNParameters()
This is arbitrary data you've included in the SDN as a StringYou can use this as a way to differentiate between scripts with a similar code base, such as a basic and advanced version, without needing to maintain two separate (but extremely similar) script repos/modules.
- Returns:
- The script parameters you've set on the SDN for this script, only shown during runs loaded from the SDN. If no parameters have been set, it will return an empty string.
-
-