Annotations

Understand RuneLite annotations and how they configure your plugin.

Annotations are special markers you add to your code that tell RuneLite how to handle your plugin. Think of them like labels that give instructions to RuneLite.


Common Annotations


@PluginDescriptor

**Required for all plugins!** Tells RuneLite about your plugin:


@PluginDescriptor(

name = "My Plugin",

description = "What my plugin does"

)


@Inject

Tells RuneLite to provide an object automatically:


@Inject

private Client client; // RuneLite provides the Client


@Subscribe

Marks a method as an event listener:


@Subscribe

public void onGameTick(GameTick event) {

// This method receives GameTick events

}


@ConfigItem

Defines a configuration setting (see Configuration concept).


How Annotations Work


Annotations don't change how your code runs - they're metadata. RuneLite reads these annotations at runtime and uses them to:

- Register your plugin

- Inject dependencies

- Subscribe to events

- Create config UI


Best Practices


- Always use @PluginDescriptor

- Use @Inject for RuneLite services

- Use @Subscribe for event handlers

- RuneLite automatically registers @Subscribe methods — no manual EventBus registration needed

Code Examples

Example 1

java
1// Complete plugin with annotations
2@PluginDescriptor(
3    name = "Example Plugin",
4    description = "An example plugin"
5)
6public class ExamplePlugin extends Plugin {
7    @Inject
8    private Client client;
9    
10    // No EventBus injection needed — @Subscribe is auto-registered
11    
12    @Subscribe
13    public void onGameTick(GameTick event) {
14        // Handle event - automatically registered!
15    }
16}