public abstract class Script extends MethodProvider implements Painter, MessageListener, ConfigListener, LoginResponseCodeListener, AudioListener, GameTickListener
bank, bot, camera, chatbox, client, colorPicker, combat, configs, depositBox, dialogues, diaries, display, doorHandler, equipment, experienceTracker, favour, grandExchange, graphicObjects, groundItems, hintArrow, inventory, keyboard, logger, logoutTab, magic, map, menu, mouse, npcs, objects, players, prayer, projectiles, quests, settings, skills, store, tabs, trade, walking, widgets, worlds
Constructor and Description |
---|
Script() |
Modifier and Type | Method and Description |
---|---|
boolean |
canStart()
Functionality to execute code before any login validation and calling
onStart()
Return false to keep looping this method. |
void |
complete()
Signals this Script has finished execution.
|
void |
complete(boolean logout)
Signals this Script has finished execution.
|
java.lang.String |
getAuthor()
Gets the author of the script.
|
java.io.InputStream |
getDataResourceAsStream(java.lang.String name)
Scripts are allowed to access the OSBot Data folder; this method returns an InputStream
of a file relative to this Data folder.
|
java.lang.String |
getDirectoryData()
Scripts are limited to working inside the Data folder, you may append files inside this directory.
|
java.lang.String |
getName()
Gets the name of the script.
|
java.lang.String |
getParameters() |
int |
getRecommendedMirrorFps()
Gets recommended fps for mirror client.
|
int |
getRecommendedMirrorReactionTime()
Gets recommended reaction time for mirror client.
|
int |
getScriptId()
Gets the id of this script, when launched from the SDN.
|
java.io.InputStream |
getScriptResourceAsStream(java.lang.String name) |
double |
getVersion()
Gets the version of the script.
|
boolean |
isPlugin()
Deprecated.
|
void |
onConfig(int id,
int value)
Event listener used for callbacks on config change events
|
void |
onExit()
Called when this script exits and after the event queue has been terminated.
|
void |
onGameTick()
Do not do any calculations (or anything computational) in this.
|
abstract int |
onLoop()
Called by the script executor.
|
void |
onMessage(Message message)
Event listener used for callbacks on message events
|
void |
onPaint(java.awt.Graphics2D g)
Called when the next frame should be painted.
|
void |
onPlayAudio(int track) |
void |
onResponseCode(int code) |
void |
onStart()
Called when this script gets started.
|
void |
onStop()
Called when this script stops and before the event queue has been terminated.
|
void |
pause()
This method gets called when the
ScriptExecutor gets suspended or paused. |
void |
resume()
This method gets called when the
ScriptExecutor gets resumed. |
Script |
setParameters(java.lang.String parameters)
Deprecated.
|
void |
setScriptId(int scriptId)
Deprecated.
|
void |
stop()
Stops the script and will logout the accounts.
|
void |
stop(boolean logout)
Stops the script by stopping the script executor threads.
|
exchangeContext, execute, getBank, getBot, getCamera, getChatbox, getClient, getColorPicker, getCombat, getConfigs, getDepositBox, getDialogues, getDiaries, getDisplay, getDoorHandler, getEquipment, getExperienceTracker, getFavour, getGrandExchange, getGraphicObjects, getGroundItems, getHintArrow, getInventory, getKeyboard, getLogoutTab, getMagic, getMap, getMenuAPI, getMouse, getNpcs, getObjects, getPlayers, getPrayer, getProjectiles, getQuests, getSettings, getSkills, getStore, getTabs, getTrade, getWalking, getWidgets, getWorlds, gRandom, gRandom, gRandom, initializeContext, log, log, myPlayer, myPosition, random, random, sleep, stripFormatting, warn
public int getScriptId()
@Deprecated public void setScriptId(int scriptId)
scriptId
- The id of the script@Deprecated public boolean isPlugin()
public java.lang.String getDirectoryData()
public java.io.InputStream getScriptResourceAsStream(java.lang.String name)
public java.io.InputStream getDataResourceAsStream(java.lang.String name) throws java.io.FileNotFoundException
name
- The name of the filejava.io.FileNotFoundException
- Thrown when the file could not be found@Deprecated public Script setParameters(java.lang.String parameters)
public java.lang.String getParameters()
public java.lang.String getName()
public java.lang.String getAuthor()
public double getVersion()
public int getRecommendedMirrorReactionTime()
public int getRecommendedMirrorFps()
public boolean canStart()
onStart()
Return false to keep looping this method. Return true to continue script startup flow.onStart()
public void onStart() throws java.lang.InterruptedException
java.lang.InterruptedException
- Throws when execution is interruptedpublic abstract int onLoop() throws java.lang.InterruptedException
java.lang.InterruptedException
- Throws when execution is interruptedpublic void onPaint(java.awt.Graphics2D g)
public void onMessage(Message message) throws java.lang.InterruptedException
onMessage
in interface MessageListener
message
- The Message
instancejava.lang.InterruptedException
public void onConfig(int id, int value) throws java.lang.InterruptedException
onConfig
in interface ConfigListener
id
- The id of the configvalue
- The new value of the configjava.lang.InterruptedException
public void onResponseCode(int code) throws java.lang.InterruptedException
onResponseCode
in interface LoginResponseCodeListener
java.lang.InterruptedException
public void onPlayAudio(int track)
onPlayAudio
in interface AudioListener
public void onGameTick()
onGameTick
in interface GameTickListener
public void onStop() throws java.lang.InterruptedException
java.lang.InterruptedException
- Throws when execution is interruptedpublic void onExit() throws java.lang.InterruptedException
onStop()
.java.lang.InterruptedException
- Throws when execution is interruptedpublic final void stop()
public final void stop(boolean logout)
logout
- True if you want the account to logout.public final void complete()
stop()
public final void complete(boolean logout)
stop()
logout
- True if you want the account to logout if this is the last script in the queue.public void pause()
ScriptExecutor
gets suspended or paused.
Usage of overriding this method could be for example shutting down/pausing/suspending any runnables/threads that run outside
the OSBot threading. Examples of cases where this method gets called are: pausing a script, activation of a random handler.public void resume()
ScriptExecutor
gets resumed.
Usage of overriding this method could be for example resuming any runnables/threads that run outside
the OSBot threading.