2024-06-25 15:43:36 +01:00
|
|
|
package cc.fascinated.bat.service;
|
|
|
|
|
2024-06-25 17:20:19 +01:00
|
|
|
import cc.fascinated.bat.command.BatCommand;
|
2024-06-25 15:43:36 +01:00
|
|
|
import cc.fascinated.bat.features.Feature;
|
|
|
|
import lombok.Getter;
|
|
|
|
import lombok.NonNull;
|
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
import org.springframework.context.annotation.DependsOn;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Fascinated (fascinated7)
|
|
|
|
*/
|
|
|
|
@Service @Getter @Log4j2
|
|
|
|
@DependsOn("commandService")
|
|
|
|
public class FeatureService {
|
|
|
|
/**
|
|
|
|
* The registered features
|
|
|
|
*/
|
|
|
|
private final List<Feature> features = new ArrayList<>();
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
public FeatureService(@NonNull ApplicationContext context, @NonNull CommandService commandService) {
|
|
|
|
context.getBeansOfType(Feature.class)
|
|
|
|
.values()
|
|
|
|
.forEach((feature) -> {
|
|
|
|
features.add(context.getBean(feature.getClass()));
|
|
|
|
});
|
|
|
|
|
2024-06-25 17:20:19 +01:00
|
|
|
context.getBeansOfType(BatCommand.class)
|
|
|
|
.values()
|
|
|
|
.forEach((command) -> {
|
|
|
|
commandService.registerCommand(context.getBean(command.getClass()));
|
|
|
|
});
|
|
|
|
|
2024-06-25 15:43:36 +01:00
|
|
|
commandService.registerSlashCommands(); // Register all slash commands
|
|
|
|
}
|
|
|
|
}
|