Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ project.build.group=net.runelite
project.build.version=1.12.10

glslang.path=
microbot.version=2.1.1
microbot.version=2.1.2
microbot.commit.sha=nogit
microbot.repo.url=http://138.201.81.246:8081/repository/microbot-snapshot/
microbot.repo.username=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.runelite.client.plugins.microbot.ui.MicrobotPluginConfigurationDescriptor;
import net.runelite.client.plugins.microbot.ui.MicrobotPluginListPanel;
import net.runelite.client.plugins.microbot.ui.MicrobotTopLevelConfigPanel;
import net.runelite.client.plugins.microbot.util.bank.Rs2Bank;
import net.runelite.client.plugins.microbot.util.equipment.Rs2Equipment;
import net.runelite.client.plugins.microbot.util.inventory.Rs2Gembag;
import net.runelite.client.plugins.microbot.util.inventory.Rs2Inventory;
Expand Down Expand Up @@ -215,14 +216,18 @@ public void onRuneScapeProfileChanged(RuneScapeProfileChanged event)
public void onItemContainerChanged(ItemContainerChanged event)
{
Microbot.getPouchScript().onItemContainerChanged(event);
if (event.getContainerId() == InventoryID.INV)
if (event.getContainerId() == InventoryID.INV)
{
Rs2Inventory.storeInventoryItemsInMemory(event);
}
else if (event.getContainerId() == InventoryID.WORN)
{
Rs2Equipment.storeEquipmentItemsInMemory(event);
}
else if (event.getContainerId() == InventoryID.BANK)
{
Rs2Bank.updateLocalBank(event);
}
else if (Arrays.stream(getShopContainerIds()).anyMatch(sid -> Objects.equals(event.getContainerId(), sid))) {
Rs2Shop.storeShopItemsInMemory(event, event.getContainerId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import net.runelite.api.*;
import net.runelite.api.coords.WorldArea;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.gameval.InterfaceID;
import net.runelite.api.gameval.ItemID;
import net.runelite.api.gameval.InventoryID;
import net.runelite.api.gameval.VarbitID;
import net.runelite.api.widgets.ComponentID;
import net.runelite.api.widgets.Widget;
Expand Down Expand Up @@ -158,20 +160,56 @@ public static Rectangle itemBounds(Rs2ItemModel rs2Item) {
*
* @return {@code true} if the bank interface is open, {@code false} otherwise.
*/
public static boolean isOpen() {
if (!handleBankPin()) return false;
return Rs2Widget.hasWidgetText("Rearrange mode", 12, 18, false);
}

public static List<Rs2ItemModel> bankItems() {
return rs2BankData.getBankItems();
}

/**
* Closes the bank interface if it is open.
*
* @return true if the bank interface was open and successfully closed, true if already closed.
*/
public static boolean isOpen() {
if (!handleBankPin()) return false;
return Rs2Widget.hasWidgetText("Rearrange mode", 12, 18, false);
}

public static List<Rs2ItemModel> bankItems() {
return rs2BankData.getBankItems();
}

public static void updateLocalBank(ItemContainerChanged event) {
assert Microbot.getClient().isClientThread();

if (event.getContainerId() != InventoryID.BANK || event.getItemContainer() == null) {
return;
}

final Item[] items = event.getItemContainer().getItems();
if (items == null) {
rs2BankData.setEmpty();
return;
}

final List<Rs2ItemModel> bankItems = new ArrayList<>();
for (int slot = 0; slot < items.length; slot++) {
final Item item = items[slot];
if (item == null || item.getId() == -1) {
continue;
}

final ItemComposition itemComposition = Microbot.getClient().getItemDefinition(item.getId());
if (itemComposition.getPlaceholderTemplateId() > 0) {
continue;
}

bankItems.add(new Rs2ItemModel(item, itemComposition, slot));
}

if (bankItems.isEmpty()) {
rs2BankData.setEmpty();
return;
}

rs2BankData.set(bankItems);
}

/**
* Closes the bank interface if it is open.
*
* @return true if the bank interface was open and successfully closed, true if already closed.
*/
public static boolean closeBank() {
if (!isOpen()) return true;
if (Rs2Settings.isEscCloseInterfaceSettingEnabled()) {
Expand Down