Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors dependency gluing #392

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Protonull
Copy link
Contributor

This PR refactors the APIs provided by CivModCore that were intended to help hooking into soft dependencies. Now, any plugin that wishes to create a dependency glue need only do the following:

  1. Ensure that CivModCore is declared within the depend or softdepend lists in your plugin's plugin.yml

  2. Create a class that will NEVER be touched by any other code, eg:
    src/main/java/net/civmc/example/glues/NameLayerGlue.java
    Which must implement the DependencyGlue interface.

  3. Create a file called glues.properties and with the content:

    NameLayer:net.civmc.example.glues.NameLayerGlue

    Where the key is the name of the dependency and the value the class-name of the glue.

  4. Done.

That's it... the glue class will be initialised when CivModCore detects the dependency is enabled for the first time and then invoke enable(). If the dependency is disabled at some point, the disable() method is called. Any subsequent re-enabling will call enable(), etc.

This does mean that glues cannot themselves be API interfaces: the entire point is that they're only interacted with by CivModCore's GlueManager class, but this is a great way of safely registering listeners and such without fear these kinds of issues, since the class is never initialised if the dependency is not present.

@Protonull
Copy link
Contributor Author

Hmmm, starting to wonder whether this refactor is moot: the server is just the compiled output of this monorepo; there'll NEVER be a question over whether NameLayer, or Citadel, or JukeAlert, is missing, unless we delete those plugins from the monorepo... which is unlikely. In addition, Okx has said that we should stop pretending that we aren't the only ones who consume our APIs (reference), and SoundTech has said that all changes must be tested with a local docker instance (reference) because it replicates the server as closely as possible. With these things in mind, I'm wondering whether it'd be better to yeet this boilerplate altogether and convert all our soft-dependencies into hard-dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

None yet

2 participants