-
Notifications
You must be signed in to change notification settings - Fork 0
4. The auto injector
RedsTom edited this page May 15, 2021
·
2 revisions
One of the major features of the BotServer API is the injection tool. It permits to easily get variables all around your code.
The only places where you can use this auto-inject is into the different methods called by the server itself.
At the moment, you cannot auto-inject your own variables.
For example, you can use auto-injector into the load methods of the plugin, or in the events.
@BotPlugin(
id = "Example",
name = "Example",
author = "Me"
)
public class Main {
public void load(@Inject("server") IServer server) {
server.getLogger().info("Plugin loaded.");
}
public void unload() {
}
}
As you can see in this example, the Inject annotation takes a parameter. This is the name of the variable to inject. In this example, the injected variable is the server instance.
You can find here the different variables that can be used with the auto-injector.
Name | Type |
---|---|
server | org.redstom.botapi.server.IServer |
BotServer is under the MIT license and its author is RedsTom.