Skip to content

Commit f931e7a

Browse files
committed
Fixed #46
1 parent 632c14e commit f931e7a

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

dev.md

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
# Developer notes
22

3-
This document is for developers who want to contribute to this project.
3+
## High-level API
44

5-
## API
6-
7-
### Summary
5+
This section describes the simple API for developers of other plugins
6+
without learning the concepts of Capital in depth.
87

9-
Capital supports different account classifications (known as [schemas](#schema)).
10-
All operations involving player accounts require
11-
a config entry to select which account,
12-
e.g. if the user selects the Currency schema,
13-
you need a config that selects which currency to use.
8+
Capital supports different ways of classifying accounts (known as [schemas](#schema)),
9+
e.g. multi-currency and multi-world.
1410
The good news is, you don't have to consider each schema,
1511
because Capital will figure it out.
16-
For each use case, just create an empty config entry to select the account:
12+
You just need to leave a place in your config.yml
13+
so that users who want to use other schemas can configure it:
1714

1815
```yaml
19-
selector:
16+
# Selects the Capital account to use.
17+
# See https://github.com/SOF3/Capital/wiki/Schemas for more details.
18+
selector: {}
2019
```
2120
2221
Users can fill this selector with options like `allowed-currencies` etc.,
@@ -41,7 +40,7 @@ class Main extends PluginBase {
4140
Then you can use the stored selector in the code
4241
where you want to manipulate player money.
4342

44-
#### Take money from a player
43+
### Take money from a player
4544

4645
Let's make a plugin called "ChatFee"
4746
which charges the player $5 for every chat message:
@@ -57,7 +56,7 @@ public function onChat(PlayerChatEvent $event) : void {
5756
$player,
5857
$this->selector,
5958
5,
60-
new LabelSet(["reason" => "chatting"]),
59+
new LabelSet(["reason" => "chatting"]),
6160
);
6261
6362
$player->sendMessage("You lost $5 for chatting");
@@ -94,7 +93,7 @@ However, remember that **you cannot cancel `$event` after the first `yield`**,
9493
because transactions are asynchronous, which means that
9594
the event already happened by that time and it is too late to cancel.
9695

97-
#### Giving money to a player
96+
### Giving money to a player
9897

9998
Giving money is similar to taking money,
10099
except `takeMoney` becomes `addMoney`.
@@ -126,7 +125,7 @@ public function onDamage(EntityDamageByEntityEvent $event) : void {
126125
}
127126
```
128127

129-
#### Paying money from a player to another
128+
### Paying money from a player to another
130129

131130
Paying money is like taking money from one player and giving to another,
132131
but it only happens when *both* players have enough money and don't exceed limits.
@@ -188,7 +187,7 @@ It is also possible for player1 to pay less and player2 to pay more.
188187
In that case, player1 only pays the amount to player2,
189188
then the system account will pay the rest to player2.
190189

191-
#### Getting money for a player
190+
### Getting money for a player
192191

193192
If you want to check whether the player has enough money for something,
194193
use `takeMoney` as explained above and handle the error case.
@@ -200,6 +199,8 @@ Consider using InfoAPI to compute the messages
200199
and let the user set their own messages.
201200
See [InfoAPI readme](https://github.com/SOF3/InfoAPI) for usage guide.
202201

202+
## API
203+
203204
### Async functions
204205

205206
Capital uses [await-generator](https://github.com/SOF3/await-generator),

0 commit comments

Comments
 (0)