-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
371 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
runelite-client/src/main/java/ext/ethans/QuickPrayerExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ext.ethans | ||
|
||
import com.example.EthanApiPlugin.Collections.query.QuickPrayer | ||
import com.example.EthanApiPlugin.EthanApiPlugin | ||
|
||
object QuickPrayerExt { | ||
/** | ||
* Checks whether an individual quick prayer is active | ||
*/ | ||
fun QuickPrayer.isActive() : Boolean { | ||
return EthanApiPlugin.isQuickPrayerActive(this) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,46 @@ | ||
package ext.runelite | ||
|
||
import com.example.EthanApiPlugin.Collections.query.QuickPrayer | ||
import com.example.EthanApiPlugin.EthanApiPlugin | ||
import ext.kotlin.KClassExt.getInstance | ||
import ext.runelite.PluginManagerExt.get | ||
import hotlite.plugins.scriptmanager.ScriptManager | ||
import net.runelite.api.ChatMessageType | ||
import net.runelite.api.Client | ||
import net.runelite.api.widgets.Widget | ||
import net.runelite.api.widgets.WidgetInfo | ||
import net.runelite.client.plugins.Plugin | ||
import net.runelite.client.plugins.PluginManager | ||
|
||
object PluginExt { | ||
val client = Client::class.getInstance() | ||
val pluginManager = PluginManager::class.getInstance() | ||
|
||
inline fun <reified T> Plugin.getInjectedInstance(): T { | ||
return injector.getInstance(T::class.java) | ||
} | ||
|
||
fun Plugin.loggedIn() : Boolean { | ||
return EthanApiPlugin.loggedIn() | ||
} | ||
|
||
fun Plugin.getClient() : Client { | ||
return EthanApiPlugin.getClient() | ||
} | ||
|
||
fun Plugin.isQuickPrayerEnabled() : Boolean { | ||
return EthanApiPlugin.isQuickPrayerEnabled() | ||
} | ||
|
||
fun Plugin.sendGameMessage(message: String) { | ||
getClient().addChatMessage(ChatMessageType.GAMEMESSAGE, "", message, "") | ||
} | ||
|
||
fun Plugin.getWidget(group: Int, child: Int): Widget? { | ||
return client.getWidget(WidgetInfo.PACK(group, child)) | ||
} | ||
|
||
fun Plugin.getScriptManager() : ScriptManager { | ||
return pluginManager.get<ScriptManager>() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
package ext.runelite | ||
|
||
import net.runelite.api.Client | ||
import net.runelite.api.Prayer | ||
|
||
object PrayerExt { | ||
fun Prayer.blah() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
package ext.runelite | ||
|
||
import com.example.Packets.WidgetPackets | ||
import net.runelite.api.widgets.Widget | ||
|
||
object WidgetExt { | ||
fun Widget.doAction(action: String) { | ||
WidgetPackets.queueWidgetAction(this, action) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package hotlite.api | ||
|
||
import net.runelite.api.Client | ||
import net.runelite.client.RuneLite | ||
|
||
open class Varp(val id: Int) { | ||
private var client = RuneLite.getInjector().getInstance(Client::class.java) | ||
fun getValue() : Int { | ||
return client.getVarpValue(id) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
runelite-client/src/main/java/hotlite/api/varp/TutorialProgressVarp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package hotlite.api.varp | ||
|
||
import hotlite.api.Varp | ||
|
||
object TutorialProgressVarp : Varp(281) { | ||
const val CHOOSE_NAME = 1 | ||
} |
8 changes: 8 additions & 0 deletions
8
runelite-client/src/main/java/hotlite/plugins/example/ExamplePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
runelite-client/src/main/java/hotlite/plugins/scriptmanager/Script.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package hotlite.plugins.scriptmanager | ||
|
||
import com.example.EthanApiPlugin.EthanApiPlugin | ||
import ext.kotlin.KClassExt.getInstance | ||
import ext.runelite.PluginManagerExt.get | ||
import net.runelite.api.Client | ||
import net.runelite.api.widgets.Widget | ||
import net.runelite.api.widgets.WidgetInfo | ||
import net.runelite.client.RuneLite | ||
import net.runelite.client.plugins.PluginManager | ||
|
||
open class Script(var priority: Int = Int.MAX_VALUE-1) { | ||
val client = Client::class.getInstance() | ||
val childScripts = arrayListOf<Script>() | ||
var message: String = "" | ||
val ethans = PluginManager::class.getInstance().get<EthanApiPlugin>() | ||
open fun onGameTick() : ((Script) -> ScriptState)? = null | ||
|
||
fun getWidget(group: Int, child: Int): Widget? { | ||
return client.getWidget(WidgetInfo.PACK(group, child)) | ||
} | ||
|
||
fun error(message: String) : ScriptState { | ||
println("ERROR: $message") | ||
return ScriptState.ABORTED | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
runelite-client/src/main/java/hotlite/plugins/scriptmanager/ScriptManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package hotlite.plugins.scriptmanager | ||
|
||
import net.runelite.api.events.GameTick | ||
import net.runelite.client.eventbus.Subscribe | ||
import net.runelite.client.plugins.Plugin | ||
import net.runelite.client.plugins.PluginDescriptor | ||
|
||
/** | ||
* This controls the execution flow of [Script]s and their childScripts | ||
*/ | ||
@PluginDescriptor( | ||
name = "Z-ScriptManager", | ||
description = "Script runner", | ||
tags = ["kotlin"] | ||
) | ||
class ScriptManager : Plugin(){ | ||
val scripts = ArrayList<Script>() | ||
val scriptsPendingRemoval = ArrayList<Script>() | ||
|
||
fun onGameTickExecution(script: Script, execution: ((Script) -> ScriptState)) { | ||
val result = execution.invoke(script) | ||
when (result) { | ||
ScriptState.RUNNING -> {} | ||
ScriptState.PAUSED -> {} | ||
ScriptState.FINISHED -> { | ||
scriptsPendingRemoval.add(script) | ||
} | ||
ScriptState.ABORTED -> { | ||
scriptsPendingRemoval.add(script) | ||
} | ||
} | ||
} | ||
|
||
fun ArrayList<Script>.priorityForEach(unit: (Script) -> ScriptState?) { | ||
this | ||
.sortedBy { it.priority } | ||
.forEach { | ||
val result = unit.invoke(it) | ||
} | ||
} | ||
|
||
@Subscribe | ||
private fun onGameTick(gameTick: GameTick) { | ||
try { | ||
scripts.priorityForEach { script -> | ||
val rootResult = script.onGameTick()?.invoke(script) | ||
script.childScripts.priorityForEach { childScript -> | ||
childScript.onGameTick()?.invoke(childScript) | ||
} | ||
return@priorityForEach rootResult | ||
} | ||
|
||
scriptsPendingRemoval.forEach { scripts.remove(it) } | ||
} catch (e: Exception) { | ||
println("Uncaught Script Exception:") | ||
e.printStackTrace() | ||
} | ||
} | ||
|
||
fun registerScript(script: Script) { | ||
scripts.add(script) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
runelite-client/src/main/java/hotlite/plugins/scriptmanager/ScriptState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package hotlite.plugins.scriptmanager | ||
|
||
enum class ScriptState { | ||
RUNNING, | ||
PAUSED, | ||
FINISHED, | ||
ABORTED | ||
} |
70 changes: 70 additions & 0 deletions
70
runelite-client/src/main/java/hotlite/plugins/tutorial/ChooseNameScript.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package hotlite.plugins.tutorial | ||
|
||
import com.example.Packets.MousePackets | ||
import com.example.Packets.WidgetPackets | ||
import hotlite.plugins.scriptmanager.Script | ||
import hotlite.plugins.scriptmanager.ScriptState | ||
import net.runelite.api.widgets.Widget | ||
|
||
object ChooseNameScript : Script() { | ||
override fun onGameTick(): (Script) -> ScriptState = script@{ | ||
fetchSetDisplayNameRootWidget()?.let { rootWidget -> | ||
if (rootWidget.isHidden) | ||
return@script error("SetDisplayNameRootWidget must not be hidden") | ||
else { | ||
fetchSetDisplayNameTextFieldWidget()?.let { textField -> | ||
if (textField.isHidden) | ||
return@script error("SetDisplayNameTextFieldWidget must not be hidden") | ||
else { | ||
/* if (textField.text != "AliBaba") { | ||
textField.setText("AliBaba") | ||
return@script ScriptState.PAUSED | ||
}*/ | ||
fetchLookupNameButtonWidget()?.let { | ||
if (it.onOpListener != null) { | ||
println("sending packet") | ||
lookupName() | ||
return@script ScriptState.PAUSED | ||
} else { | ||
|
||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
return@script ScriptState.RUNNING | ||
} | ||
|
||
fun fetchSetDisplayNameRootWidget(): Widget? { | ||
return getWidget(558, 3) | ||
} | ||
|
||
fun fetchSetDisplayNameTextFieldWidget(): Widget? { | ||
return getWidget(558, 12) | ||
} | ||
|
||
fun fetchNameAvailabilityResponseTextWidget(): Widget? { | ||
return getWidget(558, 13) | ||
} | ||
|
||
fun fetchLookupNameButtonWidget(): Widget? { | ||
return getWidget(558, 18) | ||
} | ||
|
||
fun lookupName() { | ||
fetchLookupNameButtonWidget()?.let { | ||
if (it.onOpListener.isEmpty()) { | ||
//name already taken and text field not edited yet | ||
} else { | ||
MousePackets.queueClickPacket() | ||
WidgetPackets.queueWidgetActionPacket(1, it.id, it.itemId, it.index) | ||
} | ||
} | ||
} | ||
|
||
private fun Widget.lookupName() { | ||
|
||
} | ||
} |
Oops, something went wrong.