Annotations

This page describes all annotations provided by the Tubing framework.

@IocBean

This is the most used annotation. It registers the class annotated with this bean inside the ioc container of Tubing. Making it a bean. The class can now be injected into other Tubing beans, or can inject other Tubing beans in its constructor.

Property

conditionalOnProperty

you can specify this optional property inside the annotation if you want to conditionally register this bean. The bean will only be created if the property specified can be found and has the specified value.

example simple bean:

@IocBean
public class MessageService {

    public void sendMessage(CommandSender player, String message) {
        player.sendMessage(translateAlternateColorCodes('&', message));
    }
}

example conditional bean

@IocBean(conditionalOnProperty = "tubing-example.broadcast-on-bungee=true")
@IocListener
public class BroadcastedMessageBungeeSender implements Listener {

    private final BungeeService bungeeService;

    public BroadcastedMessageBungeeSender(BungeeService bungeeService) {
        this.bungeeService = bungeeService;
    }

    @EventHandler
    public void onBroadcast(MessageBroadcastedEvent messageBroadcastedEvent) {
        Player player = Bukkit.getOnlinePlayers().iterator().next();
        bungeeService.sendMessage(player, Constants.BUNGEE_REPORT_MESSAGE_BROADCAST_CHANNEL, new BungeeBroadcastedMessage(messageBroadcastedEvent.getBroadcastedMessage()));
    }
}

@IocMultiProvider

Must be used on a class that will be a registered bean Must be used on a class implementing at least one interface

This annotation indicates that this bean can be used for list injection.

property

description

value

The interface that this bean extends and you want to list inject.

@IocMulti

Used to inject a list of @IocMultiProvider beans.

property

description

value

The interface class you want to inject a list of

@TubingConfiguration

Notates a class as a tubing configuration class. This type of class can contain Tubing bean provider methods. Provider methods are used when you want to register a bean that is determined based on some logic that is more complex than can be handled by the @IocBean annotation

@IocBeanProvider

Can only be used on methods inside a Tubing Configuration class. Inside the arguments of this method we can use tubing beans. Tubing will inject the beans when using this method when creating the bean.

@IocCommandHandler

Specify this bean as a command executor. More info

property

description

value

The name of the command as specified in the plugin.yml

@IocListener

Specify this bean as a Bukkit event listener.

@IocMessageListener

Specify this bean as a Bungee message listener.

property

Description

channel

The channel on which the listener should listen.

@ConfigProperty

This annotation can only be used on fields of Tubing beans. Inject a property from the config file inside a bean.

Property

Description

value

The config yml path.

Config

@ConfigTransformer

This annotation must be used on a field annotated with the @ConfigProperty annotation. The ConfigTransformer class must implement the IConfigTransformer interface. Specify a class which will be used to transform the property before it gets injected into the bean

Property

Description

value

The transformer class to use

Transformer

Last updated

Was this helpful?