Skip to content

Dependency injection#79

Merged
minoneer merged 14 commits into
uskyblock:masterfrom
minoneer:dependency-injection
Feb 9, 2025
Merged

Dependency injection#79
minoneer merged 14 commits into
uskyblock:masterfrom
minoneer:dependency-injection

Conversation

@minoneer

@minoneer minoneer commented Feb 7, 2025

Copy link
Copy Markdown
Member

The goal of this PR is to improve the maintainability of the plugin by moving towards dependency-injection-based initialization.

Current issue:
The plugin currently uses a combination of static references, a massive single-instance service locator (the main uSkyBlock class), and passing dependencies down to child objects. This means

  • initialization order is implicit, and changing anything in the order may break stuff due to undocumented implicit dependencies
  • an overloaded main plugin class
  • implicit cyclic dependencies between services
  • changing a class usually requires changes to several others, including the main plugin class
  • Things are hard to test, as everything depends on everything else

This PR breaks these dependencies through dependency injection using Guice.

  • Most services, commands, and listeners are initialized through DI
  • Some services were refactored to depend on the actual type instead of the uSkyBlock class. This is an ongoing effort and will require continued effort in the future
  • Moved most of the initialization code out of the main plugin class

Initial testing looks good, but since this is a larger change, it may cause some initial instability or hidden issues.

Closes #14
Resolves #76

@minoneer minoneer added enhancement New feature or request maintenance Maintenance chores, e.g., migrate deprecated API's labels Feb 7, 2025
@minoneer minoneer requested a review from Muspah February 7, 2025 13:57
@minoneer minoneer self-assigned this Feb 7, 2025
@minoneer

minoneer commented Feb 7, 2025

Copy link
Copy Markdown
Member Author

@Muspah, I would appreciate a second opinion on this; sorry for the massive diff.

@minoneer

minoneer commented Feb 7, 2025

Copy link
Copy Markdown
Member Author

PS: hiding whitespace changes helps ;)

@Muspah Muspah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, it's "boring" stuff but it needs to be done to overhaul all the legacy crap that's in the codebase. Thanks very much for your continuous effort.

Are we able to run some real-world tests before releasing to Spigot/Paper/...? I do run a small demo server, but without many players except for myself.

@minoneer

minoneer commented Feb 9, 2025

Copy link
Copy Markdown
Member Author

LGTM, it's "boring" stuff but it needs to be done to overhaul all the legacy crap that's in the codebase. Thanks very much for your continuous effort.

Are we able to run some real-world tests before releasing to Spigot/Paper/...? I do run a small demo server, but without many players except for myself.

Thanks!

I did some quick testing on my test setup - mostly to make sure commands, challenges, etc. still work as expected. I can update to our live server and see if we run into issues. We don't have a ton of players in skyblock, but a handful of regulars.

@Muspah

Muspah commented Feb 9, 2025

Copy link
Copy Markdown
Member

Sounds good. Feel free to merge when you're ready and I will include it into my SQL-support branch when possible so it gets tested on my demo too. Lets just prevent that it gets included in some trivial MC version update release without testing :)

@minoneer

minoneer commented Feb 9, 2025

Copy link
Copy Markdown
Member Author

Sounds good!

Can we create a release for spigot & paper at the current master head (4d7afec)? It includes a bug fix for 1.21.4, biome updates, and a couple other things that should be stable (we are running it in production). It is compatible with [1.20.5, 1.21.4].

@minoneer minoneer force-pushed the dependency-injection branch from 2ec9fad to 3485366 Compare February 9, 2025 21:48
@minoneer minoneer merged commit 8ad2dc2 into uskyblock:master Feb 9, 2025
@minoneer minoneer deleted the dependency-injection branch January 19, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request maintenance Maintenance chores, e.g., migrate deprecated API's

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup Plugin Initialisation

2 participants