Skip to content

Instantly share code, notes, and snippets.

@chsami
Created May 20, 2023 21:31
Show Gist options
  • Save chsami/8a3674203e49543947d3649bfad4aadd to your computer and use it in GitHub Desktop.
Save chsami/8a3674203e49543947d3649bfad4aadd to your computer and use it in GitHub Desktop.
Example Plugin Runelite
package net.runelite.client.plugins.example;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.events.GameStateChanged;
import net.runelite.client.Mouse;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import javax.inject.Inject;
@PluginDescriptor(
name = "1. Example plugin",
description = "Example plugin",
tags = {"example"}
)
public class ExamplePlugin extends Plugin {
@Inject
Client client;
boolean runScript = false;
@Override
protected void startUp() {
net.runelite.client.Mouse.setClient(client);
runScript = true;
loop();
System.out.println("Plugin started");
}
@Override
protected void shutDown() {
runScript = false;
System.out.println("Plugin stopped");
}
@Subscribe
public void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGGED_IN) {
System.out.println("Game started");
}
}
public void loop() {
int sleep = 1000000;
while (runScript) {
if (sleep <= 0) {
net.runelite.api.NPC npc = client
.getNpcs()
.stream()
.filter(x -> x.getName().toLowerCase().equals("chicken"))
.findFirst()
.orElse(null);
if (npc != null) {
Mouse.click(npc.getCanvasTilePoly());
}
sleep = 1000000;
}
System.out.println(sleep);
sleep--;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment