Updated ExtensionTest and wiki

This commit is contained in:
Christian Blos 2020-10-08 16:11:45 +02:00
parent 247ca5f984
commit 3f07bfdff1
2 changed files with 16 additions and 0 deletions

View File

@ -35,6 +35,20 @@ public class MrBadGuy implements AbilityExtension {
return new MrBadGuy(); return new MrBadGuy();
} }
// Override creatorId
}
```
It's also possible to add extensions in the constructor by using the `addExtension()` or `addExtensions()` method:
```java
public class YourAwesomeBot implements AbilityBot {
public YourAwesomeBot() {
super(/* pass required args ... */);
addExtensions(new MrGoodGuy(), new MrBadGuy());
}
// Override creatorId // Override creatorId
} }
``` ```

View File

@ -32,6 +32,7 @@ class ExtensionTest {
assertTrue(hasAbilityNamed("direct"), "Failed to find Ability in directly declared in root extension/bot"); assertTrue(hasAbilityNamed("direct"), "Failed to find Ability in directly declared in root extension/bot");
assertTrue(hasAbilityNamed("returningSuperClass0abc"), "Failed to find Ability in directly declared in extension returned by method returning the AbilityExtension class"); assertTrue(hasAbilityNamed("returningSuperClass0abc"), "Failed to find Ability in directly declared in extension returned by method returning the AbilityExtension class");
assertTrue(hasAbilityNamed("returningSubClass0abc"), "Failed to find Ability in directly declared in extension returned by method returning the AbilityExtension subclass"); assertTrue(hasAbilityNamed("returningSubClass0abc"), "Failed to find Ability in directly declared in extension returned by method returning the AbilityExtension subclass");
assertTrue(hasAbilityNamed("addedInConstructor0abc"), "Failed to find Ability in directly declared in extension added in the constructor");
} }
private boolean hasAbilityNamed(String name) { private boolean hasAbilityNamed(String name) {
@ -41,6 +42,7 @@ class ExtensionTest {
public static class ExtensionUsingBot extends AbilityBot { public static class ExtensionUsingBot extends AbilityBot {
ExtensionUsingBot() { ExtensionUsingBot() {
super("", "", offlineInstance("testing")); super("", "", offlineInstance("testing"));
addExtension(new AbilityBotExtension("addedInConstructor"));
} }
@Override @Override