Skip to content

Conversation

@Infinitay
Copy link
Owner

@Infinitay Infinitay commented Dec 20, 2025

This PR is an attempt to better modularize my existing codebase and plugin lifecycle by using abstraction and primarily constructor injection. The few benefits to this refactor are:

  • Cleaner codebase
  • Better defined plugin lifecycle
  • Better dependency injection handling
  • Re-post various game events which will eliminate the need to manually refetching the required data on cold starts (with the exception of a few events such as Varbits)

Events Implemented and Tested

  • Beekeeper
  • Capt' Arnav's Chest
  • Drill Demon
  • Freaky Forester
  • Gravedigger
  • Maze
  • Mime
  • Pinball
  • Sandwich Lady
  • Surprise Exam
  • Quiz Master

feat(module): Created PluginModule class for modular plugin lifecycle

  • Created an abstract class PluginModule to better handle multiple modules within the plugin and to appropriately handle the lifecycle
    • Construct injected common fields such as OverlayManager, Client, and the config
    • Field injected on-demand fields such as EventBus and GameEventManager
    • Automatically (un)registers the module from the EventBus
    • Re-fire various events by utilizing GameEventManager#simulateGameEvents within #startUp
    • Abstracted #onStartUp to handle module starts, #onShutdown to handle module stops, and #isEnabled to determine the status of the module

@Infinitay Infinitay added enhancement New feature or request implementing Actively working on this issue/PR surprise-exam Surprise Exam module labels Dec 20, 2025
@Infinitay
Copy link
Owner Author

feat(module): Created PluginModule class for modular plugin lifecycle

  • Created an abstract class PluginModule to better handle multiple modules within the plugin and to appropriately handle the lifecycle
        - Construct injected common fields such as OverlayManager, Client, and the config
        - Field injected on-demand fields such as EventBus and GameEventManager
        - Automatically (un)registers the module from the EventBus
        - Re-fire various events by utilizing GameEventManager#simulateGameEvents within #startUp
        - Abstracted #onStartUp to handle module starts, #onShutdown to handle module stops, and #isEnabled to determine the status of the module

refactor: Start refactoring RandomEventHelper to modular plugin lifecycle

  • Removed prior injections that have yet to be refactored
  • Refactored #startUp, #shutDown, and #onConfigChanged to utilize the new modular system to handle state changes

refactor(surpriseexam): Migrate SurpriseExamHelper to PluginModule lifecycle

  • Refactored SurpriseExamHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
  • Injected SurpriseExamHelper and added it to the pluginModulesMap

feat(PluginModule): Add #isLoggedIn to check if the player is logged in

feat(surpriseexam): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when already inside the Surprise Exam random event
    • Primarily for when the puzzle interface is already on screen

@Infinitay
Copy link
Owner Author

refactor(captarnav): Migrate PirateHelper to PluginModule lifecycle

  • Refactored PirateHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
  • Injected PirateHelper and added it to the pluginModulesMap

refactor(mime): Migrate MimeHelper to PluginModule lifecycle

  • Refactored MimeHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
  • Injected MimeHelper and added it to the pluginModulesMap

feat(mime): Improve support for starting during active event, overlay, refactor

  • Improved handling initial runs when (re)starting the plugin when already inside the Mime random event
    • Primarily for when the emote button interface is already on screen
  • Change Mime text when undetermined emote answer
  • Use default font size for overlay
  • Refactored Mime animation checks and answer updating into #updateMimeAnimation

@Infinitay
Copy link
Owner Author

Note, while testing the Mime module, I noticed that starting and stopping the refactored Gravedigger module (multiple times) seems to have overlay issues again when switching back to field injection for both overlays.

@Infinitay
Copy link
Owner Author

refactor(drilldemon): Migrate DrillDemonHelper to PluginModule lifecycle

  • Refactored DrillDemonHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
  • Injected DrillDemonHelper and added it to the pluginModulesMap

feat(drilldemon): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when already inside the Drill Demon random event
    • Fix race condition issue with events - primarily regarding #onGroundObjectSpawned and exerciseMatsMultimap

It's probably better to have kept the varbit initialization within #onNpcChanged, but I wanted to keep everything inline for the future. I want to handle varbit inits #onStartUp. Though looking back, I may have to reconsider this due to the way GravediggerHelper is implemented. Also, it does spam the log with 4/8 writes due to the varbit value being 0 and reaching

private void updateExerciseMappings(int exerciseVarbitValue, int postNumber)
{
DrillExercise exercise = DrillExercise.VARBIT_TO_EXERCISE_MAP.get(exerciseVarbitValue);
if (exercise != null)
{
log.debug("Drill Demon exercise of Post_{} changed to: {} ({})", postNumber, exercise.getVarbitValue(), exercise.name());
this.exerciseVarbitMatMultimap.replaceValues(exerciseVarbitValue, this.exerciseMatsMultimap.get(postNumber));
}
else
{
log.warn("Drill Demon exercise varbit changed to unknown value: {}", exerciseVarbitValue);
this.exerciseVarbitMatMultimap.replaceValues(exerciseVarbitValue, ImmutableSet.of());
}
}

The log being log.warn("Drill Demon exercise varbit changed to unknown value: {}", exerciseVarbitValue); , but that's expected because of how Jagex inits the varbs to 0. I could just ignore it, but I think it'd be better to just have it for now.

@Infinitay Infinitay added the drill-demon Drill Demon module label Dec 26, 2025
@Infinitay
Copy link
Owner Author

refactor(beekeeper): Migrate BeekeeperHelper to PluginModule lifecycle

  • Refactored BeekeeperHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
  • Injected BeekeeperHelper and added it to the pluginModulesMap

feat(beekeeper): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when already inside the Beekeeper random event
  • Avoid constantly appending corresponding number to destination widget label

@Infinitay
Copy link
Owner Author

feat(captarnav): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when doing Capt' Arnav's Chest random event
  • Add missing isSolved = false assignment within PirateChestSolver#isChestCorrectlySet

@Infinitay
Copy link
Owner Author

refactor(quizmaster): Migrate QuizMasterHelper to PluginModule lifecycle

  • Refactored QuizMasterHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
  • Injected QuizMasterHelper and added it to the pluginModulesMap

feat(quizmaster): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when doing Quiz Master random event

@Infinitay
Copy link
Owner Author

refactor(sandwich): Migrate SandwichLadyHelper to PluginModule lifecycle

  • Refactored SandwichLadyHelper to the modular plugin lifecycle
        - Now extends PluginModule and implements respective methods, moving the existing start/stop login there
        - Use constructor injection and removed duplicate field injections
  • Injected SandwichLadyHelper and added it to the pluginModulesMap

feat(sandwich): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when doing Sandwich Lady random event

@Infinitay Infinitay added beekeeper Beekeeper module capt-arnav-chest Capt' Arnav's Chest module quiz-master Quiz Master module sandwich-lady Sandwich Lady module labels Dec 28, 2025
@Infinitay
Copy link
Owner Author

Note, while testing the Mime module, I noticed that starting and stopping the refactored Gravedigger module (multiple times) seems to have overlay issues again when switching back to field injection for both overlays.

@Inject
private OverlayManager overlayManager;
private GravediggerOverlay gravediggerOverlay;

if (this.gravediggerOverlay != null)
{
this.overlayManager.remove(gravediggerOverlay);
this.gravediggerOverlay = null;
}

The issue was that I forgot to re-inject the gravediggerItemOverlay as a part of the refactor. As you can see from the snippets above, it was defined but never injected/created.

Also, in the future, this is a good reference to have: https://github.com/google/guice/wiki/CyclicDependencies

@Infinitay
Copy link
Owner Author

refactor(gravedigger): Migrate GravediggerHelper to PluginModule lifecycle

  • Refactored GravediggerHelper to the modular plugin lifecycle
    • Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    • Use constructor injection and removed duplicate field injections
      • Re-inject GravediggerOverlay
  • Injected GravediggerHelper and added it to the pluginModulesMap

feat(gravedigger): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when doing Gravedigger random event
    • Removed reliance on #onGameTick and initiallyEnteredGraveDiggerArea
    • Allow the plugin lifecycle's #startUp and specifically GameEventManager#simulateGameEvents to handle re-posting events
      • Migrate over ItemContainerChanged and VarbitChanged re-posts and fetching of sprites/images to #onStartUp
  • Removed unnecessary event listeners for GameTick and NpcSpawned

fix(gravedigger): Fix NPE when starting plugin with an empty grave

  • Fix NPE that was thrown as a result of grave#getFilledGrave being null such as when starting the plugin with an empty grave
    • Now fetching either a filled or empty grave depending on which is available -> skipping if both null

@Infinitay Infinitay added the gravedigger Gravedigger module label Dec 28, 2025
@Infinitay
Copy link
Owner Author

refactor(maze): Migrate MazeHelper to PluginModule lifecycle

  • Refactored MazeHelper to the modular plugin lifecycle
        - Now extends PluginModule and implements respective methods, moving the existing start/stop login there
        - Use constructor injection and removed duplicate field injections
  • Injected MazeHelper and added it to the pluginModulesMap

refactor(maze): Remove now redundant cold start handling

  • Removed no longer needed event listener for GameTick
  • Removed no longer needed variables that help track first start or required for cold start support

fix(maze): Fix not clearing the current path when plugin is shutdown

@Infinitay Infinitay added the maze Maze module label Dec 29, 2025
@Infinitay
Copy link
Owner Author

refactor(freakyforester): Migrate FreakyForesterHelper to PluginModule lifecycle

  • Refactored FreakyForesterHelper to the modular plugin lifecycle
        - Now extends PluginModule and implements respective methods, moving the existing start/stop login there
        - Use constructor injection and removed duplicate field injections
  • Injected FreakyForesterHelper and added it to the pluginModulesMap

feat(freakyforester): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when doing Freaky Forester random event

@Infinitay Infinitay added the freaky-forester Freaky Forester module label Dec 31, 2025
@Infinitay
Copy link
Owner Author

fix(maze): Fix not showing path on restart, use instanced WorldPoint instead

  • Fixed an issue where the Shortest Path wasn't properly calculated/rendered upon restarts/cold-starts
  • Now uses the player's LocalPoint and converts it to an instanced WorldPoint (WorldPoint#fromLocalInstance) as the starting WorldPoint for the path generation
  • Modified logging to reflect usage of point types

@Infinitay
Copy link
Owner Author

refactor(pinball): Migrate PinballHelper to PluginModule lifecycle

  • Refactored PinballHelper to the modular plugin lifecycle
        - Now extends PluginModule and implements respective methods, moving the existing start/stop login there
        - Use constructor injection and removed duplicate field injections
  • Injected PinballHelper and added it to the pluginModulesMap

feat(pinball): Improve support for starting during active event

  • Improved handling initial runs when (re)starting the plugin when doing Pinball random event

@Infinitay
Copy link
Owner Author

Infinitay commented Jan 7, 2026

I realized that I forgot about event race conditions. For example, when refactoring the Pinball module, even though I was calling ClientThread#invokeLater, sometimes my required variables were null/not populated due to that happening during game events such as GameObjectSpawned. The sequence would look like the following:

  1. #onStartUp
  2. ClientThread#invokeLater to initialize any other event data such as faking a VarbitChanged
  3. --> In this case, it was doing this.activePinballPost = this.pinballPostsMap.get(value); but this.pinballPostsMap was null/not fully populated
  4. Then #onGameObjectSpawned was fully triggered

I think it will be a good idea to reference back to any event that had to fake sending events on startup and specifically Varbit related events.

WidgetLoaded

  • Beekeeper
  • Capt' Arnav's Chest
  • Mime
  • Sandwich Lady
  • Surprise Exam
  • Quiz Master

VarbitChanged

  • Drill Demon
    • Unlike the Pinball module, when I was testing cold-starts for Drill Demon module, it was working properly. We should be safe to consider this as not having a problem due to way this module is coded.
      • #onStartup -> #onVarbitChanged updates exerciseVarbitMatMultimap, which is later referenced by #onChatMessage - The required referenced data is stored and therefore safe
  • Gravedigger
    • I believe at some point I may have experienced an issue here, but I could've sworn I fixed it.
      • #onStartup -> #onVarbitChanged which calls #updateRequiredCoffin and #updatePlacedCoffin which both modifies graveMap - graveMap is referenced in #onGameObjectSpawned; however, in both event subscribers, we're always checking to see if there is a respective found within graveMap and initializing it if not, so there should be no problems
        • #onVarbitChanged uses getOrDefault(graveNumber, new Grave(graveNumber));
        • #onGameObjectSpawned null checks - if null -> initialize -> update -> store
  • Pinball

@Infinitay
Copy link
Owner Author

fix(drilldemon): Use #invokeLater to fix possible race conditions

  • Other modules rely on #invokeLater, so this also maintains consistency

- Created an abstract class PluginModule to better handle multiple modules within the plugin and to appropriately handle the lifecycle
	- Construct injected common fields such as OverlayManager, Client, and the config
	- Field injected on-demand fields such as EventBus and GameEventManager
	- Automatically (un)registers the module from the EventBus
	- Re-fire various events by utilizing GameEventManager#simulateGameEvents within #startUp
	- Abstracted #onStartUp to handle module starts, #onShutdown to handle module stops, and #isEnabled to determine the status of the module
…ycle

- Removed prior injections that have yet to be refactored
- Refactored #startUp, #shutDown, and #onConfigChanged to utilize the new modular system to handle state changes
- Improved handling initial runs when (re)starting the plugin when already inside the Surprise Exam random event
	- Primarily for when the puzzle interface is already on screen
- Refactored PirateHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected PirateHelper and added it to the pluginModulesMap
- Refactored MimeHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected MimeHelper and added it to the pluginModulesMap
…, refactor

- Improved handling initial runs when (re)starting the plugin when already inside the Mime random event
	- Primarily for when the emote button interface is already on screen
- Change Mime text when undetermined emote answer
- Use default font size for overlay
- Refactored Mime animation checks and answer updating into #updateMimeAnimation
- Refactored DrillDemonHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected DrillDemonHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when already inside the Drill Demon random event
	- Fix race condition issue with events - primarily regarding #onGroundObjectSpawned and exerciseMatsMultimap
- Refactored BeekeeperHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected BeekeeperHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when already inside the Beekeeper random event
- Avoid constantly appending corresponding number to destination widget label
- Improved handling initial runs when (re)starting the plugin when doing Capt' Arnav's Chest random event
- Add missing isSolved = false assignment within PirateChestSolver#isChestCorrectlySet
- Refactored QuizMasterHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected QuizMasterHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when doing Quiz Master random event
- Refactored SandwichLadyHelper to the modular plugin lifecycle
    - Now extends PluginModule and implements respective methods, moving the existing start/stop login there
    - Use constructor injection and removed duplicate field injections
- Injected SandwichLadyHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when doing Sandwich Lady random event
…cycle

- Refactored GravediggerHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
		- Re-inject GravediggerOverlay
- Injected GravediggerHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when doing Gravedigger random event
	- Removed reliance on #onGameTick and `initiallyEnteredGraveDiggerArea`
	- Allow the plugin lifecycle's #startUp and specifically GameEventManager#simulateGameEvents to handle re-posting events
		- Migrate over ItemContainerChanged and VarbitChanged re-posts and fetching of sprites/images to #onStartUp
- Removed unnecessary event listeners for GameTick and NpcSpawned
- Fix NPE that was thrown as a result of grave#getFilledGrave being null such as when starting the plugin with an empty grave
	- Now fetching either a filled or empty grave depending on which is available -> skipping if both null
- Refactored MazeHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected MazeHelper and added it to the pluginModulesMap
- Removed no longer needed event listener for GameTick
- Removed no longer needed variables that help track first start or required for cold start support
…e lifecycle

- Refactored FreakyForesterHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected FreakyForesterHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when doing Freaky Forester random event
…instead

- Fixed an issue where the Shortest Path wasn't properly calculated/rendered upon restarts/cold-starts
- Now uses the player's LocalPoint and converts it to an instanced WorldPoint (WorldPoint#fromLocalInstance) as the starting WorldPoint for the path generation
- Modified logging to reflect usage of point types
- Refactored PinballHelper to the modular plugin lifecycle
	- Now extends PluginModule and implements respective methods, moving the existing start/stop login there
	- Use constructor injection and removed duplicate field injections
- Injected PinballHelper and added it to the pluginModulesMap
- Improved handling initial runs when (re)starting the plugin when doing Pinball random event
- Other modules rely on #invokeLater, so this also maintains consistency
- Refactored plugin to adopt a new PluginModule lifecycle
- Migrated all existing random event helpers to the new lifecycle
	- Greatly improved cold start support and cleaned up the codebase
- (gravedigger) Fixed a NPE when starting the plugin while a grave is not filled
- (maze) Now clears the path when the module is shutdown
- (maze) Fixed not showing the path properly when restarting/cold starting due to a wrong destination
@Infinitay Infinitay force-pushed the pluginmodule-refactor branch from efbdd26 to 7b9f85d Compare January 16, 2026 23:20
@Infinitay Infinitay merged commit 3f94e7f into master Jan 16, 2026
@Infinitay Infinitay added implemented The changes have been implemented locally and/or a PR has been made and removed implementing Actively working on this issue/PR labels Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beekeeper Beekeeper module capt-arnav-chest Capt' Arnav's Chest module drill-demon Drill Demon module enhancement New feature or request freaky-forester Freaky Forester module gravedigger Gravedigger module implemented The changes have been implemented locally and/or a PR has been made maze Maze module quiz-master Quiz Master module sandwich-lady Sandwich Lady module surprise-exam Surprise Exam module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants