Kraken Community API in Java - RSKrakenCommunity/CommunityAPI GitHub Wiki
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.
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() {
}
}
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;
ItemDefinition whip = CacheHelper.getItem(4151);
NpcDefinition npc = CacheHelper.getNpc(1);
ObjectDefinition object = CacheHelper.getObject(1226);
VarbitDefinition lumbridgeLodstoneUnlocked = CacheHelper.getVarbit(35);
InventoryDefinition playerInventory = CacheHelper.getInventory(93);
RegionDefinition edgeVille = CacheHelper.getRegion(12342);
List<VarbitDefinition> varbits = CacheHelper.findVarbitsFor(4265);
import com.rshub.api.world.WorldHelper;
WorldNpc doris = WorldHelper.closestNpc(npc -> npc.getName().equalsIgnoreCase("Doris"));
WorldObject stove = WorldHelper.closestObject(object -> object.getName().equalsIgnoreCase("Stove"));
WorldItem item = WorldHelper.closestGroundItem(i -> i.getName().equalsIgnoreCase("Abyssal Whip"));
WorldPlayer bob = WorldHelper.closestPlayer(plr -> plr.getPlayer().getName().equalsIgnoreCase("Bob"));
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;
VariableBit is Varbit VariablePlayer is ConVar
VariableHelper.registerVariable("lodestone", "lumbridge", new VariableBit(35));
boolean isUnlocked = VariableHelper.getVariable("lodestone", "lumbridge") == 1;
boolean isUnlocked2 = VariableHelper.getVariableByName("lodestone:lumbridge") == 1;
Map<String, Variable> lodestoneVars = VariableHelper.getVariables("lodestone");
Variable var = lodestoneVars.get("lumbridge");
boolean isUnlocked3 = var.getValue() == 1;
import com.rshub.api.containers.Inventory;
import com.rshub.api.containers.InventoryHelper;
Inventory bankContainer = InventoryHelper.getInventory(95);
bankContainer.addListener((integer, item, item2) -> {
//Listen to changes on this item container
return Unit.INSTANCE;
});
import com.rshub.api.widgets.BankHelper;
import com.rshub.api.widgets.WidgetHelper;
Inventory inv = InventoryHelper.getInventory(92);
BindingHelper.bind(BankHelper.getBank(), inv);