AlessioDP / libby

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

Instructions for VelocityLibraryManager #48

Closed Andre601 closed 1 month ago

Andre601 commented 2 months ago

The VelocityLibraryManager seems to be a odd one out of the group for a few reasons, one of them being that you need to define the plugin's main class as part of it...

It would be good if instructions would be present for to make it easier to understand how to properly use it, because from what I understand is this what you're supposed to do?

public class MyVelocityPlugin {

    @Inject // Maybe too early to call it in constructor?
    public MyVelocityPlugin(ProxyServer proxy, @DataDirectory Path path) {
        VelocityLibraryManager<MyVelocityPlugin> manager = new VelocityLibraryManager<>(
            this, LoggerFactory.getLogger(MyVelocityPlugin.class), path, proxy.getPluginManager()
        );

        // Do stuff...
    }
}
AlessioDP commented 2 months ago

Yes, that is the correct way to call it, the logger can be obtained with an argument in the Inject constructor:

@Inject
public MyPlugin(Logger logger, @DataDirectory Path dataDirectory, PluginManager pluginManager) {
    VelocityLibraryManager<MyPlugin> libraryManager = new VelocityLibraryManager<>(this, logger, dataDirectory, pluginManager);
}

A wiki is planned to be published once the gradle branch is released.