Maxlego08 / zEssentials

Essentials suite for Folia and Paper.
Other
34 stars 16 forks source link

[BUG] API economy getBalance() always null #66

Closed DxrkCat closed 2 months ago

DxrkCat commented 3 months ago

Terms

Discord Username (optional)

No response

Server Version

1.21

Server Software

Purpur

zEssentials Version

1.0.0.7

zMenu Version

1.0.3.4

What happened?

https://github.com/Maxlego08/zEssentials/blob/e2e4f08b3a7a19ddc6e798b3161b2da272c3eb5c/src/main/java/fr/maxlego08/essentials/economy/EconomyModule.java#L142

Steps to reproduce the issue

https://github.com/Maxlego08/zEssentials/blob/e2e4f08b3a7a19ddc6e798b3161b2da272c3eb5c/src/main/java/fr/maxlego08/essentials/economy/EconomyModule.java#L142

Full Server Log

null

Error (optional)

No response

Other files, you can drag and drop them here to upload. (optional)

No response

Screenshots/Videos (you can drag and drop files or paste links)

No response

DxrkCat commented 3 months ago
    @Override
    public BigDecimal getBalance(OfflinePlayer player, Economy economy) {
        if (player.isOnline()) {
            User user = plugin.getStorageManager().getStorage().getUser(player.getUniqueId());
            if (user != null) {
                return user.getBalance(economy);
            }
        } else {
            OfflineEconomy offlineEconomy = getOfflineEconomy(player.getUniqueId());
            return offlineEconomy.getEconomy(economy.getName());
        }
        return BigDecimal.ZERO; 
    }

or

    @Override
    public BigDecimal getBalance(OfflinePlayer player, Economy economy) {
        if (player.isOnline()) {
            User user = plugin.getStorageManager().getStorage().getUser(player.getUniqueId());
            if (user != null) {
                return user.getBalance(economy);
            }
        } else {
            OfflineEconomy offlineEconomy = getOfflineEconomy(player.getUniqueId());
            return offlineEconomy.getEconomy(economy.getName());
        }
        return null; 
    }
Maxlego08 commented 2 months ago

Done !