Skip to content

Commit

Permalink
Be able to add AbilityExtensions in Bot constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
christianblos committed Oct 5, 2020
1 parent 203b265 commit b715f2a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public abstract class BaseAbilityBot extends DefaultAbsSender implements Ability
private final String botUsername;

// Ability registry
protected final List<AbilityExtension> extensions = new ArrayList<>();
private Map<String, Ability> abilities;
private Map<String, Stats> stats;

Expand Down Expand Up @@ -280,10 +281,10 @@ protected boolean allowContinuousText() {
private void registerAbilities() {
try {
// Collect all classes that implement AbilityExtension declared in the bot
List<AbilityExtension> extensions = stream(getClass().getMethods())
extensions.addAll(stream(getClass().getMethods())
.filter(checkReturnType(AbilityExtension.class))
.map(returnExtension(this))
.collect(Collectors.toList());
.collect(Collectors.toList()));

// Add the bot itself as it is an AbilityExtension
extensions.add(this);
Expand Down

0 comments on commit b715f2a

Please sign in to comment.