wiki: fix code in ability extension example

This commit is contained in:
Dhina17 2020-12-09 15:31:51 +05:30
parent 415d31eaec
commit adb765d739

View File

@ -2,7 +2,7 @@
You have around 100 abilities in your bot and you're looking for a way to refactor that mess into more modular classes. `AbillityExtension` is here to support just that! It's not a secret that AbilityBot uses refactoring backstage to be able to construct all of your abilities and map them accordingly. However, AbilityBot searches initially for all methods that return an `AbilityExtension` type. Then, those extensions will be used to search for declared abilities. Here's an example. You have around 100 abilities in your bot and you're looking for a way to refactor that mess into more modular classes. `AbillityExtension` is here to support just that! It's not a secret that AbilityBot uses refactoring backstage to be able to construct all of your abilities and map them accordingly. However, AbilityBot searches initially for all methods that return an `AbilityExtension` type. Then, those extensions will be used to search for declared abilities. Here's an example.
```java ```java
public class MrGoodGuy implements AbilityExtension { public class MrGoodGuy implements AbilityExtension {
public Ability () { public Ability nice() {
return Ability.builder() return Ability.builder()
.name("nice") .name("nice")
.privacy(PUBLIC) .privacy(PUBLIC)
@ -13,7 +13,7 @@ public class MrGoodGuy implements AbilityExtension {
} }
public class MrBadGuy implements AbilityExtension { public class MrBadGuy implements AbilityExtension {
public Ability () { public Ability notnice() {
return Ability.builder() return Ability.builder()
.name("notnice") .name("notnice")
.privacy(PUBLIC) .privacy(PUBLIC)
@ -51,4 +51,4 @@ It's also possible to add extensions in the constructor by using the `addExtensi
// Override creatorId // Override creatorId
} }
``` ```