External Plugins
Build external n3Client plugins — Gradle dependencies and version pins, the NPlugin loop contract, lifecycle sharp edges, and sideloading.
Build external plugins against the pinned n3Client API. Sideload discovery is ~/.runelite/sideloaded-plugins (ClientPaths.PLUGINS, base-api/src/main/java/dev/n3u/ClientPaths.java:16; pinned by src/test/java/dev/n3u/StorageIsolationTest.java:21-22) and existing files there are not moved. Plugins using the renamed native interfaces must be rebuilt against dev.n3u.api.NClient and the other N interfaces. Source of truth: docs/EXTERNALPLUGIN.md in the n3Client repository.
Getting started
Dependencies
Publish the current modules locally with .\gradlew.bat buildAndPublishAll (on Linux/macOS ./gradlew). The root build composes its artifact version as runeliteVersion + "_" + clientVersion — with runeliteVersion = 1.13.6 and clientVersion = 1 (build.gradle.kts, val clientVersion by extra("1"), version = runeliteVersion + "_" + clientVersion) that is 1.13.6_1, so declare:
val runeliteVersion = "1.13.6"
val clientVersion = "1.13.6_1" // composed artifact version from the n3client build
compileOnly("net.runelite:client:$runeliteVersion")
compileOnly("dev.n3u:base-api:$clientVersion")
compileOnly("dev.n3u:api:$clientVersion")repositories {} needs:
repositories {
mavenLocal()
maven {
url = uri("https://repo.runelite.net")
content {
includeGroupByRegex("net\\.runelite.*")
}
}
mavenCentral()
}Compile with JDK 25 HotSpot (the toolchain the n3client build enforces, build.gradle.kts JavaLanguageVersion.of(25)) and options.release.set(11) for the current artifact boundary.
Plugin structure
Plugins may extend RuneLite's Plugin. The retained native NPlugin supertype additionally provides loop(); its behavior is preserved while higher-level n3 workflow contracts are evaluated.
Sample:
@PluginDescriptor(
name = "Sample Plugin",
description = "A sample NPlugin",
tags = {"n3client", "sample"}
)
public class SampleNPlugin extends NPlugin
{
@Override
public void loop() throws Exception
{
}
}NPlugin extends Plugin and adds the overridable loop() method:
/**
* Overridable loop() method. It is safe to sleep in, but as a result is
* not thread safe, so you must use invoke()'s to do operations that require
* thread safety. It is started from the start of a gametick.
* @throws Exception exception
*/
public void loop() throws Exception
{
}The loop() method is called at the start of every game tick. It is safe to sleep in, but as a result is not thread safe, so you must use invoke()'s to do operations that require thread safety. There is a package of the API designed for use in threaded/looped automation at dev.n3u.api.threaded.*.
Lifecycle (source contract)
- Scheduling:
_onGameTickis a final@SubscribeonGameTick; each tick it submitsloop()to the shared thread pool only if the plugin overridesloop()and the previous run finished (api/src/main/java/dev/n3u/util/NPlugin.java:31-38). A longloop()therefore skips ticks instead of piling up. - Failure: a
RuntimeException("Task cancelled")is logged as an interruption; any other throwable is logged viaLogger.errorand printed — the client keeps running (NPlugin.java:43-59). - Cancellation:
haltLoop(Runnable callback)flips the task-cancelled flag, waits for the future to finish (polling every 10 ms), then runs the callback (NPlugin.java:71-89). Two sharp edges in the current implementation: the callback can run twice — when the loop already finished, it runs immediately and then again from the pool waiter, because the immediate branch has noreturn(NPlugin.java:73-76) — and callinghaltLoopbefore the first loop run throwsNullPointerExceptionon the pool thread (loopFutureis still null inside the waiter'swhile (!loopFuture.isDone()),NPlugin.java:77-88). Make the callback idempotent and only callhaltLoopafter a loop has started.Delays.tick()/wait()are the sleep primitives that observe cancellation (api/src/main/java/dev/n3u/api/threaded/Delays.java). - Sleeping on the client thread is refused:
Delays.waitthrows whenclient.isClientThread(); game-state writes go throughStatic.invoke(see SDK Client Reference for the full thread-affinity table). - Bundled plugins are ordinary examples:
plugins/src/main/java/dev/n3u/plugins/containsauthgen.AuthGenPlugin,bankvaluer.BankValuerPlugin,breakhandler.BreakHandlerPlugin,codeeval.CodeEvalPlugin,multiclientutils.MultiClientUtilPlugin,profiles.ProfilesPlugin(allextends Plugin/NPlugin, verified 2026-11-06). The historical n3plugins inventory indocs/development/PLUGINS.mdanddocs/development/PLUGIN_DEPENDENCIES.mddescribes the migration source, not current-client behavior.
Complete minimal example
import dev.n3u.Logger;
import dev.n3u.api.threaded.Delays;
import dev.n3u.api.entities.PlayerAPI;
import dev.n3u.util.NPlugin;
import net.runelite.client.plugins.PluginDescriptor;
@PluginDescriptor(
name = "Idle Notifier (n3)",
description = "Logs when the local player goes idle",
tags = {"n3client", "sample"}
)
public class IdleNotifierPlugin extends NPlugin
{
private boolean wasIdle = true;
@Override
public void loop() throws Exception
{
boolean idle = PlayerAPI.isIdle(); // safe from worker threads
if (idle && !wasIdle)
{
Logger.info("Local player is idle.");
}
wasIdle = idle;
Delays.tick(); // one game tick; throws on cancel
}
@Override
protected void shutDown() throws Exception // RuneLite lifecycle cleanup
{
// loop future is abandoned with the plugin; no shared resources to release here
}
}- Setup: dependencies above; drop the built JAR into
~/.runelite/sideloaded-plugins(the loader scans JAR files in two directories,Static.RUNELITE_DIR/externalpluginsandClientPaths.PLUGINS—PluginReloader.findJars,api/src/main/java/dev/n3u/services/hotswapper/PluginReloader.java:207-216). - Expected result: on each game tick with a finished previous run, the loop body executes; going from busy to idle logs one line to the embedded console.
- Failure handling: exceptions are logged, not fatal; a blocked tick budget simply skips the loop until the next free tick.
- Cleanup: RuneLite
shutDown(); usehaltLoop(callback)if you must join a running loop before releasing resources.
Choosing between NPlugin, Plugin, and the Script DSL
| Need | Use |
|---|---|
| Per-tick automation that sleeps | NPlugin.loop() + dev.n3u.api.threaded |
| Event listeners, overlays, config | plain RuneLite Plugin (everything in the SDK is callable from it) |
| Sequential workflows with waits/branches | Script DSL — docs/SCRIPT-DSL.md in the repository (Script.build/Script.execute, never on the client thread) |
| Bank/NPC/object choreography | handler builders — SDK Widgets Reference |
Known limits
- The
loop()thread pool is shared (NPlugin.java:38submits toThreadPool); a long-blocking loop starves other plugins' loops rather than the client. @PluginDescriptoron anNPluginstill requires the class to be discoverable by RuneLite's plugin scan; sideloaded JARs are scanned perPluginReloader(inference from the scan flow; per-JAR discovery details live in the hotswapper implementation).- Live startup behavior (plugin enable/disable in the running client) is a foundation-gate item and was not exercised for this page — source contracts only.
SDK Pathfinder Reference
The pathfinder module — blocking Walker, WalkerPath teleport-and-steps plans, five algorithms, collision/transport/teleport data, strategic pathing, and boat pathing.
Mouse Movement
Trajectory-based mouse movement — recording, generation, rapid action mode, every setting and default, common configurations, and the packet-level encoding.