> For the complete documentation index, see [llms.txt](https://docs.preva1l.info/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.preva1l.info/fadah/api/economy.md).

# Adding a Economy Hook

### Adding a Single Currency

```java
public class MyCustomCurrency implements Currency {
    private MyPluginsAPI api;
    
    @Override
    public String getId() {
        return "my_currency";
    }
    
    @Override
    public String getRequiredPlugin() {
        return "MyPlugin";
    }
    
    @Override
    public String getName() {
        return "Super Money";
    }

    @Override
    public void withdraw(OfflinePlayer player, double amountToTake) {
        api.take(player, amountToTake);
    }

    @Override
    public void add(OfflinePlayer player, double amountToAdd) {
        api.give(player, amountToAdd);
    }

    @Override
    public double getBalance(OfflinePlayer player) {
        return api.get(player);
    }

    @Override
    public boolean preloadChecks() {
        api = MyPluginsAPI.getInstance()
        return api != null;
    }
}

```

### Adding a Multi Currency

<pre class="language-java"><code class="lang-java">public class MyMultiCurrency implements MultiCurrency {
    private final List&#x3C;Currency> currencies = new ArrayList&#x3C;>();
    private MyPluginsAPI api;
    
<strong>    @Override
</strong>    public String getId() {
        return "my_plugin";
    }
    
    @Override
    public String getRequiredPlugin() {
        return "MyPlugin";
    }
    
    @Override
    public List&#x3C;Currency> getCurrencies() {
        return currencies;
    }

    @Override
    public boolean preloadChecks() {
        api = MyPluginsAPI.getInstance()
        if (api == null) return false;

        for (String economy : List.of("gems", "tokens")) {
            Currency subCur = new SubCurrency(
                id + "_" + economy,
                economy,
                requiredPlugin,
                (player, amount) -> api.take(p.getUniqueId(), economy, amount),
                (player, amount) -> api.give(p.getUniqueId(), economy, amount),
                player -> api.get(player.getUniqueId(), economy),
                v -> {
                    if (!api.currencyExists(economy)) {
                        System.out.println("-------------------------------------");
                        System.out.println("Cannot enable coins engine currency!");
                        System.out.println("No currency with name: " + eco.economy());
                        System.out.println("-------------------------------------");
                        return false;
                    }
                    return true;
                }
            );
            currencies.add(subCur);
        }
        return true;
    }
}

</code></pre>

### Registering your currency

```java
CurrencyRegistry.register(new MyCustomCurrency());
CurrencyRegistry.register(new MyMultiCurrency());
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.preva1l.info/fadah/api/economy.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
