This commit is contained in:
BenceX100 2024-05-30 19:20:45 +02:00
parent 298bfb1c38
commit 29d0ee0053
3 changed files with 14 additions and 3 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.artillexstudios</groupId>
<artifactId>AxTrade</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<packaging>jar</packaging>
<name>AxTrade</name>

View File

@ -1,8 +1,10 @@
package com.artillexstudios.axtrade.hooks.currency;
import com.artillexstudios.axapi.utils.StringUtils;
import me.TechsCode.UltraEconomy.UltraEconomy;
import me.TechsCode.UltraEconomy.objects.Account;
import me.TechsCode.UltraEconomy.objects.Currency;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
@ -15,8 +17,12 @@ public class UltraEconomyHook implements CurrencyHook {
@Override
public void setup() {
final Optional<Currency> currencyOptional = UltraEconomy.getAPI().getCurrencies().name(HOOKS.getString("currencies.UltraEconomy.currency-name", "coins"));
if (!currencyOptional.isPresent()) throw new RuntimeException("Currency not found!");
final String name = HOOKS.getString("currencies.UltraEconomy.currency-name", "coins");
final Optional<Currency> currencyOptional = UltraEconomy.getAPI().getCurrencies().name(name);
if (!currencyOptional.isPresent()) {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("&#FF0000[AxAuctions] UltraEconomy currency named &#DD0000" + name + " &#FF0000not found! Change the currency-name or disable the hook to get rid of this warning!"));
return;
}
currency = currencyOptional.get();
}
@ -42,6 +48,7 @@ public class UltraEconomyHook implements CurrencyHook {
@Override
public double getBalance(@NotNull UUID player) {
if (currency == null) return 0.0D;
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(player);
if (!account.isPresent()) return 0.0D;
return account.get().getBalance(currency).getOnHand();
@ -49,6 +56,7 @@ public class UltraEconomyHook implements CurrencyHook {
@Override
public void giveBalance(@NotNull UUID player, double amount) {
if (currency == null) return;
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(player);
if (account.isEmpty()) return;
account.get().addBalance(currency, amount);
@ -56,6 +64,7 @@ public class UltraEconomyHook implements CurrencyHook {
@Override
public void takeBalance(@NotNull UUID player, double amount) {
if (currency == null) return;
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(player);
if (account.isEmpty()) return;
account.get().removeBalance(currency, amount);

View File

@ -76,6 +76,7 @@ public class TradeGui extends GuiFrame {
gui.open(player.getPlayer());
inSign = false;
trade.update();
updateTitle();
}
}));
shulkerGui.open(player.getPlayer());
@ -207,6 +208,7 @@ public class TradeGui extends GuiFrame {
gui.open(player.getPlayer());
inSign = false;
trade.update();
updateTitle();
});
}).build(player.getPlayer());
sign.open();