Added Offensive Combat Prayers and Max Random Delays for Equipping Combat Gear#1515
Added Offensive Combat Prayers and Max Random Delays for Equipping Combat Gear#1515SamBunker wants to merge 1 commit intochsami:mainfrom
Conversation
WalkthroughThis change adds Offensive Prayers and Defensive Prayers sections to CombatHotkeysConfig. It introduces enums (MeleePrayerOption, RangedPrayerOption, MagicPrayerOption) mapping to Rs2PrayerEnum, plus new keybind config items for offensive melee/range/magic and default selections. It adds Gear Equip Settings with a maxDelay (ms) config and reorders gearSetup sections. CombatHotkeysPlugin now handles new offensive prayer hotkeys, consuming events and toggling prayers based on config. equipGear is made instance-level and inserts a randomized delay (0 to maxDelay) after each item equip using Rs2Random.between and sleep. Possibly related PRs
Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing touches
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: 1
🧹 Nitpick comments (3)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java (2)
91-99: Avoid multi-toggle if the same key is bound to multiple offensive prayersUse else-if to ensure only one offensive prayer toggles per keypress if users accidentally reuse a key.
- if (config.offensiveRangeKey().matches(e)) { + else if (config.offensiveRangeKey().matches(e)) { e.consume(); Rs2Prayer.toggle(config.offensiveRangePrayer().getPrayer()); } - if (config.offensiveMagicKey().matches(e)) { + else if (config.offensiveMagicKey().matches(e)) { e.consume(); Rs2Prayer.toggle(config.offensiveMagicPrayer().getPrayer()); }
15-15: Drop Rs2Random import if using Global.sleep(0, maxDelay)Be consistent with existing utilities and avoid an unused import after the equipGear change.
-import net.runelite.client.plugins.microbot.util.math.Rs2Random;runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysConfig.java (1)
319-329: Constrain maxDelay via @range to prevent invalid negatives/extremesUI-level bounds reduce bad configs and complement the runtime clamp.
@ConfigItem( keyName = "maxDelay", name = "Max Equip Delay (ms)", description = "Maximum random delay (in milliseconds) between equipping items", position = 0, section = gearEquipSettings ) + @Range(min = 0, max = 2000) default int maxDelay() { return 500; // default max delay of 500ms }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysConfig.java(8 hunks)runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java (2)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/Global.java (1)
Global(10-171)runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/inventory/Rs2Inventory.java (1)
Rs2Inventory(46-2324)
| private void equipGear(String gearListConfig) { | ||
| String[] itemIDs = gearListConfig.split(","); | ||
|
|
||
| for (String value : itemIDs) { | ||
| int itemId = Integer.parseInt(value); | ||
| Rs2Inventory.equip(itemId); | ||
|
|
||
| int delay = Rs2Random.between(0, config.maxDelay()); | ||
| sleep(delay); | ||
| } | ||
| } |
There was a problem hiding this comment.
Make equipGear robust: skip blanks, handle parse errors, clamp delay, and use Global.sleep’s randomized overload
Parsing an empty/default gear list ("") or entries with whitespace will throw NumberFormatException. Also clamp negative maxDelay values to avoid invalid ranges. Prefer Global.sleep(0, maxDelay) to consolidate randomness and sleeping.
Apply:
- private void equipGear(String gearListConfig) {
- String[] itemIDs = gearListConfig.split(",");
-
- for (String value : itemIDs) {
- int itemId = Integer.parseInt(value);
- Rs2Inventory.equip(itemId);
-
- int delay = Rs2Random.between(0, config.maxDelay());
- sleep(delay);
- }
- }
+ private void equipGear(String gearListConfig) {
+ if (gearListConfig == null || gearListConfig.isBlank()) {
+ return;
+ }
+ String[] itemIDs = gearListConfig.split(",");
+ final int maxDelay = Math.max(0, config.maxDelay());
+ for (String value : itemIDs) {
+ final String token = value.trim();
+ if (token.isEmpty()) continue;
+ try {
+ int itemId = Integer.parseInt(token);
+ Rs2Inventory.equip(itemId);
+ } catch (NumberFormatException ex) {
+ log.warn("Invalid gear id '{}'; skipping", value);
+ }
+ // uses Global.sleep(start, end) to randomize and sleep safely
+ sleep(0, maxDelay);
+ }
+ }📝 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.
| private void equipGear(String gearListConfig) { | |
| String[] itemIDs = gearListConfig.split(","); | |
| for (String value : itemIDs) { | |
| int itemId = Integer.parseInt(value); | |
| Rs2Inventory.equip(itemId); | |
| int delay = Rs2Random.between(0, config.maxDelay()); | |
| sleep(delay); | |
| } | |
| } | |
| private void equipGear(String gearListConfig) { | |
| if (gearListConfig == null || gearListConfig.isBlank()) { | |
| return; | |
| } | |
| String[] itemIDs = gearListConfig.split(","); | |
| final int maxDelay = Math.max(0, config.maxDelay()); | |
| for (String value : itemIDs) { | |
| final String token = value.trim(); | |
| if (token.isEmpty()) continue; | |
| try { | |
| int itemId = Integer.parseInt(token); | |
| Rs2Inventory.equip(itemId); | |
| } catch (NumberFormatException ex) { | |
| log.warn("Invalid gear id '{}'; skipping", value); | |
| } | |
| // uses Global.sleep(start, end) to randomize and sleep safely | |
| sleep(0, maxDelay); | |
| } | |
| } |
🤖 Prompt for AI Agents
In
runelite-client/src/main/java/net/runelite/client/plugins/microbot/combathotkeys/CombatHotkeysPlugin.java
around lines 158 to 168, make equipGear robust by trimming and skipping empty
entries from gearListConfig.split(","), wrapping Integer.parseInt in a try/catch
to skip entries that fail to parse (log/debug if desired), clamp
config.maxDelay() to a minimum of 0 before use, and replace the manual
random/delay code with a single call to Global.sleep(0, clampedMaxDelay) to
perform randomized sleeping reliably.
|
Please make a PR to development and not main. |
Added offensive prayers hotkeys with dropdown menus for people to choose which offensive prayers for melee, range, and mage to use.
Added a max equipment delay setting with a default delay of 500 ms to randomize each equipped item. Originally, it seems each item equipped in the list of items had the same timing with little to no variation in timing.