From 9c2039db7cd441efc11dfd2b891c7b4b73a02a72 Mon Sep 17 00:00:00 2001
From: BenceX100 <52270269+BenceX100@users.noreply.github.com>
Date: Sun, 24 Dec 2023 09:17:19 +0100
Subject: [PATCH] 1.0.3
---
pom.xml | 14 +++++-
.../axrankmenu/hooks/HookManager.java | 10 +++-
.../hooks/currency/UltraEconomyHook.java | 48 +++++++++++++++++++
.../axrankmenu/utils/PlaceholderUtils.java | 4 +-
src/main/resources/config.yml | 3 ++
src/main/resources/plugin.yml | 7 +++
6 files changed, 81 insertions(+), 5 deletions(-)
create mode 100644 src/main/java/com/artillexstudios/axrankmenu/hooks/currency/UltraEconomyHook.java
diff --git a/pom.xml b/pom.xml
index af332f4..b3dd4b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.artillexstudios
AxRankMenu
- 1.1.0
+ 1.0.3
jar
AxRankMenu
@@ -100,6 +100,10 @@
placeholderapi
https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+ techscode
+ https://repo.techscode.com/repository/maven-releases/
+
@@ -112,7 +116,7 @@
com.artillexstudios.axapi
axapi
- 1.4.6
+ 1.4.10
compile
@@ -194,5 +198,11 @@
2.11.3
provided
+
+ me.TechsCode
+ UltraEconomyAPI
+ 2.6.4
+ provided
+
diff --git a/src/main/java/com/artillexstudios/axrankmenu/hooks/HookManager.java b/src/main/java/com/artillexstudios/axrankmenu/hooks/HookManager.java
index 95d640b..d411dcb 100644
--- a/src/main/java/com/artillexstudios/axrankmenu/hooks/HookManager.java
+++ b/src/main/java/com/artillexstudios/axrankmenu/hooks/HookManager.java
@@ -5,6 +5,7 @@
import com.artillexstudios.axrankmenu.hooks.currency.CurrencyHook;
import com.artillexstudios.axrankmenu.hooks.currency.PlayerPointsHook;
import com.artillexstudios.axrankmenu.hooks.currency.RoyaleEconomyHook;
+import com.artillexstudios.axrankmenu.hooks.currency.UltraEconomyHook;
import com.artillexstudios.axrankmenu.hooks.currency.VaultHook;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
@@ -40,13 +41,20 @@ public void updateHooks() {
} else {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF3333[AxRankMenu] CoinsEngine is set in config.yml, but it isn't installed, please download it or change it in the config to stop errors!"));
}
-
+
if (CONFIG.getBoolean("hooks.RoyaleEconomy.register", true) && Bukkit.getPluginManager().getPlugin("RoyaleEconomy") != null) {
currency.add(new RoyaleEconomyHook());
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("!FF33[AxRankMenu] Hooked into RoyaleEconomy!"));
} else {
Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF3333[AxRankMenu] RoyaleEconomy is set in config.yml, but it isn't installed, please download it or change it in the config to stop errors!"));
}
+
+ if (CONFIG.getBoolean("hooks.UltraEconomy.register", true) && Bukkit.getPluginManager().getPlugin("UltraEconomy") != null) {
+ currency.add(new UltraEconomyHook());
+ Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("!FF33[AxRankMenu] Hooked into UltraEconomy!"));
+ } else {
+ Bukkit.getConsoleSender().sendMessage(StringUtils.formatToString("FF3333[AxRankMenu] UltraEconomy is set in config.yml, but it isn't installed, please download it or change it in the config to stop errors!"));
+ }
for (CurrencyHook hook : currency) hook.setup();
diff --git a/src/main/java/com/artillexstudios/axrankmenu/hooks/currency/UltraEconomyHook.java b/src/main/java/com/artillexstudios/axrankmenu/hooks/currency/UltraEconomyHook.java
new file mode 100644
index 0000000..092c596
--- /dev/null
+++ b/src/main/java/com/artillexstudios/axrankmenu/hooks/currency/UltraEconomyHook.java
@@ -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 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 = 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 = 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 = UltraEconomy.getAPI().getAccounts().uuid(p.getUniqueId());
+ if (!account.isPresent()) return;
+ account.get().removeBalance(currency, amount);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/artillexstudios/axrankmenu/utils/PlaceholderUtils.java b/src/main/java/com/artillexstudios/axrankmenu/utils/PlaceholderUtils.java
index 0168119..3495129 100644
--- a/src/main/java/com/artillexstudios/axrankmenu/utils/PlaceholderUtils.java
+++ b/src/main/java/com/artillexstudios/axrankmenu/utils/PlaceholderUtils.java
@@ -14,8 +14,8 @@ public class PlaceholderUtils {
public static String parsePlaceholders(@NotNull String string, @NotNull Section section) {
string = string.replace("%price%", StringUtils.formatNumber("#,###.##", section.getDouble("price")));
- LuckPerms lpApi = LuckPermsProvider.get();
- ImmutableContextSet set = lpApi.getContextManager().getStaticContext();
+ final LuckPerms lpApi = LuckPermsProvider.get();
+ final ImmutableContextSet set = lpApi.getContextManager().getStaticContext();
string = string.replace("%server%", (section.getString("server").equals("") && set.getAnyValue("server").isPresent()) ? set.getAnyValue("server").get() : section.getString("server"));
if (HookManager.getPapi() != null)
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 8ca8e66..9a92d20 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -66,6 +66,9 @@ hooks:
CoinsEngine:
register: true
currency-name: "coins"
+ UltraEconomy:
+ register: true
+ currency-name: "coins"
PlaceholderAPI:
register: true
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 6ddc39d..a1bbb9d 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -7,6 +7,13 @@ folia-supported: true
depend:
- LuckPerms
+softdepend:
+ - PlaceholderAPI
+ - CoinsEngine
+ - PlayerPoints
+ - RoyaleEconomy
+ - UltraEconomy
+
commands:
axrankmenu:
usage: /