feat(huntkit): wire kit cache + add helpers#1754
Conversation
AgentServer Security fixes + Fix POH teleport utilities and Rs2Walker behavior in instances
2.5.1 fixes interfacetab
Forward InventoryID.HUNTSMANS_KIT container events to Rs2HuntKit, add HuntKit util + docs. Made-with: Cursor
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis change introduces a new 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
docs/api/Rs2HuntKit.mdrunelite-client/src/main/java/net/runelite/client/plugins/microbot/MicrobotPlugin.javarunelite-client/src/main/java/net/runelite/client/plugins/microbot/util/huntkit/Rs2HuntKit.java
| 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"); | ||
| } |
There was a problem hiding this comment.
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.
| 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"); | |
| } | |
| 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 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"); | |
| } |
🤖 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.
| public static boolean withdrawItem(boolean checkInv, String name, boolean exact) | ||
| { | ||
| if (checkInv && Rs2Inventory.hasItem(name)) | ||
| { | ||
| return true; | ||
| } | ||
| return withdrawOne(name, exact); | ||
| } |
There was a problem hiding this comment.
🧩 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 1225withdrawFive(boolean checkInv, String name, boolean exact)— Line 1339withdrawX(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.
Forward InventoryID.HUNTSMANS_KIT container events to Rs2HuntKit, add HuntKit util + docs.