ByteLib Documentation 1.1 Help

Using Lifecycles

ByteLib automatically discovers classes implementing the PluginLifecycle interface. This interface allows overriding the standard Paper lifecycle events. Using PluginLifecycle enables you to use Dependency Injection within your lifecycle classes, meaning you can inject dependencies for use in your onEnable, onDisable, and even onLoad methods!

As with Paper's lifecycle system, you only have to override lifecycle methods you intend on using.

public final class MyLifecycle implements PluginLifecycle { private final BytePluginConfig config; // You don't need to inject anything into your constructor, or even have one at all. // This example just demonstrates that you can. @Inject public MyLifecycle([[[BytePluginConfig|configuration-translation.html]]] config) { this.config = config; } @Override public void onEnable() { config.config().getString("some-string"); // Do more work... } }

ByteLib makes liberal use of the Lifecycles API. The Lifecycles API is even used internally when registering Commands via the Commands API. Lifecycles are a powerful way to separate your plugin's code at build time.

You can see an example of the Lifecycle API being used here.

10 March 2026