public interface IService {
void doSomething(CommandSender sender);
}
public class IServiceImpl implements IService{
@Inject
private TestConfig config; // 別忘了任何註冊單例/服務均可使用依賴注入!
@Override
public void doSomething(CommandSender sender) {
sender.sendMessage(config.name);
}
}
@Override
public void bindServices(ServiceCollection serviceCollection) {
serviceCollection.bindService(IService.class, IServiceImpl.class);
}
@Commander(
name = "service",
description = "service command"
)
public class TestServiceCommand implements CommandNode {
@Inject
private IService service;
@Override
public void execute(CommandSender commandSender) {
service.doSomething(commandSender);
}
}