Skip to content

Comments

Barrows: Improved readability, removed a lot of duplicate code.#1386

Merged
gmason0 merged 5 commits intochsami:developmentfrom
Gage307:development
Aug 24, 2025
Merged

Barrows: Improved readability, removed a lot of duplicate code.#1386
gmason0 merged 5 commits intochsami:developmentfrom
Gage307:development

Conversation

@Gage307
Copy link
Contributor

@Gage307 Gage307 commented Aug 18, 2025

I see my commits from 2 days ago were also included in this PR. These were already merged. Let me know if I need to fix it; sorry about that.

Summary by CodeRabbit

  • New Features

    • Automatic anti-ban setup and activity tracking when starting the Blue Dragons plugin.
  • Improvements

    • Barrows: Smarter, per-opponent prayer activation and more reliable combat engagement to reduce stalls.
    • Barrows: Streamlined supplies and banking checks for faster decisions and fewer interruptions.
    • Barrows: Prioritized Forgotten brew usage for quicker boosts.
    • Barrows: More robust chest interaction and tunnel progression, with better handling when targets are lost or defeated.
    • Blue Dragons: Minor looting flow tidy-up (no behavioral change).

@gmason0
Copy link
Contributor

gmason0 commented Aug 19, 2025

@Gage307 - Can you please rebase this branch to remove the old commits from the pull request.

@Gage307
Copy link
Contributor Author

Gage307 commented Aug 19, 2025

@Gage307 - Can you please rebase this branch to remove the old commits from the pull request.

Oh I see, thank you as always!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Refactors Barrows combat flow by introducing parameterized prayer activation and consolidating brother detection/fighting into a new method. Streamlines supply/banking and brew consumption. Adjusts tunnel/chest interaction calls accordingly. Adds anti-ban initialization to Blue Dragons plugin startup. Blue Dragons script sees whitespace-only edits.

Changes

Cohort / File(s) Summary of changes
Barrows combat/prayer refactor
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java
Removed unused imports; simplified boolean checks; changed activatePrayer() to activatePrayer(Rs2PrayerEnum); replaced checkForBrother(...) with checkForAndFightBrother(...) and updated all call sites; reworked fight loop using hint-arrow and proximity checks; dynamic prayer selection; disable prayer on exit/death; prioritized Forgotten brew consumption; streamlined supplies/banking logic with early returns; adjusted chest/tunnel handling.
Blue Dragons anti-ban init
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java
On startup, initializes anti-ban: activateAntiban(), resetAntibanSettings(), applies combat setup template, and sets activity to KILLING_BLUE_DRAGONS.
Whitespace tidy (no logic changes)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsScript.java
Minor whitespace adjustments in handleLooting; no functional changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant P as Player
  participant BS as BarrowsScript
  participant PM as Prayer Manager
  participant B as Barrows Brother (NPC)
  participant H as Hint Arrow

  Note over BS: New flow
  P->>BS: Start run / step
  BS->>BS: checkForAndFightBrother(config)
  alt Brother present (mound/tunnel)
    BS->>H: Read target from hint arrow
    BS->>PM: activatePrayer(prayer)
    loop Engage until death/lost
      BS->>B: Attack / Re-attack if needed
      BS->>BS: Validate LOS / proximity (tunnel guards)
      H-->>BS: Update arrow status
      alt Brother dead or arrow lost
        BS->>PM: deactivate prayer
        BS-->>P: Exit fight path
      end
    end
  else No brother
    BS-->>P: Continue navigation/open chest/etc.
  end
Loading
sequenceDiagram
  autonumber
  participant BD as BlueDragonsPlugin
  participant AB as Anti-Ban System
  participant T as Setup Templates
  participant ACT as Activity Tracker

  BD->>BD: startUp()
  BD->>AB: activateAntiban()
  BD->>AB: resetAntibanSettings()
  BD->>T: applyCombatSetup()
  BD->>ACT: setActivity(KILLING_BLUE_DRAGONS)
  BD-->>BD: Proceed to script run
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Rs2Bank.depositAll("Blue dragonhide");
}
logOnceToChat("Withdrawing food for combat.", true, config);
String[] thingsWeWantToKeep = {config.foodType().getName(), "Law rune", "Air rune", "Water rune", "Falador teleport", "Dusty key"};
Copy link
Owner

Choose a reason for hiding this comment

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

isn't this dependant on what you use for your teleport? I can understand some people would like to bank runes for extra space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. have Falador teleport (runes/teletab) - from the description of the plugin.

The only time the inventory will have law, air, or water runes is if the user wants to use their spell book teleports. Otherwise they'd just be using a tablet. The script won't pickup those runes; they're too low value.

Copy link
Contributor

@gmason0 gmason0 left a comment

Choose a reason for hiding this comment

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

I appreciate your continued efforts in your plugins gage!

When you have some time, if you could please take a look at the microbot plugin hub project & start to see how you can migrate your plugins over to the plugin hub!

https://github.com/chsami/microbot-hub

@gmason0
Copy link
Contributor

gmason0 commented Aug 23, 2025

@Gage307 - Are you able to resolve merge conflicts here?

Copy link
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: 1

🧹 Nitpick comments (7)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java (1)

47-55: Initialize anti-ban before starting the script — add cleanup on shutdown.

Startup sequence makes sense: activate -> reset -> apply combat template -> set activity. To prevent anti-ban state leaking into other plugins after this one stops, reset anti-ban in shutDown() (and optionally set a neutral activity if the API supports it).

Apply this diff to perform cleanup on shutdown:

@@
     @Override
     protected void shutDown() {
         script.logOnceToChat("Stopping Blue Dragons plugin...", false, config);
         overlayManager.remove(overlay);
+        // Reset antiban so subsequent plugins don't inherit Blue Dragons state.
+        Rs2Antiban.resetAntibanSettings();
+        // Optional (if supported by your enum/API):
+        // Rs2Antiban.setActivity(Activity.IDLE);
         script.shutdown();
     }
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (6)

366-370: Chest flow: early-return is fine; consider short backoff if open fails.

  • The early return when "Open" fails prevents cascading actions in a bad UI state — good.
  • Minor: consider a short backoff (e.g., sleep(600,1200)) before returning to avoid tight-loop spam if the chest is temporarily un-interactable.

Also applies to: 379-380, 389-391, 393-394


927-931: Logging threshold is hard-coded and misleading.

Message says “less than 180” even though the threshold is minRuneAmt. Log the actual threshold to avoid operator confusion.

Apply this diff:

-                Microbot.log("We have less than 180 " + neededRune);
+                Microbot.log("We have <= " + minRuneAmt + " " + neededRune);

942-984: Pre-fight supplies gating is comprehensive; one minor UX nit.

Checks for ring, spade, food, teleports, brews, prayer restores, and run energy look good. To reduce duplicate logs across ticks, consider gating repeated “shouldBank” logs behind a cooldown or using a logOnce pattern similar to other classes.


1045-1050: Use idempotent prayer toggle to reduce race surfaces.

You already guard with isPrayerActive, but using the boolean toggle overload ensures the prayer is turned on even if varbits change between the check and the toggle.

Apply this diff:

-            drinkPrayerPot();
-            Rs2Prayer.toggle(prayer);
+            drinkPrayerPot();
+            Rs2Prayer.toggle(prayer, true);

1184-1190: LoS break is tunnels-only — add a general escape hatch to prevent stalling.

You only break on lack of line-of-sight when inTunnels. If a brother is hint-arrowed but not visible outside tunnels (e.g., blocked by geometry), the loop can spin. Consider a time/iteration cap with a graceful break or a reposition attempt outside tunnels too.


1026-1043: String equality in setAutoCast should use .equals, not ==.

While literals may be interned, using == for string comparison is brittle and error-prone. Recommend .equals for correctness.

Apply this diff:

-        if(neededRune == "Wrath rune"){
+        if ("Wrath rune".equals(neededRune)) {
@@
-        if(neededRune == "Blood rune"){
+        if ("Blood rune".equals(neededRune)) {
@@
-        if(neededRune == "Death rune"){
+        if ("Death rune".equals(neededRune)) {
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7a184aa and 4ab004c.

📒 Files selected for processing (3)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (14 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java (2 hunks)
  • runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsScript.java (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (4)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/inventory/Rs2Inventory.java (1)
  • Rs2Inventory (60-2244)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/equipment/Rs2Equipment.java (1)
  • Rs2Equipment (27-485)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/player/Rs2Player.java (1)
  • Rs2Player (67-2062)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/prayer/Rs2Prayer.java (1)
  • Rs2Prayer (21-222)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (8)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsPlugin.java (1)

10-11: Anti-ban imports look good and scoped.

New imports are minimal and only used in this class. No conflicts detected.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/zerozero/bluedragons/BlueDragonsScript.java (1)

399-399: Whitespace-only change.

No functional changes; safe to include.

runelite-client/src/main/java/net/runelite/client/plugins/microbot/barrows/BarrowsScript.java (6)

146-146: Boolean condition simplification improves readability.

if (!inTunnels && !shouldBank) is clearer and equivalent to the previous check.


238-244: Parameterized prayer activation is clearer and safer.

Switching to activatePrayer(brother.getWhatToPray()) removes the hidden dependency on NeededPrayer and makes intent explicit at the call site.


279-279: Centralized fight orchestration via checkForAndFightBrother(config) is a solid refactor.

Good consolidation; reduces duplication and tightens the combat flow around a single entry point.


293-306: Sync NeededPrayer with selected tunnel brother before traveling.

Assigning NeededPrayer = brother.getWhatToPray() ahead of tunnel entry keeps anti-pattern helpers consistent if they rely on this field.


1257-1265: Forgotten brew prioritization is correct and avoids waste.

Drinking lower-dosed brews first is a sensible inventory-optimization.


1045-1050: No stale call sites detected after renames

  • Verified that there are no zero-arg activatePrayer() usages anywhere in the repo.
  • Verified that there are no lingering calls to checkForBrother(...).

All existing call sites have been updated to the new signatures.

@Gage307
Copy link
Contributor Author

Gage307 commented Aug 23, 2025

I appreciate your continued efforts in your plugins gage!

When you have some time, if you could please take a look at the microbot plugin hub project & start to see how you can migrate your plugins over to the plugin hub!

https://github.com/chsami/microbot-hub

Of course; and I'll check it out thank you!

@gmason0 gmason0 merged commit a91cba4 into chsami:development Aug 24, 2025
2 checks passed
@gmason0 gmason0 mentioned this pull request Aug 27, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 3, 2025
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.

3 participants