diff --git a/pom.xml b/pom.xml
index 648b076..b5297b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
ca.tweetzy
auctionhouse
- 2.22.0
+ 2.23.0
UTF-8
@@ -138,20 +138,7 @@
ca.tweetzy
tweetycore
- 2.5.3
-
-
- com.github.MilkBowl
- VaultAPI
- 1.7
- provided
-
-
- org.black_ixx
- PlayerPoints
- 3.0.3
- system
- ${user.home}/Documents/Development/Minecraft/External Jars/PlayerPoints.jar
+ 2.6.0
org.projectlombok
diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
index fde7aa2..c12397c 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java
@@ -6,7 +6,6 @@ import ca.tweetzy.auctionhouse.commands.*;
import ca.tweetzy.auctionhouse.database.DataManager;
import ca.tweetzy.auctionhouse.database.migrations._1_InitialMigration;
import ca.tweetzy.auctionhouse.database.migrations._2_FilterWhitelistMigration;
-import ca.tweetzy.auctionhouse.economy.EconomyManager;
import ca.tweetzy.auctionhouse.listeners.AuctionListeners;
import ca.tweetzy.auctionhouse.listeners.PlayerListeners;
import ca.tweetzy.auctionhouse.managers.*;
@@ -23,6 +22,7 @@ import ca.tweetzy.core.database.DataMigrationManager;
import ca.tweetzy.core.database.DatabaseConnector;
import ca.tweetzy.core.database.MySQLConnector;
import ca.tweetzy.core.gui.GuiManager;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.utils.Metrics;
import ca.tweetzy.core.utils.TextUtils;
import co.aikar.taskchain.BukkitTaskChainFactory;
@@ -47,9 +47,6 @@ public class AuctionHouse extends TweetyPlugin {
private static TaskChainFactory taskChainFactory;
private static AuctionHouse instance;
- @Getter
- private EconomyManager economyManager;
-
@Getter
private final GuiManager guiManager = new GuiManager(this);
@@ -102,16 +99,18 @@ public class AuctionHouse extends TweetyPlugin {
taskChainFactory = BukkitTaskChainFactory.create(this);
+ // Load Economy
+ EconomyManager.load();
+
// Settings
Settings.setup();
- // Check the economy right after the settings setup
- this.economyManager = new EconomyManager(this);
-
// local
setLocale(Settings.LANG.getString());
LocaleSettings.setup();
+ // Setup Economy
+ EconomyManager.getManager().setPreferredHook(Settings.ECONOMY_PLUGIN.getString());
// listeners
Bukkit.getServer().getPluginManager().registerEvents(new PlayerListeners(), this);
@@ -186,6 +185,7 @@ public class AuctionHouse extends TweetyPlugin {
// metrics
this.metrics = new Metrics(this, 6806);
+
}
@Override
diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java
index 0dd0c6a..6abe6f4 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java
@@ -214,7 +214,7 @@ public class AuctionAPI {
.addField(Settings.DISCORD_MSG_FIELD_FINAL_PRICE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_sold").getMessage() : Settings.DISCORD_MSG_FIELD_FINAL_PRICE_VALUE.getString().replace("%final_price%", this.getFriendlyNumber(isBid ? auctionItem.getCurrentPrice() : auctionItem.getBasePrice())), Settings.DISCORD_MSG_FIELD_FINAL_PRICE_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_IS_BID_NAME.getString(), Settings.DISCORD_MSG_FIELD_IS_BID_VALUE.getString().replace("%is_bid%", isBid ? AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_true").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.is_bid_false").getMessage()), Settings.DISCORD_MSG_FIELD_IS_BID_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_NAME.getString(), isNew ? AuctionHouse.getInstance().getLocale().getMessage("discord.not_bought").getMessage() : Settings.DISCORD_MSG_FIELD_PURCHASE_TYPE_VALUE.getString().replace("%purchase_type%", saleType == AuctionSaleType.USED_BIDDING_SYSTEM ? AuctionHouse.getInstance().getLocale().getMessage("discord.sale_bid_win").getMessage() : AuctionHouse.getInstance().getLocale().getMessage("discord.sale_immediate_buy").getMessage()), Settings.DISCORD_MSG_FIELD_PURCHASE_INLINE.getBoolean())
- .addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", auctionItem.getItemName()), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean())
+ .addField(Settings.DISCORD_MSG_FIELD_ITEM_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_VALUE.getString().replace("%item_name%", ChatColor.stripColor(getItemName(deserializeItem(auctionItem.getRawItem())))), Settings.DISCORD_MSG_FIELD_ITEM_INLINE.getBoolean())
.addField(Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_NAME.getString(), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_VALUE.getString().replace("%item_amount%", String.valueOf(this.deserializeItem(auctionItem.getRawItem()).getAmount())), Settings.DISCORD_MSG_FIELD_ITEM_AMOUNT_INLINE.getBoolean())
);
@@ -377,7 +377,7 @@ public class AuctionAPI {
* Used to get any items that are similar to the provided stack in a player's inventory
*
* @param player is the player being checked
- * @param stack the item stack is being looked for
+ * @param stack the item stack is being looked for
* @return all the items that are similar to the stack
*/
public List getSimilarItemsFromInventory(Player player, ItemStack stack) {
@@ -432,7 +432,7 @@ public class AuctionAPI {
* Used to create an item bundle
*
* @param baseItem is the base item of the bundle (original)
- * @param items is the items that should be added to the bundle
+ * @param items is the items that should be added to the bundle
* @return an item stack with all the items saved in NBT tags
*/
public ItemStack createBundledItem(ItemStack baseItem, ItemStack... items) {
@@ -464,7 +464,7 @@ public class AuctionAPI {
time = time.toLowerCase();
char suffix = time.charAt(time.length() - 1);
int amount = Character.getNumericValue(time.charAt(time.length() - 2));
- switch(suffix) {
+ switch (suffix) {
case 's':
return amount;
case 'm':
diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java
index 49f2009..40cf8db 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java
@@ -13,6 +13,7 @@ import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.commands.AbstractCommand;
import ca.tweetzy.core.compatibility.CompatibleHand;
import ca.tweetzy.core.compatibility.XMaterial;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.nms.NBTEditor;
@@ -128,7 +129,9 @@ public class CommandSell extends AbstractCommand {
}
}
- boolean isBiddingItem = Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? listingPrices.size() == 3 : listingPrices.size() == 2;
+ boolean isBiddingItem = listingPrices.size() == 3 || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() && listingPrices.size() == 2;
+ if (Settings.FORCE_AUCTION_USAGE.getBoolean()) isBiddingItem = true;
+
/*======================================================================
================ THE PLAYER IS NOT USING THE BID OPTION ================
@@ -159,19 +162,21 @@ public class CommandSell extends AbstractCommand {
return ReturnType.FAILURE;
}
- if (listingPrices.get(1) < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
- return ReturnType.FAILURE;
- }
-
if (listingPrices.get(0) > Settings.MAX_AUCTION_START_PRICE.getDouble()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.maxstartingprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
- if (listingPrices.get(1) > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
- return ReturnType.FAILURE;
+ if (!Settings.FORCE_AUCTION_USAGE.getBoolean()) {
+ if (listingPrices.get(1) < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
+
+ if (listingPrices.get(1) > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
}
} else {
if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(0) < Settings.MIN_AUCTION_PRICE.getDouble() && !(listingPrices.get(0) <= -1)) {
@@ -179,35 +184,36 @@ public class CommandSell extends AbstractCommand {
return ReturnType.FAILURE;
}
- if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(1) < Settings.MIN_AUCTION_START_PRICE.getDouble()) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.minstartingprice").processPlaceholder("price", Settings.MIN_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player);
- return ReturnType.FAILURE;
- }
-
- if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(2) < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
- return ReturnType.FAILURE;
- }
-
- // check max
if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(0) > Settings.MAX_AUCTION_PRICE.getDouble()) {
AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbaseprice").processPlaceholder("price", Settings.MAX_AUCTION_PRICE.getDouble()).sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
- if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(1) > Settings.MAX_AUCTION_START_PRICE.getDouble()) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.maxstartingprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player);
- return ReturnType.FAILURE;
- }
+ if (!Settings.FORCE_AUCTION_USAGE.getBoolean()) {
+ if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(1) < Settings.MIN_AUCTION_START_PRICE.getDouble()) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.minstartingprice").processPlaceholder("price", Settings.MIN_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
- if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(2) > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
- return ReturnType.FAILURE;
- }
+ if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(2) < Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
- if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && isBiddingItem && listingPrices.get(1) > listingPrices.get(0) && !(listingPrices.get(0) <= -1)) {
- AuctionHouse.getInstance().getLocale().getMessage("pricing.basepricetoolow").sendPrefixedMessage(player);
- return ReturnType.FAILURE;
+ if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(1) > Settings.MAX_AUCTION_START_PRICE.getDouble()) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.maxstartingprice").processPlaceholder("price", Settings.MAX_AUCTION_START_PRICE.getDouble()).sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
+
+ if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && isBiddingItem && listingPrices.get(2) > Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.maxbidincrementprice").processPlaceholder("price", Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble()).sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
+
+ if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean() && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && isBiddingItem && listingPrices.get(1) > listingPrices.get(0) && !(listingPrices.get(0) <= -1)) {
+ AuctionHouse.getInstance().getLocale().getMessage("pricing.basepricetoolow").sendPrefixedMessage(player);
+ return ReturnType.FAILURE;
+ }
}
}
@@ -221,7 +227,7 @@ public class CommandSell extends AbstractCommand {
isUsingBundle = true;
}
- AuctionItem auctionItem = Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? new AuctionItem(
+ AuctionItem auctionItem = Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() && !Settings.FORCE_AUCTION_USAGE.getBoolean() ? new AuctionItem(
player.getUniqueId(),
player.getUniqueId(),
itemToSell,
@@ -241,18 +247,18 @@ public class CommandSell extends AbstractCommand {
UUID.randomUUID(),
isBiddingItem ? -1 : listingPrices.get(0),
isBiddingItem ? listingPrices.get(0) : 0,
- isBiddingItem ? listingPrices.get(1) : 0,
+ isBiddingItem ? listingPrices.size() == 1 ? 1 : listingPrices.get(1) : 0,
listingPrices.get(0),
allowedTime,
false
);
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
- if (!AuctionHouse.getInstance().getEconomyManager().has(player, Settings.TAX_LISTING_FEE.getDouble())) {
+ if (!EconomyManager.hasBalance(player, Settings.TAX_LISTING_FEE.getDouble())) {
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", String.format("%,.2f", Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(player);
return ReturnType.FAILURE;
}
- AuctionHouse.getInstance().getEconomyManager().withdrawPlayer(player, Settings.TAX_LISTING_FEE.getDouble());
+ EconomyManager.withdrawBalance(player, Settings.TAX_LISTING_FEE.getDouble());
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", String.format("%,.2f", Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", String.format("%,.2f", Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(player);
}
@@ -273,23 +279,19 @@ public class CommandSell extends AbstractCommand {
String NAX = AuctionHouse.getInstance().getLocale().getMessage("auction.biditemwithdisabledbuynow").getMessage();
- AuctionHouse.getInstance().getLocale().getMessage(isBiddingItem ? "auction.listed.withbid" : "auction.listed.nobid")
+ String msg = AuctionHouse.getInstance().getLocale().getMessage(isBiddingItem ? "auction.listed.withbid" : "auction.listed.nobid")
.processPlaceholder("amount", itemToSell.getAmount())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemToSell))
- .processPlaceholder("base_price", listingPrices.get(0) <= -1 || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? NAX : AuctionAPI.getInstance().formatNumber(listingPrices.get(0)))
- .processPlaceholder("start_price", isBiddingItem ? !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? AuctionAPI.getInstance().formatNumber(listingPrices.get(0)) : AuctionAPI.getInstance().formatNumber(listingPrices.get(1)) : 0)
- .processPlaceholder("increment_price", isBiddingItem ? !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? AuctionAPI.getInstance().formatNumber(listingPrices.get(1)) : AuctionAPI.getInstance().formatNumber(listingPrices.get(2)) : 0)
- .sendPrefixedMessage(player);
+ .processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()))
+ .processPlaceholder("start_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidStartPrice()))
+ .processPlaceholder("increment_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncPrice())).getMessage();
+
+ AuctionHouse.getInstance().getLocale().newMessage(msg).sendPrefixedMessage(player);
if (Settings.BROADCAST_AUCTION_LIST.getBoolean()) {
- Bukkit.getOnlinePlayers().forEach(AuctionHouse.getInstance().getLocale().getMessage(isBiddingItem ? "auction.listed.withbid" : "auction.broadcast.nobid")
- .processPlaceholder("player", player.getName())
- .processPlaceholder("amount", itemToSell.getAmount())
- .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemToSell))
- .processPlaceholder("base_price", listingPrices.get(0) <= -1 || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? NAX : AuctionAPI.getInstance().formatNumber(listingPrices.get(0)))
- .processPlaceholder("start_price", isBiddingItem ? !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? AuctionAPI.getInstance().formatNumber(listingPrices.get(0)) : AuctionAPI.getInstance().formatNumber(listingPrices.get(1)) : 0)
- .processPlaceholder("increment_price", isBiddingItem ? !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? AuctionAPI.getInstance().formatNumber(listingPrices.get(1)) : AuctionAPI.getInstance().formatNumber(listingPrices.get(2)) : 0)::sendPrefixedMessage);
+ Bukkit.getOnlinePlayers().forEach(p -> AuctionHouse.getInstance().getLocale().newMessage(msg).processPlaceholder("player", p.getName()).sendPrefixedMessage(p));
}
+
return ReturnType.SUCCESS;
}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/economy/EconomyManager.java b/src/main/java/ca/tweetzy/auctionhouse/economy/EconomyManager.java
deleted file mode 100644
index bb3625f..0000000
--- a/src/main/java/ca/tweetzy/auctionhouse/economy/EconomyManager.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package ca.tweetzy.auctionhouse.economy;
-
-import ca.tweetzy.auctionhouse.settings.Settings;
-import lombok.Getter;
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.plugin.java.JavaPlugin;
-
-/**
- * The current file has been created by Kiran Hart
- * Date Created: June 24 2021
- * Time Created: 11:26 p.m.
- * Usage of any code found within this class is prohibited unless given explicit permission otherwise
- */
-public class EconomyManager {
-
- private final JavaPlugin plugin;
- private IEconomy selectedEconomy;
-
- enum SupportedEconomy {
- VAULT("Vault"),
- PLAYER_POINTS("PlayerPoints");
-
- @Getter
- final String economyName;
-
- SupportedEconomy(String economyName) {
- this.economyName = economyName;
- }
- }
-
- public EconomyManager(JavaPlugin plugin) {
- this.plugin = plugin;
- String preferredEconomy = Settings.ECONOMY_MODE.getString();
-
- if (preferredEconomy.equalsIgnoreCase(SupportedEconomy.VAULT.getEconomyName())) {
- this.selectedEconomy = new VaultEconomy();
- if (!this.selectedEconomy.isEnabled()) {
- Bukkit.getPluginManager().disablePlugin(this.plugin);
- plugin.getLogger().severe("Something went wrong while trying to load the " + selectedEconomy.getHookName() + " economy!");
- }
- }
-
- if (preferredEconomy.equalsIgnoreCase(SupportedEconomy.PLAYER_POINTS.getEconomyName())) {
- this.selectedEconomy = new PlayerPointsEconomy();
- if (!this.selectedEconomy.isEnabled()) {
- Bukkit.getPluginManager().disablePlugin(this.plugin);
- plugin.getLogger().severe("Something went wrong while trying to load the " + selectedEconomy.getHookName() + " economy!");
- }
- }
-
- this.plugin.getLogger().info("Using " + selectedEconomy.getHookName() + " as the economy provider!");
- }
-
- public double getBalance(OfflinePlayer offlinePlayer) {
- return this.selectedEconomy.getBalance(offlinePlayer);
- }
-
- public boolean has(OfflinePlayer offlinePlayer, double cost) {
- return this.selectedEconomy.has(offlinePlayer, cost);
- }
-
- public boolean withdrawPlayer(OfflinePlayer offlinePlayer, double cost) {
- return this.selectedEconomy.withdraw(offlinePlayer, cost);
- }
-
- public boolean depositPlayer(OfflinePlayer offlinePlayer, double cost) {
- return this.selectedEconomy.deposit(offlinePlayer, cost);
- }
-}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/economy/IEconomy.java b/src/main/java/ca/tweetzy/auctionhouse/economy/IEconomy.java
deleted file mode 100644
index 71f769d..0000000
--- a/src/main/java/ca/tweetzy/auctionhouse/economy/IEconomy.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package ca.tweetzy.auctionhouse.economy;
-
-import org.bukkit.OfflinePlayer;
-
-/**
- * The current file has been created by Kiran Hart
- * Date Created: June 24 2021
- * Time Created: 11:21 p.m.
- * Usage of any code found within this class is prohibited unless given explicit permission otherwise
- */
-public interface IEconomy {
-
- String getHookName();
-
- boolean isEnabled();
-
- double getBalance(OfflinePlayer player);
-
- boolean has(OfflinePlayer player, double cost);
-
- boolean withdraw(OfflinePlayer player, double cost);
-
- boolean deposit(OfflinePlayer player, double cost);
-}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/economy/PlayerPointsEconomy.java b/src/main/java/ca/tweetzy/auctionhouse/economy/PlayerPointsEconomy.java
deleted file mode 100644
index 79e2a1b..0000000
--- a/src/main/java/ca/tweetzy/auctionhouse/economy/PlayerPointsEconomy.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package ca.tweetzy.auctionhouse.economy;
-
-import org.black_ixx.playerpoints.PlayerPoints;
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * The current file has been created by Kiran Hart
- * Date Created: June 24 2021
- * Time Created: 11:39 p.m.
- * Usage of any code found within this class is prohibited unless given explicit permission otherwise
- */
-public class PlayerPointsEconomy implements IEconomy {
-
- private final PlayerPoints playerPoints;
-
- public PlayerPointsEconomy() {
- this.playerPoints = (PlayerPoints) Bukkit.getServer().getPluginManager().getPlugin("PlayerPoints");
- }
-
- @Override
- public String getHookName() {
- return "PlayerPoints";
- }
-
- @Override
- public boolean isEnabled() {
- return playerPoints.isEnabled();
- }
-
- @Override
- public double getBalance(OfflinePlayer player) {
- AtomicInteger value = new AtomicInteger(0);
- playerPoints.getAPI().lookAsync(player.getUniqueId()).thenAccept(value::set);
- return value.get();
- }
-
- @Override
- public boolean has(OfflinePlayer player, double cost) {
- int total = 0;
- try {
- total = playerPoints.getAPI().lookAsync(player.getUniqueId()).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- return total >= convert(cost);
- }
-
- @Override
- public boolean withdraw(OfflinePlayer player, double cost) {
- boolean success = false;
- try {
- success = playerPoints.getAPI().takeAsync(player.getUniqueId(), convert(cost)).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- return success;
- }
-
- @Override
- public boolean deposit(OfflinePlayer player, double cost) {
- boolean success = false;
- try {
- success = playerPoints.getAPI().giveAsync(player.getUniqueId(), convert(cost)).get();
- } catch (InterruptedException | ExecutionException e) {
- e.printStackTrace();
- }
- return success;
- }
-
- private int convert(double amount) {
- return (int) Math.ceil(amount);
- }
-}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/economy/VaultEconomy.java b/src/main/java/ca/tweetzy/auctionhouse/economy/VaultEconomy.java
deleted file mode 100644
index cc70b06..0000000
--- a/src/main/java/ca/tweetzy/auctionhouse/economy/VaultEconomy.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package ca.tweetzy.auctionhouse.economy;
-
-import ca.tweetzy.auctionhouse.exception.EconomyProviderNotFoundException;
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.plugin.RegisteredServiceProvider;
-
-/**
- * The current file has been created by Kiran Hart
- * Date Created: June 24 2021
- * Time Created: 11:23 p.m.
- * Usage of any code found within this class is prohibited unless given explicit permission otherwise
- */
-public class VaultEconomy implements IEconomy {
-
- private final net.milkbowl.vault.economy.Economy vault;
-
- public VaultEconomy() {
- RegisteredServiceProvider v = Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
- if (v != null) {
- this.vault = v.getProvider();
- } else {
- this.vault = null;
- throw new EconomyProviderNotFoundException("Could not find any plugin to hook into: " + getHookName());
- }
- }
-
- @Override
- public String getHookName() {
- return "Vault";
- }
-
- @Override
- public boolean isEnabled() {
- return vault != null;
- }
-
- @Override
- public double getBalance(OfflinePlayer player) {
- if (vault == null) return 0D;
- return vault.getBalance(player);
- }
-
- @Override
- public boolean has(OfflinePlayer player, double cost) {
- return vault != null && vault.has(player, cost);
- }
-
- @Override
- public boolean withdraw(OfflinePlayer player, double cost) {
- return vault != null && vault.withdrawPlayer(player, cost).transactionSuccess();
- }
-
- @Override
- public boolean deposit(OfflinePlayer player, double cost) {
- return vault != null && vault.depositPlayer(player, cost).transactionSuccess();
- }
-}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/exception/EconomyProviderNotFoundException.java b/src/main/java/ca/tweetzy/auctionhouse/exception/EconomyProviderNotFoundException.java
deleted file mode 100644
index 962cc3f..0000000
--- a/src/main/java/ca/tweetzy/auctionhouse/exception/EconomyProviderNotFoundException.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package ca.tweetzy.auctionhouse.exception;
-
-/**
- * The current file has been created by Kiran Hart
- * Date Created: June 24 2021
- * Time Created: 11:17 p.m.
- * Usage of any code found within this class is prohibited unless given explicit permission otherwise
- */
-public class EconomyProviderNotFoundException extends NullPointerException {
-
- public EconomyProviderNotFoundException(String errorMessage) {
- super(errorMessage);
- }
-}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java
index 2a08c73..d93061c 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java
@@ -15,6 +15,7 @@ import ca.tweetzy.core.compatibility.ServerVersion;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.TimeUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
@@ -150,7 +151,7 @@ public class GUIAuctionHouse extends Gui {
return;
}
- if (!AuctionHouse.getInstance().getEconomyManager().has(e.player, auctionItem.getBasePrice())) {
+ if (!EconomyManager.hasBalance(e.player, auctionItem.getBasePrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;
}
@@ -187,7 +188,7 @@ public class GUIAuctionHouse extends Gui {
return;
}
- if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getInstance().getEconomyManager().has(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
+ if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;
}
@@ -198,7 +199,7 @@ public class GUIAuctionHouse extends Gui {
} else {
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setCurrentPrice(auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice());
- if (Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
+ if (auctionItem.getBasePrice() != -1 && Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
auctionItem.setBasePrice(auctionItem.getCurrentPrice());
}
@@ -298,7 +299,7 @@ public class GUIAuctionHouse extends Gui {
private void drawFixedButtons() {
setButton(5, 0, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_ITEM.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_NAME.getString(), Settings.GUI_AUCTION_HOUSE_ITEMS_YOUR_AUCTIONS_LORE.getStringList(), new HashMap() {{
put("%active_player_auctions%", auctionPlayer.getItems(false).size());
- put("%player_balance%", AuctionAPI.getInstance().formatNumber(AuctionHouse.getInstance().getEconomyManager().getBalance(auctionPlayer.getPlayer())));
+ put("%player_balance%", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(auctionPlayer.getPlayer())));
}}), e -> {
cleanup();
e.manager.showGUI(e.player, new GUIActiveAuctions(this.auctionPlayer));
diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java
index 0ddab29..d45c85b 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java
@@ -13,6 +13,7 @@ import ca.tweetzy.core.commands.AbstractCommand;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.input.ChatPrompt;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.core.utils.PlayerUtils;
@@ -96,6 +97,10 @@ public class GUISellItem extends Gui {
}
});
+ if (Settings.FORCE_AUCTION_USAGE.getBoolean()) {
+ this.isBiddingItem = true;
+ }
+
setUnlocked(1, 4);
setUnlockedRange(45, 89);
draw();
@@ -121,30 +126,32 @@ public class GUISellItem extends Gui {
this.itemToBeListed = e.clickedItem;
});
- setButton(3, 1, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_BUY_NOW_ITEM.getString(), Settings.GUI_SELL_ITEMS_BUY_NOW_NAME.getString(), Settings.GUI_SELL_ITEMS_BUY_NOW_LORE.getStringList(), new HashMap() {{
- put("%buy_now_price%", AuctionAPI.getInstance().formatNumber(buyNowPrice));
- }}), ClickType.LEFT, e -> {
- setTheItemToBeListed();
- setAllowClose(true);
- e.gui.close();
+ if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) {
+ setButton(3, 1, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_BUY_NOW_ITEM.getString(), Settings.GUI_SELL_ITEMS_BUY_NOW_NAME.getString(), Settings.GUI_SELL_ITEMS_BUY_NOW_LORE.getStringList(), new HashMap() {{
+ put("%buy_now_price%", AuctionAPI.getInstance().formatNumber(buyNowPrice));
+ }}), ClickType.LEFT, e -> {
+ setTheItemToBeListed();
+ setAllowClose(true);
+ e.gui.close();
- ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new buy now price").getMessage()), chat -> {
- String msg = chat.getMessage();
- if (validateChatNumber(msg, Settings.MIN_AUCTION_PRICE.getDouble())) {
- // check if the buy now price is higher than the bid start price
- if (this.isAllowingBuyNow && this.isBiddingItem && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && Double.parseDouble(msg) < this.bidStartPrice) {
+ ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new buy now price").getMessage()), chat -> {
+ String msg = chat.getMessage();
+ if (validateChatNumber(msg, Settings.MIN_AUCTION_PRICE.getDouble())) {
+ // check if the buy now price is higher than the bid start price
+ if (this.isAllowingBuyNow && this.isBiddingItem && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && Double.parseDouble(msg) < this.bidStartPrice) {
+ reopen(e);
+ return;
+ }
+
+ this.buyNowPrice = Double.parseDouble(msg);
reopen(e);
- return;
}
-
- this.buyNowPrice = Double.parseDouble(msg);
- reopen(e);
- }
- }).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
- });
+ }).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
+ });
+ }
if (this.isBiddingItem) {
- setButton(3, 2, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_STARTING_BID_ITEM.getString(), Settings.GUI_SELL_ITEMS_STARTING_BID_NAME.getString(), Settings.GUI_SELL_ITEMS_STARTING_BID_LORE.getStringList(), new HashMap() {{
+ setButton(3, Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? 2 : 1, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_SELL_ITEMS_STARTING_BID_ITEM.getString(), Settings.GUI_SELL_ITEMS_STARTING_BID_NAME.getString(), Settings.GUI_SELL_ITEMS_STARTING_BID_LORE.getStringList(), new HashMap() {{
put("%starting_bid_price%", AuctionAPI.getInstance().formatNumber(bidStartPrice));
}}), ClickType.LEFT, e -> {
setTheItemToBeListed();
@@ -174,12 +181,13 @@ public class GUISellItem extends Gui {
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
});
- setButton(3, 6, ConfigurationItemHelper.createConfigurationItem(this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_ITEM.getString(), this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_NAME.getString(), this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_LORE.getStringList(), null), ClickType.LEFT, e -> {
- this.isAllowingBuyNow = !this.isAllowingBuyNow;
- setTheItemToBeListed();
- draw();
- });
-
+ if (Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) {
+ setButton(3, 6, ConfigurationItemHelper.createConfigurationItem(this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_ITEM.getString(), this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_NAME.getString(), this.isAllowingBuyNow ? Settings.GUI_SELL_ITEMS_BUY_NOW_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BUY_NOW_DISABLED_LORE.getStringList(), null), ClickType.LEFT, e -> {
+ this.isAllowingBuyNow = !this.isAllowingBuyNow;
+ setTheItemToBeListed();
+ draw();
+ });
+ }
}
setButton(3, 4, ConfigurationItemHelper.createConfigurationItem(Settings.GUI_CLOSE_BTN_ITEM.getString(), Settings.GUI_CLOSE_BTN_NAME.getString(), Settings.GUI_CLOSE_BTN_LORE.getStringList(), null), e -> {
@@ -190,7 +198,9 @@ public class GUISellItem extends Gui {
if (Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean()) {
setButton(3, 5, ConfigurationItemHelper.createConfigurationItem(this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_ITEM.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_ITEM.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_NAME.getString() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_NAME.getString(), this.isBiddingItem ? Settings.GUI_SELL_ITEMS_BIDDING_ENABLED_LORE.getStringList() : Settings.GUI_SELL_ITEMS_BIDDING_DISABLED_LORE.getStringList(), null), e -> {
- this.isBiddingItem = !this.isBiddingItem;
+ if (!Settings.FORCE_AUCTION_USAGE.getBoolean()) {
+ this.isBiddingItem = !this.isBiddingItem;
+ }
setTheItemToBeListed();
draw();
});
@@ -226,11 +236,11 @@ public class GUISellItem extends Gui {
if (auctionStartEvent.isCancelled()) return;
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
- if (!AuctionHouse.getInstance().getEconomyManager().has(e.player, Settings.TAX_LISTING_FEE.getDouble())) {
+ if (!EconomyManager.hasBalance(e.player, Settings.TAX_LISTING_FEE.getDouble())) {
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", String.format("%,.2f", Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(e.player);
return;
}
- AuctionHouse.getInstance().getEconomyManager().withdrawPlayer(e.player, Settings.TAX_LISTING_FEE.getDouble());
+ EconomyManager.withdrawBalance(e.player, Settings.TAX_LISTING_FEE.getDouble());
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", String.format("%,.2f", Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(e.player);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", String.format("%,.2f", Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(e.player);
}
@@ -251,22 +261,17 @@ public class GUISellItem extends Gui {
// TODO FIGURE OUT WHY THE HELL THIS IS NOT WORKING
String NAX = AuctionHouse.getInstance().getLocale().getMessage("auction.biditemwithdisabledbuynow").getMessage();
- AuctionHouse.getInstance().getLocale().getMessage(isBiddingItem ? "auction.listed.withbid" : "auction.listed.nobid")
- .processPlaceholder("player", e.player.getName())
+ String msg = AuctionHouse.getInstance().getLocale().getMessage(isBiddingItem ? "auction.listed.withbid" : "auction.listed.nobid")
.processPlaceholder("amount", itemToBeListed.getAmount())
.processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemToBeListed))
- .processPlaceholder("base_price", !isAllowingBuyNow ? NAX : AuctionAPI.getInstance().formatNumber(buyNowPrice))
- .processPlaceholder("start_price", isBiddingItem ? AuctionAPI.getInstance().formatNumber(bidStartPrice) : 0)
- .processPlaceholder("increment_price", isBiddingItem ? AuctionAPI.getInstance().formatNumber(bidIncrementPrice) : 0).sendPrefixedMessage(e.player);
+ .processPlaceholder("base_price", auctionItem.getBasePrice() <= -1 ? NAX : AuctionAPI.getInstance().formatNumber(auctionItem.getBasePrice()))
+ .processPlaceholder("start_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidStartPrice()))
+ .processPlaceholder("increment_price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncPrice())).getMessage();
+
+ AuctionHouse.getInstance().getLocale().newMessage(msg).sendPrefixedMessage(e.player);
if (Settings.BROADCAST_AUCTION_LIST.getBoolean()) {
- Bukkit.getOnlinePlayers().forEach(AuctionHouse.getInstance().getLocale().getMessage(isBiddingItem ? "auction.listed.withbid" : "auction.broadcast.nobid")
- .processPlaceholder("player", e.player.getName())
- .processPlaceholder("amount", itemToBeListed.getAmount())
- .processPlaceholder("item", AuctionAPI.getInstance().getItemName(itemToBeListed))
- .processPlaceholder("base_price", !isAllowingBuyNow ? NAX : AuctionAPI.getInstance().formatNumber(buyNowPrice))
- .processPlaceholder("start_price", isBiddingItem ? AuctionAPI.getInstance().formatNumber(bidStartPrice) : 0)
- .processPlaceholder("increment_price", isBiddingItem ? AuctionAPI.getInstance().formatNumber(bidIncrementPrice) : 0)::sendPrefixedMessage);
+ Bukkit.getOnlinePlayers().forEach(p -> AuctionHouse.getInstance().getLocale().newMessage(msg).processPlaceholder("player", p.getName()).sendPrefixedMessage(p));
}
});
}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java
index 9ae3961..494301a 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java
@@ -7,6 +7,7 @@ import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.gui.Gui;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import org.bukkit.event.inventory.ClickType;
@@ -47,14 +48,14 @@ public class GUIConfirmBid extends Gui {
return;
}
- if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !AuctionHouse.getInstance().getEconomyManager().has(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
+ if (Settings.PLAYER_NEEDS_TOTAL_PRICE_TO_BID.getBoolean() && !EconomyManager.hasBalance(e.player, auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice())) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
return;
}
auctionItem.setHighestBidder(e.player.getUniqueId());
auctionItem.setCurrentPrice(auctionItem.getCurrentPrice() + auctionItem.getBidIncPrice());
- if (Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
+ if (auctionItem.getBasePrice() != -1 && Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) {
auctionItem.setBasePrice(auctionItem.getCurrentPrice());
}
diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java
index 1459c05..ed55ccd 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java
@@ -14,6 +14,7 @@ import ca.tweetzy.auctionhouse.managers.SoundManager;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.gui.events.GuiClickEvent;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
@@ -116,7 +117,7 @@ public class GUIConfirmPurchase extends Gui {
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * buyNowPrice : 0D;
// Check economy
- if (!AuctionHouse.getInstance().getEconomyManager().has(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) {
+ if (!EconomyManager.hasBalance(e.player, buyNowPrice + (Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? tax : 0D))) {
AuctionHouse.getInstance().getLocale().getMessage("general.notenoughmoney").sendPrefixedMessage(e.player);
SoundManager.getInstance().playSound(e.player, Settings.SOUNDS_NOT_ENOUGH_MONEY.getString(), 1.0F, 1.0F);
e.gui.close();
@@ -188,8 +189,8 @@ public class GUIConfirmPurchase extends Gui {
private void transferFunds(Player from, double amount) {
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * amount : 0D;
- AuctionHouse.getInstance().getEconomyManager().withdrawPlayer(from, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount + tax : amount);
- AuctionHouse.getInstance().getEconomyManager().depositPlayer(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount : amount - tax);
+ EconomyManager.withdrawBalance(from, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount + tax : amount);
+ EconomyManager.deposit(Bukkit.getOfflinePlayer(this.auctionItem.getOwner()), Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? amount : amount - tax);
}
private void sendMessages(GuiClickEvent e, AuctionItem located, boolean overwritePrice, double price) {
@@ -199,7 +200,7 @@ public class GUIConfirmPurchase extends Gui {
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player);
if (Bukkit.getOfflinePlayer(located.getOwner()).isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
- .processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(located.getRawItem()).getType().name().replace("_", " ")))
+ .processPlaceholder("item", AuctionAPI.getInstance().getItemName(AuctionAPI.getInstance().deserializeItem(this.auctionItem.getRawItem())))
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax))
.processPlaceholder("buyer_name", e.player.getName())
.sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer());
diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java
index bf7a595..02f29a9 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/settings/Settings.java
@@ -5,9 +5,11 @@ import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.compatibility.XSound;
import ca.tweetzy.core.configuration.Config;
import ca.tweetzy.core.configuration.ConfigSetting;
+import ca.tweetzy.core.hooks.EconomyManager;
import java.util.Arrays;
import java.util.Collections;
+import java.util.stream.Collectors;
/**
* The current file has been created by Kiran Hart
@@ -20,7 +22,10 @@ public class Settings {
static final Config config = AuctionHouse.getInstance().getCoreConfig();
public static final ConfigSetting LANG = new ConfigSetting(config, "lang", "en_US", "Default language file");
- public static final ConfigSetting ECONOMY_MODE = new ConfigSetting(config, "economy provider", "Vault", "Supported Economies:", "Vault", "PlayerPoints");
+ public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "economy provider", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
+ "Which economy should auction house use?",
+ "You have the following supported economy plugins installed: \"" + EconomyManager.getManager().getPossiblePlugins().stream().collect(Collectors.joining("\", \"")) + "\"."
+ );
/* ===============================
* BASIC SETTINGS
* ===============================*/
@@ -54,6 +59,7 @@ public class Settings {
public static final ConfigSetting ASK_FOR_BID_CONFIRMATION = new ConfigSetting(config, "auction setting.ask for bid confirmation", true, "Should Auction House open the confirmation menu for the user to confirm", "whether they actually meant to place a bid or not?");
public static final ConfigSetting REPLACE_HOW_TO_SELL_WITH_LIST_BUTTON = new ConfigSetting(config, "auction setting.replace how to sell with list button", false, "This will replace the \"How to Sell\" button with a List Item button");
public static final ConfigSetting ALLOW_USAGE_OF_SELL_GUI = new ConfigSetting(config, "auction setting.allow usage of sell gui", true, "Should the sell menu be enabled?");
+ public static final ConfigSetting FORCE_AUCTION_USAGE = new ConfigSetting(config, "auction setting.force auction usage", true, "If enabled, all items sold on the auction house must be an auction (biddable) items");
public static final ConfigSetting ASK_FOR_CANCEL_CONFIRM_ON_BID_ITEMS = new ConfigSetting(config, "auction setting.ask for cancel confirm on bid items", true, "Should Auction House ask the user if they want to cancel the item?");
public static final ConfigSetting ASK_FOR_CANCEL_CONFIRM_ON_NON_BID_ITEMS = new ConfigSetting(config, "auction setting.ask for cancel confirm on non bid items", false, "Should Auction House ask the user if they want to cancel the item?");
diff --git a/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java b/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java
index d60749c..d547d43 100644
--- a/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java
+++ b/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java
@@ -6,6 +6,7 @@ import ca.tweetzy.auctionhouse.api.events.AuctionEndEvent;
import ca.tweetzy.auctionhouse.auction.AuctionItem;
import ca.tweetzy.auctionhouse.auction.AuctionSaleType;
import ca.tweetzy.auctionhouse.settings.Settings;
+import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.utils.PlayerUtils;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
@@ -67,7 +68,7 @@ public class TickAuctionsTask extends BukkitRunnable {
double finalPrice = auctionItem.getCurrentPrice();
double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_AUCTION_WON_PERCENTAGE.getDouble() / 100) * auctionItem.getCurrentPrice() : 0D;
- if (!AuctionHouse.getInstance().getEconomyManager().has(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)) {
+ if (!EconomyManager.hasBalance(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)) {
auctionItem.setExpired(true);
continue;
}
@@ -77,12 +78,12 @@ public class TickAuctionsTask extends BukkitRunnable {
if (auctionEndEvent.isCancelled()) continue;
- AuctionHouse.getInstance().getEconomyManager().withdrawPlayer(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice);
- AuctionHouse.getInstance().getEconomyManager().depositPlayer(Bukkit.getOfflinePlayer(auctionItem.getOwner()), Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice: finalPrice - tax);
+ EconomyManager.withdrawBalance(auctionWinner, Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice);
+ EconomyManager.deposit(Bukkit.getOfflinePlayer(auctionItem.getOwner()), Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice: finalPrice - tax);
if (Bukkit.getOfflinePlayer(auctionItem.getOwner()).isOnline()) {
AuctionHouse.getInstance().getLocale().getMessage("auction.itemsold")
- .processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(auctionItem.getRawItem()).getType().name().replace("_", " ")))
+ .processPlaceholder("item", AuctionAPI.getInstance().getItemName(AuctionAPI.getInstance().deserializeItem(auctionItem.getRawItem())))
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax))
.processPlaceholder("buyer_name", Bukkit.getOfflinePlayer(auctionItem.getHighestBidder()).getName())
.sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer());
@@ -92,7 +93,7 @@ public class TickAuctionsTask extends BukkitRunnable {
if (auctionWinner.isOnline()) {
assert auctionWinner.getPlayer() != null;
AuctionHouse.getInstance().getLocale().getMessage("auction.bidwon")
- .processPlaceholder("item", WordUtils.capitalizeFully(AuctionAPI.getInstance().deserializeItem(auctionItem.getRawItem()).getType().name().replace("_", " ")))
+ .processPlaceholder("item", AuctionAPI.getInstance().getItemName(AuctionAPI.getInstance().deserializeItem(auctionItem.getRawItem())))
.processPlaceholder("amount", AuctionAPI.getInstance().deserializeItem(auctionItem.getRawItem()).getAmount())
.processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice))
.sendPrefixedMessage(auctionWinner.getPlayer());
diff --git a/src/main/test/Test.java b/src/main/test/Test.java
index 751bf93..a54aed2 100644
--- a/src/main/test/Test.java
+++ b/src/main/test/Test.java
@@ -1,5 +1,3 @@
-import ca.tweetzy.core.utils.TimeUtils;
-
/**
* The current file has been created by Kiran Hart
* Date Created: July 21 2021
@@ -9,7 +7,9 @@ import ca.tweetzy.core.utils.TimeUtils;
public class Test {
public static void main(String[] args) {
- System.out.println(TimeUtils.makeReadable(getSecondsFromString("2y")*1000));
+// System.out.println(TimeUtils.makeReadable(getSecondsFromString("2y")*1000));
+
+
}
public static long getSecondsFromString(String time) {