Skip to content

Commit

Permalink
AxAuctions update
Browse files Browse the repository at this point in the history
  • Loading branch information
BenceX100 committed Dec 16, 2024
1 parent 8bee14f commit 365cdbd
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
1 change: 1 addition & 0 deletions Writerside/hi.tree
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<toc-element topic="AxAuctions-Configuration.md"/>
<toc-element topic="AxAuctions-Permissions.md"/>
<toc-element topic="AxAuctions-Placeholders.md"/>
<toc-element topic="AxAuctions-Multi-Currency-Plugins.md"/>
<toc-element topic="AxAuctions-Custom-Currencies.md"/>
<toc-element topic="AxAuctions-Supported-Plugins.md"/>
<toc-element topic="AxAuctions-Developer-API.md"/>
Expand Down
Binary file added Writerside/images/image_52.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 14 additions & 8 deletions Writerside/topics/AxAuctions-Developer-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public class ExampleCurrency implements CurrencyHook {
@Override
public String getName() {
// the name of your hook, make sure to use this in the currencies.yml
// the name of your hook, used for the currencies.yml
// this should not contain any special characters - underscores (_) and dashes (-) are fine
return "ExampleCurrency";
}
Expand All @@ -87,7 +88,7 @@ public class ExampleCurrency implements CurrencyHook {
@Override
public boolean isPersistent() {
// should the plugin unregister the hook when it gets reloaded?
// should the plugin unregister the hook when the AxAuctions gets reloaded?
// you should keep this on true
return true;
}
Expand All @@ -99,23 +100,28 @@ public class ExampleCurrency implements CurrencyHook {
}
@Override
public void giveBalance(@NotNull UUID player, double amount) {
public CompletableFuture<Boolean> giveBalance(@NotNull UUID player, double amount) {
CompletableFuture<Boolean> cf = new CompletableFuture<>();
// your code here
cf.complete(true); // make sure to return true if the transaction the successfully completed! (or false if it failed) if your plugin doesn't use async tasks, just complete with a true value
return cf;
}
@Override
public void takeBalance(Consumer<Boolean> successful, @NotNull UUID player, double amount) {
public CompletableFuture<Boolean> takeBalance(Consumer<Boolean> successful, @NotNull UUID player, double amount) {
CompletableFuture<Boolean> cf = new CompletableFuture<>();
// your code here
// the Consumer is meant to be used for async plugins, for example if your async sql query fails, return false to prevent giving the item
successful.accept(true); // it is VERY IMPORTANT to accept the consumer if everything worked!!!
cf.complete(true); // make sure to return true if the transaction the successfully completed! (or false if it failed) if your plugin doesn't use async tasks, just complete with a true value
return cf;
}
}
```

> Double-check, that in the **takeBalance** method you always accept the consumer (`successful.accept()`)
> Double-check, that you always complete the CompletableFuture transactions. (`cf.complete(true or false)`)
> If this is not done, the plugin will not respond to purchases using your currency.
{style="warning"}

Next is, you will have to create a section in the `currencies.yml`, copy paste one of the other currencies, for example, like this:
Next is, check the `currencies.yml`, there should be something like this generated for your own currency:
```yaml
ExampleCurrency: # < the name of your currency
register: true
Expand Down
44 changes: 44 additions & 0 deletions Writerside/topics/AxAuctions-Multi-Currency-Plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Multi Currency Plugins

* If a plugin supports multiple currencies, you can allow multiple currencies to be used in AxAuctions.

Example CoinsEngine setup with 2 currencies in the `currencies.yml`:

We have 2 currencies set up in CoinsEngine:

![image_52.png](image_52.png)

And in The AxAuctions currencies.yml, this is how the 2 currencies are set up:
```yaml
currencies:
CoinsEngine:
register: true
# CoinsEngine supports multiple currencies, so you can also add multiple here
# "coins" is the name of the currency
# first currency
coins:
tax: 0
display:
raw: "CoinsEngine-coins"
gui: "&f%\price% &#AAFFFFcoins"
item:
material: GOLD_INGOT
name: "&#00DDFFCoinsEngine coins"
lore:
- " "
- "&#00DDFF&l(!) &#00DDFFClick here to select!"
# second currency
money:
tax: 0
display:
raw: "CoinsEngine-money"
gui: "&f%\price% &#AAFFFFmoney"
item:
material: GOLD_NUGGET
name: "&#00DDFFCoinsEngine money"
lore:
- " "
- "&#00DDFF&l(!) &#00DDFFClick here to select!"
```
You can register any amount of custom currencies if the plugin supports it.

0 comments on commit 365cdbd

Please sign in to comment.