Skip to content

feat(huntkit): wire kit cache + add helpers#1754

Merged
chsami merged 7 commits into
chsami:developmentfrom
TheHaliax:Rs2HuntKit
May 3, 2026
Merged

feat(huntkit): wire kit cache + add helpers#1754
chsami merged 7 commits into
chsami:developmentfrom
TheHaliax:Rs2HuntKit

Conversation

@TheHaliax
Copy link
Copy Markdown
Contributor

Forward InventoryID.HUNTSMANS_KIT container events to Rs2HuntKit, add HuntKit util + docs.

chsami and others added 4 commits April 15, 2026 11:47
AgentServer Security fixes + Fix POH teleport utilities and Rs2Walker behavior in instances
Forward InventoryID.HUNTSMANS_KIT container events to Rs2HuntKit, add HuntKit util + docs.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8c22408c-abec-4792-a023-6e3907483148

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This change introduces a new Rs2HuntKit utility class that manages Huntsman's kit interface interactions. The implementation includes an in-memory cache of kit contents updated via ItemContainerChanged events, UI control methods for opening/closing the kit interface, query and stream utilities for inspecting kit items, and deposit/withdraw operations mirroring patterns from similar utility classes. The MicrobotPlugin is updated to route ItemContainerChanged events from the HUNTSMANS_KIT container to the new class for cache updates. Supporting API documentation is added explaining the class behavior, constants, and usage patterns.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.66% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: wiring the kit cache and adding helper methods for HuntKit functionality.
Description check ✅ Passed The description clearly relates to the changeset by explaining the forwarding of container events and addition of HuntKit utilities and documentation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/huntkit/Rs2HuntKit.java`:
- Around line 225-240: The fill() method lacks the same open-guard as
emptyKit(), causing inconsistent behavior when the kit UI is open; update fill()
(the method that currently calls Rs2Inventory.interact(KIT_ITEM_ID, "Fill") ||
Rs2Inventory.interact(KIT_NAME, "Fill")) to return false early if isOpen() is
true, mirroring emptyKit() and the documented in-game rule so both methods
consistently check isOpen() before calling Rs2Inventory.interact.
- Around line 1225-1232: The inventory pre-checks in withdrawItem, withdrawFive
and withdrawX ignore the exact flag by calling Rs2Inventory.hasItem(name) (fuzzy
match); change those branches to call the exact-aware overload (e.g.,
Rs2Inventory.hasItem(name, exact) or the correct signature provided by
Rs2Inventory) so the short-circuit honors the exact parameter, and keep the
existing fallback to withdrawOne/withdrawFive/withdrawX calls when the item is
not present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7ef4c261-43ca-4938-b998-224351b9fde7

📥 Commits

Reviewing files that changed from the base of the PR and between 167777b and 30cbb9f.

📒 Files selected for processing (3)
  • docs/api/Rs2HuntKit.md
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.java
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/huntkit/Rs2HuntKit.java

Comment on lines +225 to +240
public static boolean fill()
{
return Rs2Inventory.interact(KIT_ITEM_ID, "Fill") || Rs2Inventory.interact(KIT_NAME, "Fill");
}

/**
* Empties the kit via inventory "Empty" (only valid when kit UI is closed — same as in-game).
*/
public static boolean emptyKit()
{
if (isOpen())
{
return false;
}
return Rs2Inventory.interact(KIT_ITEM_ID, "Empty") || Rs2Inventory.interact(KIT_NAME, "Empty");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

fill() missing the open-guard that emptyKit() enforces.

Both helpers document the same in-game rule ("kit must be closed"), yet only emptyKit() returns early when isOpen(). fill() will lean on the underlying Rs2Inventory.interact(..., "Fill") failing because the option is absent while the UI is open, but the asymmetry with emptyKit() (and with the doc on Lines 22 and 24) is just begging to bite a future reader.

🩹 Suggested symmetry
 public static boolean fill()
 {
+    if (isOpen())
+    {
+        return false;
+    }
     return Rs2Inventory.interact(KIT_ITEM_ID, "Fill") || Rs2Inventory.interact(KIT_NAME, "Fill");
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static boolean fill()
{
return Rs2Inventory.interact(KIT_ITEM_ID, "Fill") || Rs2Inventory.interact(KIT_NAME, "Fill");
}
/**
* Empties the kit via inventory "Empty" (only valid when kit UI is closedsame as in-game).
*/
public static boolean emptyKit()
{
if (isOpen())
{
return false;
}
return Rs2Inventory.interact(KIT_ITEM_ID, "Empty") || Rs2Inventory.interact(KIT_NAME, "Empty");
}
public static boolean fill()
{
if (isOpen())
{
return false;
}
return Rs2Inventory.interact(KIT_ITEM_ID, "Fill") || Rs2Inventory.interact(KIT_NAME, "Fill");
}
/**
* Empties the kit via inventory "Empty" (only valid when kit UI is closedsame as in-game).
*/
public static boolean emptyKit()
{
if (isOpen())
{
return false;
}
return Rs2Inventory.interact(KIT_ITEM_ID, "Empty") || Rs2Inventory.interact(KIT_NAME, "Empty");
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/huntkit/Rs2HuntKit.java`
around lines 225 - 240, The fill() method lacks the same open-guard as
emptyKit(), causing inconsistent behavior when the kit UI is open; update fill()
(the method that currently calls Rs2Inventory.interact(KIT_ITEM_ID, "Fill") ||
Rs2Inventory.interact(KIT_NAME, "Fill")) to return false early if isOpen() is
true, mirroring emptyKit() and the documented in-game rule so both methods
consistently check isOpen() before calling Rs2Inventory.interact.

Comment on lines +1225 to +1232
public static boolean withdrawItem(boolean checkInv, String name, boolean exact)
{
if (checkInv && Rs2Inventory.hasItem(name))
{
return true;
}
return withdrawOne(name, exact);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
ast-grep --pattern $'public static boolean hasItem($$$) { $$$ }'
ast-grep --pattern $'public static boolean hasItemAmount($$$) { $$$ }'

Repository: chsami/Microbot

Length of output: 8723


Use exact-aware Rs2Inventory overloads in checkInv branches.

The exact parameter is honored when querying the kit but dropped on inventory pre-checks in these three methods:

  • withdrawItem(boolean checkInv, String name, boolean exact) — Line 1225
  • withdrawFive(boolean checkInv, String name, boolean exact) — Line 1339
  • withdrawX(boolean checkInv, String name, int amount, boolean exact) — Line 1428

When checkInv=true, Rs2Inventory.hasItem(name) uses fuzzy matching, so a caller passing exact=true can short-circuit on an unrelated inventory item, bypassing the intended withdrawal.

Apply exact-aware overloads
 public static boolean withdrawItem(boolean checkInv, String name, boolean exact)
 {
-    if (checkInv && Rs2Inventory.hasItem(name))
+    if (checkInv && Rs2Inventory.hasItem(name, exact))
     {
         return true;
     }
     return withdrawOne(name, exact);
 }
 public static boolean withdrawFive(boolean checkInv, String name, boolean exact)
 {
-    if (checkInv && Rs2Inventory.hasItemAmount(name, 5))
+    if (checkInv && Rs2Inventory.hasItemAmount(name, 5, false, exact))
     {
         return true;
     }
     return withdrawFive(name, exact);
 }
 public static boolean withdrawX(boolean checkInv, String name, int amount, boolean exact)
 {
-    if (checkInv && Rs2Inventory.hasItemAmount(name, amount))
+    if (checkInv && Rs2Inventory.hasItemAmount(name, amount, false, exact))
     {
         return true;
     }
     return withdrawX(name, amount, exact);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/huntkit/Rs2HuntKit.java`
around lines 1225 - 1232, The inventory pre-checks in withdrawItem, withdrawFive
and withdrawX ignore the exact flag by calling Rs2Inventory.hasItem(name) (fuzzy
match); change those branches to call the exact-aware overload (e.g.,
Rs2Inventory.hasItem(name, exact) or the correct signature provided by
Rs2Inventory) so the short-circuit honors the exact parameter, and keep the
existing fallback to withdrawOne/withdrawFive/withdrawX calls when the item is
not present.

checkInv short-circuits must use the same name semantics as
withdraw*; quantity checks keep stackable vs slot count correct.
Remove client-thread branching for Deposit-X/Withdraw-X and document client-thread sleepUntil behavior. Regenerate client-thread guardrail baseline.
@chsami chsami merged commit fe71cce into chsami:development May 3, 2026
2 checks passed
@TheHaliax TheHaliax deleted the Rs2HuntKit branch May 5, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants