Skip to content

Commit

Permalink
1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
BenceX100 committed May 30, 2024
1 parent 298bfb1 commit 29d0ee0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
}

Expand All @@ -42,20 +48,23 @@ public boolean isPersistent() {

@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();
}

@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);
}

@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);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/artillexstudios/axtrade/trade/TradeGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void accept(ScheduledTask scheduledTask) {
gui.open(player.getPlayer());
inSign = false;
trade.update();
updateTitle();
}
}));
shulkerGui.open(player.getPlayer());
Expand Down Expand Up @@ -207,6 +208,7 @@ public void update() {
gui.open(player.getPlayer());
inSign = false;
trade.update();
updateTitle();
});
}).build(player.getPlayer());
sign.open();
Expand Down

0 comments on commit 29d0ee0

Please sign in to comment.