Kraken Community API in Java - RSKrakenCommunity/CommunityAPI GitHub Wiki

Alt Text Alt Text

Welcome to Kraken's Community API

There are two kinds of plugins the Java Plugin and the Kotlin Plugin. The Kotlin plugin allows the developer to write code with the support of kotlin coroutines in mind.

Creating a Java Plugin

import com.rshub.api.plugin.JavaPlugin;

public class ExampleBot extends JavaPlugin {

    public ExampleBot() {
        super("Example Bot");
    }

    @Override
    protected void onLoad() {
    }

    @Override
    public int onLoop() {
        return super.onLoop();
    }
    
    @Override
    public void onPaint() {
    }
}

RuneScape Cache Methods

The CacheHelper class provides access to different RuneScape 3 definitions. RuneScape definitions provide information about items, objects, NPCs, game state, etc.

import com.rshub.api.definitions.CacheHelper;

Item Definitions

ItemDefinition whip = CacheHelper.getItem(4151);

Npc Definitions

NpcDefinition npc = CacheHelper.getNpc(1);

Object Definitions

ObjectDefinition object = CacheHelper.getObject(1226);

Varbit Definitions

VarbitDefinition lumbridgeLodstoneUnlocked = CacheHelper.getVarbit(35);

Inventory Definitions (Item Containers)

InventoryDefinition playerInventory = CacheHelper.getInventory(93);

Region Definitions

RegionDefinition edgeVille = CacheHelper.getRegion(12342);

Finding Varbits Linked to Varps (ConVars)

List<VarbitDefinition> varbits = CacheHelper.findVarbitsFor(4265);

World Methods

import com.rshub.api.world.WorldHelper;

Finding Closest Npc

WorldNpc doris = WorldHelper.closestNpc(npc -> npc.getName().equalsIgnoreCase("Doris"));

Finding Closest Object

WorldObject stove = WorldHelper.closestObject(object -> object.getName().equalsIgnoreCase("Stove"));

Finding Closest Ground Item

WorldItem item = WorldHelper.closestGroundItem(i -> i.getName().equalsIgnoreCase("Abyssal Whip"));

Finding Closest Player

WorldPlayer bob = WorldHelper.closestPlayer(plr -> plr.getPlayer().getName().equalsIgnoreCase("Bob"));

Variable Methods (Varbits and ConVars)

import com.rshub.api.variables.VariableHelper;
import com.rshub.api.variables.Variable;
import com.rshub.api.variables.impl.VariableBit;
import com.rshub.api.variables.impl.VariablePlayer;

Registering Variables

VariableBit is Varbit VariablePlayer is ConVar

VariableHelper.registerVariable("lodestone", "lumbridge", new VariableBit(35));

Using Variables

boolean isUnlocked = VariableHelper.getVariable("lodestone", "lumbridge") == 1;
boolean isUnlocked2 = VariableHelper.getVariableByName("lodestone:lumbridge") == 1;

Finding all variables for a given namespace

Map<String, Variable> lodestoneVars = VariableHelper.getVariables("lodestone");
Variable var = lodestoneVars.get("lumbridge");
boolean isUnlocked3 = var.getValue() == 1;

Item Containers

import com.rshub.api.containers.Inventory;
import com.rshub.api.containers.InventoryHelper;

Listening to changes on an item container

Inventory bankContainer = InventoryHelper.getInventory(95);
        bankContainer.addListener((integer, item, item2) -> {
            //Listen to changes on this item container
            return Unit.INSTANCE;
        });

Widgets

import com.rshub.api.widgets.BankHelper;
import com.rshub.api.widgets.WidgetHelper;

Binding Item Containers to Widgets

Inventory inv = InventoryHelper.getInventory(92);
BindingHelper.bind(BankHelper.getBank(), inv);
⚠️ **GitHub.com Fallback** ⚠️