@IocBukkitCommandHandler("broadcast")
public class BroadcastCmd implements CommandExecutor {
private final MessageService messageService;
private final BroadcastingService broadcastingService;
public BroadcastCmd(MessageService messageService, BroadcastingService broadcastingService) {
this.messageService = messageService;
this.broadcastingService = broadcastingService;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
...
}
}
Specify this bean as a Bukkit event listener.
@IocBukkitListener
public class PlayerJoinListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onJoin(PlayerJoinEvent event) {
...
}
}
@IocBukkitMessageListener
Specify this bean as a Bungee message listener.
@IocBukkitMessageListener(channel = "BungeeCord")
public class BroadcastedMessageBungeeReceiver implements PluginMessageListener {
private final BungeeService bungeeService;
public BroadcastedMessageBungeeReceiver(BungeeService bungeeService) {
this.bungeeService = bungeeService;
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
Optional<BungeeBroadcastedMessage> bungeeMessage = bungeeService.handleReceived(channel, BUNGEE_REPORT_MESSAGE_BROADCAST_CHANNEL, message, BungeeBroadcastedMessage.class);
bungeeMessage.map(BungeeBroadcastedMessage::getBroadcastedMessage).ifPresent(b -> Bukkit.getPluginManager().callEvent(new BroadcastedMessageReceivedBungeeEvent(b)));
}
}