Closed adamk33n3r closed 6 months ago
The recent changes primarily focus on code refactoring and formatting adjustments across multiple Java files. The build.gradle
file has undergone indentation corrections, while the Java classes have shifted from using the builder pattern to constructor initialization. Additionally, annotations like @SuperBuilder
and @Builder.Default
have been removed or replaced with @Accessors(chain = true)
, simplifying the code structure and enhancing readability.
File Path | Summary of Changes |
---|---|
build.gradle |
Indentation and formatting adjustments. No changes to logic or functionality. |
.../AlertManager.java |
Refactored to use constructor initialization instead of builder pattern for several alert instances. |
.../alerts/Alert.java |
Replaced @SuperBuilder with @Accessors(chain = true) , removed @Builder.Default , and added methods addNotification and addNotifications . |
.../alerts/AlertGroup.java |
Removed @SuperBuilder and @Builder.Default annotations. |
.../alerts/ChatAlert.java |
Replaced @SuperBuilder with @Accessors(chain = true) , removed @Builder.Default annotations. |
.../alerts/InventoryAlert.java |
Replaced @SuperBuilder with @Accessors(chain = true) , removed @Builder.Default annotations. |
.../alerts/LocationAlert.java |
Removed @SuperBuilder and @Builder.Default annotations, commented out showTileMarker field. |
.../alerts/NotificationFiredAlert.java |
Replaced @SuperBuilder with @Accessors(chain = true) , removed @Builder.Default annotations. |
.../alerts/PlayerChatAlert.java |
Replaced @SuperBuilder with @Accessors(chain = true) , removed @Builder.Default annotations. |
.../alerts/RegexMatcher.java |
Changed setRegexEnabled return type from void to Alert . |
.../alerts/SoundFiredAlert.java |
Removed @SuperBuilder , @Builder.Default , and field initialization for soundID . |
.../alerts/SpawnedAlert.java |
Replaced @SuperBuilder with @Accessors(chain = true) , removed @Builder.Default annotations. |
.../alerts/StatChangedAlert.java |
Removed @SuperBuilder and @Builder.Default annotations. |
.../alerts/XPDropAlert.java |
Removed @SuperBuilder and @Builder.Default annotations. |
src/main/java/com/adamk33n3r/runelite/watchdog/alerts/SoundFiredAlert.java (1)
`7-7`: Simplification by direct field initialization in constructor enhances readability but reduces flexibility compared to the builder pattern.src/main/java/com/adamk33n3r/runelite/watchdog/alerts/XPDropAlert.java (1)
`10-10`: Direct field initialization in the constructor simplifies the code and is appropriate for the specific context of XP drop alerts.src/main/java/com/adamk33n3r/runelite/watchdog/alerts/StatChangedAlert.java (1)
`10-10`: Consistent approach with direct field initialization in the constructor across alert types simplifies the code and enhances maintainability.src/main/java/com/adamk33n3r/runelite/watchdog/alerts/NotificationFiredAlert.java (1)
`9-9`: Addition of `@Accessors(chain = true)` enhances method chaining capabilities, aligning with the refactoring efforts across the project to improve API fluency.src/main/java/com/adamk33n3r/runelite/watchdog/alerts/ChatAlert.java (1)
`7-7`: The addition of `@Accessors(chain = true)` is a good practice for enabling method chaining, enhancing readability and maintainability. Also applies to: 11-11src/main/java/com/adamk33n3r/runelite/watchdog/alerts/PlayerChatAlert.java (1)
`7-7`: The use of `@Accessors(chain = true)` here, as in other alert classes, standardizes the approach across the codebase, improving maintainability. Also applies to: 11-11src/main/java/com/adamk33n3r/runelite/watchdog/alerts/InventoryAlert.java (1)
`8-8`: The addition of `@Accessors(chain = true)` is a good practice for enabling method chaining, enhancing readability and maintainability. Also applies to: 12-12src/main/java/com/adamk33n3r/runelite/watchdog/alerts/SpawnedAlert.java (1)
`9-9`: The use of `@Accessors(chain = true)` here, as in other alert classes, standardizes the approach across the codebase, improving maintainability. Also applies to: 13-13src/main/java/com/adamk33n3r/runelite/watchdog/alerts/Alert.java (1)
`8-9`: The addition of `@Accessors(chain = true)` and new methods `addNotification` and `addNotifications` enhance the functionality and maintainability of the `Alert` class. Also applies to: 20-20, 45-53src/main/java/com/adamk33n3r/runelite/watchdog/AlertManager.java (3)
`230-255`: Refactored to use direct instantiation instead of builders. Ensure all necessary properties are correctly set.Verification successful
--- The search results confirm the instantiation of `ChatAlert` objects in the specified lines. The properties for `cannonReload` and `readyToHarvest` appear to be correctly set as per the provided code snippet. - `cannonReload` sets the message, game message type, and adds notifications. - `readyToHarvest` sets the message, debounce time, and adds a notification.--- `165-229`: Refactored to use direct instantiation instead of builders. Ensure all necessary properties are correctly set. --- `116-164`: Refactored to use direct instantiation instead of builders. Ensure all necessary properties are correctly set.Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that all properties are correctly set for Alert instances. # Test: Search for the instantiation of Alert. Expect: Properties set correctly. rg --type java $'new Alert\(' ``` Length of output: 30 --- --- Script: ```shell #!/bin/bash # Description: Verify that all properties are correctly set for ChatAlert instances. # Test: Search for the instantiation of ChatAlert. Expect: Properties set correctly. rg --type java $'new ChatAlert\(' ``` Length of output: 299Verification successful
The initial script identified `AlertGroup` instances but did not find any `Alert` instances. To ensure all properties are correctly set, we need to search for subclasses or related classes of `Alert` and verify their properties. --- The script identified instances of `SpawnedAlert` and `InventoryAlert` in `AlertManager.java`. Let's review the properties set for these instances to ensure they are correctly configured. ### SpawnedAlert Instances 1. **Kraken Dies** - `setSpawnedDespawned(SpawnedAlert.SpawnedDespawned.DESPAWNED)` - `setSpawnedType(SpawnedAlert.SpawnedType.NPC)` - `setSpawnedName("Kraken")` - Notifications: - `Overhead`: `setDisplayTime(3)`, `setTextColor(Color.CYAN)`, `setMessage("Sit Krak")` - `ScreenMarker`: `setDisplayTime(8)`, `setScreenMarkerProperties("Get Fishing Explosive Ready", Color.MAGENTA, Color.BLUE, 2)` - `RequestFocus`: `setForceFocus(true)` 2. **Whirlpool Appears** - `setSpawnedDespawned(SpawnedAlert.SpawnedDespawned.DESPAWNED)` - `setSpawnedType(SpawnedAlert.SpawnedType.NPC)` - `setSpawnedName("Whirlpool")` - `setDebounceTime(15000)` - Notifications: - `ScreenFlash`: `setColor(ColorUtil.fromHex("#6D0030"))`, `setFlashMode(FlashMode.SMOOTH_FLASH)`, `setFlashDuration(1)` - `Overhead`: `setDisplayTime(3)`, `setTextColor(Color.GREEN)`, `setMessage("Throw Explosive!")` ### InventoryAlert Instance 1. **Fishing Explosive Used** - `setInventoryAlertType(InventoryAlert.InventoryAlertType.ITEM_CHANGE)` - `setItemName("Fishing explosive")` - `setItemQuantity(-1)` - `setQuantityComparator(ComparableNumber.Comparator.EQUALS)` - Notifications: - `Overhead`: `setDisplayTime(2)`, `setTextColor(Color.RED)`, `setMessage("Attack!")` - `ScreenFlash`: `setColor(ColorUtil.fromHex("#46FF00"))`, `setFlashMode(FlashMode.FLASH)`, `setFlashDuration(2)` All necessary properties for `SpawnedAlert` and `InventoryAlert` instances appear to be correctly set. Refactored to use direct instantiation instead of builders. All necessary properties are correctly set.Scripts Executed
The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify that all properties are correctly set for Alert and AlertGroup instances. # Test: Search for the instantiation of Alert and AlertGroup. Expect: Properties set correctly. rg --type java $'new AlertGroup\(' rg --type java $'new Alert\(' ``` Length of output: 447 --- --- Script: ```shell #!/bin/bash # Description: Verify that all properties are correctly set for Alert subclasses and related classes. # Test: Search for subclasses of Alert and their instantiation. Expect: Properties set correctly. ast-grep --lang java --pattern 'class $_ extends Alert { $$$ }' rg --type java 'new SpawnedAlert\(' rg --type java 'new InventoryAlert\(' ``` Length of output: 489
Summary by CodeRabbit
Refactor
New Features
Style