AlessioDP / libby

A runtime dependency management library for plugins running in Java-based Minecraft server platforms.
MIT License
76 stars 20 forks source link

Fix velocity and sponge support #9

Closed WiIIiam278 closed 2 years ago

WiIIiam278 commented 2 years ago

Injection is not possible with multiple constructors meaning the current implementation fails and isn't really necessary in this use case. Further, the current method will lead to countless https://github.com/google/guice/wiki/CAN_NOT_PROXY_CLASS errors as it requires a T type (plugin instance) which you can't directly reference staticly as that creates a circular dependency which can't be proxied when injecting.

I've changed the velocity manager here to allow direct instantiation rather than runtime injection. I've also removed one constructor from the sponge one (which has a similar problem) to fix the https://github.com/google/guice/wiki/TOO_MANY_CONSTRUCTORS that occurs with that.

Here's how you get a VelocityLibraryManager now:

VelocityLibraryManager<VelocityPlugin> manager = new VelocityLibraryManager<>(logger, dataDirectory, getProxyServer().getPluginManager(), getInstance(), "lib");

where logger -> your SL4J instance dataDirectory -> your @DataDirectory already retrievable through injection VelocityPlugin -> your velocity plugin