-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/com/artillexstudios/axrankmenu/hooks/currency/UltraEconomyHook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.artillexstudios.axrankmenu.hooks.currency; | ||
|
||
import me.TechsCode.UltraEconomy.UltraEconomy; | ||
import me.TechsCode.UltraEconomy.objects.Account; | ||
import me.TechsCode.UltraEconomy.objects.Currency; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.artillexstudios.axrankmenu.AxRankMenu.CONFIG; | ||
|
||
public class UltraEconomyHook implements CurrencyHook { | ||
private Currency currency = null; | ||
|
||
@Override | ||
public void setup() { | ||
final Optional<Currency> currencyOptional = UltraEconomy.getAPI().getCurrencies().name(CONFIG.getString("hook-settings.UltraEconomy.currency-name", "coins")); | ||
if (!currencyOptional.isPresent()) throw new RuntimeException("Currency not found!"); | ||
currency = currencyOptional.get(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "UltraEconomy"; | ||
} | ||
|
||
@Override | ||
public double getBalance(@NotNull Player p) { | ||
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId()); | ||
if (!account.isPresent()) return 0.0D; | ||
return account.get().getBalance(currency).getOnHand(); | ||
} | ||
|
||
@Override | ||
public void giveBalance(@NotNull Player p, double amount) { | ||
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId()); | ||
if (!account.isPresent()) return; | ||
account.get().addBalance(currency, amount); | ||
} | ||
|
||
@Override | ||
public void takeBalance(@NotNull Player p, double amount) { | ||
final Optional<Account> account = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId()); | ||
if (!account.isPresent()) return; | ||
account.get().removeBalance(currency, amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters