-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create an interface for external plugins #48
base: master
Are you sure you want to change the base?
Conversation
Both the Screen Markers plugin and the Loot Tracker plugin in core RuneLite have enable/disable icons made by Psikoi that I believe are under RuneLite's BSD-2 license. |
I like the look of that icon in the panel. It makes sense and I cannot think of anything better at the moment. |
hide-marker param now expected to be a valid boolean Supress unchecked cast warnings
Minor update: |
* More consistent variable naming * Small clean-up in PluginPathManager
components.add(separator); | ||
|
||
components.add(makeText("Path Owner:")); | ||
String requester = currentParameters.getRequester().getFullyQualifiedName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I prefer seeing Shortest Path
and Quest Helper
instead of shortestpath.ShortestPathPlugin
and questhelper.QuestHelperPlugin
here, so maybe change this to getName()
? Plugin names are not required to be unique, but I think they all are.
runelite/runelite#16863 was added in runelite/runelite@0b12333 |
This PR is incomplete, namely UI and API is not finalized. I'm publishing it to receive feedback from others.
Overview
A common request I see from other plugin developers is wanting some way to interface with shortest path but there currently doesn't exist a way to do so. This PR proposes a potential API that can be exposed to external plugins to allow them to make requests while also allowing users to control which paths are visible and prioritize which plugin paths should override other paths.
HashMap
to transfer data until some form of Plugin Messaging event is added to RuneLite, a la: Add PluginMessage event runelite/runelite#16863requestPath
code path as external plugins.startUp
andshutDown
functions to avoid redundantly loading data in-case the user toggles the plugin on/off.Notes
Video Demo
Video demonstrates that shortest-path's normal functions still work as expected, but also that other plugins (e.x. Quest Helper) can interface with it. Plugins can be re-ordered and paths hidden via the side panel. Shortest Path still tracks request/clear commands even if it's disabled so that the data remains current the next time it's enabled.
2023-08-02.12-45-46.mp4
API
This initial proposal is meant to implement the bare minimum feature-set most people want and that can be easily maintained going forward. Additional features like changing pathfinding options, drawing multiple paths, changing path colors, etc., are out of the intended scope of this PR.
Plugins interface over the
EventBus
by passing a hashmap of typeHashMap<String, Object>
containing the required parameters. Any invalid requests or requests with invalid/missing parameters are ignored and a debug message printed. For simplicity, the API is entirely one-way communication and Shortest Path does not send responses or acknowledgements back to requesters. Here is a working example class that external plugins can use directly to interface with shortest path or use as a reference.Internally, the API side is handled by
ShortestPathAPI.java
. It validates that the objects received are the correct types and prints debug messages when it receives invalid requests or parameters; these messages can be seen in logs or when RuneLite is run with the--debug
argument.Required Parameters
There are a few parameters that are required in all events:
plugin
command
shortestpath:
followed by the command.Commands
request-path
: Asks shortest path to try and draw a path from the player's position or start point to the target point. The requested path will only be drawn if no other plugin has an active path or the requesting plugin is higher on the user's priority list than other plugins with active paths.clear-path
: Clears any paths set by the requesting plugin; does not affect other plugins paths.Some commands may have additional parameters as listed below.
request-path
Command:target
start
null
, then the player's position is used as the start point.hide-marker
true
, shortest path won't draw the target "marker" overlay on the world map. This is useful to plugins like Quest Helper that already draw their own world map marker.