diff --git a/pom.xml b/pom.xml
index 4c0ec9c..c056d51 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
ca.tweetzy
auctionhouse
- 2.37.0
+ 2.38.0
UTF-8
@@ -192,6 +192,12 @@
2.10.10
provided
+
+ me.TechsCode
+ UltraEconomy
+ 1.4.1
+ provided
+
\ No newline at end of file
diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
index 3ae27ca..23792bb 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
@@ -1,9 +1,9 @@
package ca.tweetzy.auctionhouse;
import ca.tweetzy.auctionhouse.api.UpdateChecker;
-import ca.tweetzy.auctionhouse.api.hook.PlaceholderAPI;
+import ca.tweetzy.auctionhouse.api.hook.PlaceholderAPIHook;
+import ca.tweetzy.auctionhouse.api.hook.UltraEconomyHook;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
-import ca.tweetzy.auctionhouse.auction.AuctionStat;
import ca.tweetzy.auctionhouse.commands.*;
import ca.tweetzy.auctionhouse.database.DataManager;
import ca.tweetzy.auctionhouse.database.migrations.*;
@@ -26,6 +26,8 @@ import ca.tweetzy.core.database.MySQLConnector;
import ca.tweetzy.core.database.SQLiteConnector;
import ca.tweetzy.core.gui.GuiManager;
import ca.tweetzy.core.hooks.EconomyManager;
+import ca.tweetzy.core.hooks.PluginHook;
+import ca.tweetzy.core.hooks.economies.Economy;
import ca.tweetzy.core.utils.Metrics;
import ca.tweetzy.core.utils.TextUtils;
import co.aikar.taskchain.BukkitTaskChainFactory;
@@ -50,6 +52,7 @@ public class AuctionHouse extends TweetyPlugin {
private static TaskChainFactory taskChainFactory;
private static AuctionHouse instance;
+ private PluginHook ultraEconomyHook;
@Getter
@Setter
@@ -110,18 +113,26 @@ public class AuctionHouse extends TweetyPlugin {
taskChainFactory = BukkitTaskChainFactory.create(this);
- // Load Economy
- EconomyManager.load();
-
// Settings
Settings.setup();
+ this.ultraEconomyHook = PluginHook.addHook(Economy.class, "UltraEconomy", UltraEconomyHook.class);
+
+ // Load Economy
+ EconomyManager.load();
+
// local
setLocale(Settings.LANG.getString());
LocaleSettings.setup();
// Setup Economy
- EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
+ final String ECO_PLUGIN =Settings.ECONOMY_PLUGIN.getString();
+ if (ECO_PLUGIN.startsWith("UltraEconomy")) {
+ EconomyManager.getManager().setPreferredHook(this.ultraEconomyHook);
+ } else {
+ EconomyManager.getManager().setPreferredHook(ECO_PLUGIN);
+ }
+
if (!EconomyManager.getManager().isEnabled()) {
getLogger().severe("Could not find a valid economy provider for Auction House");
getServer().getPluginManager().disablePlugin(this);
@@ -200,8 +211,8 @@ public class AuctionHouse extends TweetyPlugin {
);
// Placeholder API
- if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
- new PlaceholderAPI(this).register();
+ if (Bukkit.getPluginManager().getPlugin("PlaceholderAPIHook") != null) {
+ new PlaceholderAPIHook(this).register();
}
// start the auction tick task
diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java
index c09d9d4..dbd7228 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java
@@ -2,8 +2,7 @@ package ca.tweetzy.auctionhouse.api;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.events.AuctionStartEvent;
-import ca.tweetzy.auctionhouse.api.hook.MMOItems;
-import ca.tweetzy.auctionhouse.auction.AuctionItem;
+import ca.tweetzy.auctionhouse.api.hook.MMOItemsHook;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
@@ -18,21 +17,17 @@ import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.ItemUtils;
import ca.tweetzy.core.utils.nms.NBTEditor;
-import io.lumine.mythic.lib.api.item.NBTItem;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.Validate;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
-import org.bukkit.attribute.Attribute;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.BundleMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.Plugin;
@@ -262,7 +257,7 @@ public class AuctionAPI {
: Color.getHSBColor(Float.parseFloat(possibleColours[0]) / 360, Float.parseFloat(possibleColours[1]) / 100, Float.parseFloat(possibleColours[2]) / 100);
ItemStack itemStack = auctionItem.getItem();
- String itemName = MMOItems.isEnabled() ? MMOItems.getItemType(itemStack) : ChatColor.stripColor(getItemName(itemStack));
+ String itemName = MMOItemsHook.isEnabled() ? MMOItemsHook.getItemType(itemStack) : ChatColor.stripColor(getItemName(itemStack));
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject();
embedObject.setTitle(isNew ? Settings.DISCORD_MSG_START_TITLE.getString() : Settings.DISCORD_MSG_FINISH_TITLE.getString());
@@ -304,7 +299,7 @@ public class AuctionAPI {
: Color.getHSBColor(Float.parseFloat(possibleColours[0]) / 360, Float.parseFloat(possibleColours[1]) / 100, Float.parseFloat(possibleColours[2]) / 100);
ItemStack itemStack = auctionItem.getItem();
- String itemName = MMOItems.isEnabled() ? MMOItems.getItemType(itemStack) : ChatColor.stripColor(getItemName(itemStack));
+ String itemName = MMOItemsHook.isEnabled() ? MMOItemsHook.getItemType(itemStack) : ChatColor.stripColor(getItemName(itemStack));
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject();
embedObject.setTitle(Settings.DISCORD_MSG_BID_TITLE.getString());
diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/hook/MMOItems.java b/src/main/java/ca/tweetzy/auctionhouse/api/hook/MMOItemsHook.java
similarity index 91%
rename from src/main/java/ca/tweetzy/auctionhouse/api/hook/MMOItems.java
rename to src/main/java/ca/tweetzy/auctionhouse/api/hook/MMOItemsHook.java
index 4bcfe1d..fb80967 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/api/hook/MMOItems.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/api/hook/MMOItemsHook.java
@@ -17,10 +17,10 @@ import org.bukkit.inventory.ItemStack;
*/
@UtilityClass
-public class MMOItems {
+public class MMOItemsHook {
public boolean isEnabled() {
- return Bukkit.getPluginManager().getPlugin("MMOItems") != null;
+ return Bukkit.getPluginManager().getPlugin("MMOItemsHook") != null;
}
private boolean hasType(@NonNull final NBTItem itemStack) {
diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java
similarity index 92%
rename from src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPI.java
rename to src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java
index bc919cf..bbfa353 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPI.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/api/hook/PlaceholderAPIHook.java
@@ -2,7 +2,6 @@ package ca.tweetzy.auctionhouse.api.hook;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
-import io.lumine.mythic.lib.comp.PlaceholderAPIHook;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
@@ -13,11 +12,11 @@ import org.jetbrains.annotations.NotNull;
* Time Created: 6:36 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
-public class PlaceholderAPI extends PlaceholderExpansion {
+public class PlaceholderAPIHook extends PlaceholderExpansion {
private final AuctionHouse plugin;
- public PlaceholderAPI(AuctionHouse plugin) {
+ public PlaceholderAPIHook(AuctionHouse plugin) {
this.plugin = plugin;
}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/hook/UltraEconomyHook.java b/src/main/java/ca/tweetzy/auctionhouse/api/hook/UltraEconomyHook.java
new file mode 100644
index 0000000..752f13a
--- /dev/null
+++ b/src/main/java/ca/tweetzy/auctionhouse/api/hook/UltraEconomyHook.java
@@ -0,0 +1,73 @@
+package ca.tweetzy.auctionhouse.api.hook;
+
+import ca.tweetzy.auctionhouse.exception.UltraEconomyCurrencyException;
+import ca.tweetzy.auctionhouse.settings.Settings;
+import ca.tweetzy.core.hooks.economies.Economy;
+import me.TechsCode.UltraEconomy.UltraEconomy;
+import me.TechsCode.UltraEconomy.objects.Account;
+import me.TechsCode.UltraEconomy.objects.Currency;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: October 05 2021
+ * Time Created: 9:18 p.m.
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise
+ */
+public final class UltraEconomyHook extends Economy {
+
+ private final Currency currency;
+
+ public UltraEconomyHook() {
+ final String[] ultraEconomyCurrencyName = Settings.ECONOMY_PLUGIN.getString().split(":");
+
+ this.currency = UltraEconomy.getAPI().getCurrencies().name(ultraEconomyCurrencyName[1]).orElse(null);
+
+ if (this.currency == null) {
+ throw new UltraEconomyCurrencyException("AuctionHouse could not find the currency: " + ultraEconomyCurrencyName[0]);
+ }
+ }
+
+ @Override
+ public double getBalance(OfflinePlayer player) {
+ final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
+ return account == null ? 0 : account.getBalance(this.currency).getOnBank();
+ }
+
+ @Override
+ public boolean hasBalance(OfflinePlayer player, double cost) {
+ final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
+ return account != null && account.getBalance(this.currency).getOnBank() >= cost;
+ }
+
+ @Override
+ public boolean withdrawBalance(OfflinePlayer player, double cost) {
+ final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
+ if (account == null) return false;
+
+ final float oldAmount = account.getBalance(this.currency).getOnBank();
+ account.getBalance(this.currency).setBank(oldAmount - (float) cost);
+ return true;
+ }
+
+ @Override
+ public boolean deposit(OfflinePlayer player, double amount) {
+ final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
+ if (account == null) return false;
+
+ final float oldAmount = account.getBalance(this.currency).getOnBank();
+ account.getBalance(this.currency).setBank(oldAmount + (float) amount);
+ return true;
+ }
+
+ @Override
+ public String getName() {
+ return "UltraEconomy";
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return Bukkit.getPluginManager().getPlugin("UltraEconomy") != null;
+ }
+}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/exception/UltraEconomyCurrencyException.java b/src/main/java/ca/tweetzy/auctionhouse/exception/UltraEconomyCurrencyException.java
new file mode 100644
index 0000000..4dda8ac
--- /dev/null
+++ b/src/main/java/ca/tweetzy/auctionhouse/exception/UltraEconomyCurrencyException.java
@@ -0,0 +1,14 @@
+package ca.tweetzy.auctionhouse.exception;
+
+/**
+ * The current file has been created by Kiran Hart
+ * Date Created: October 05 2021
+ * Time Created: 9:31 p.m.
+ * Usage of any code found within this class is prohibited unless given explicit permission otherwise
+ */
+public final class UltraEconomyCurrencyException extends NullPointerException {
+
+ public UltraEconomyCurrencyException(String errorMessage) {
+ super(errorMessage);
+ }
+}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index fc38a22..3eeedf6 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,7 @@ main: ca.tweetzy.auctionhouse.AuctionHouse
description: Auction House is a premium auction solution for your server.
website: https://tweetzy.ca/
authors: [Kiran Hart]
-softdepend: [Vault, PlayerPoints, PlaceholderAPI, MMOItems]
+softdepend: [Vault, PlayerPoints, PlaceholderAPIHook, MMOItemsHook, UltraEconomy]
commands:
auctionhouse: