From b8844a5494269b05c4496e8dcb8caf8e628e410a Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Mon, 16 Aug 2021 01:08:29 -0400 Subject: [PATCH] 2.26.0 --- pom.xml | 2 +- .../ca/tweetzy/auctionhouse/AuctionHouse.java | 3 +- .../tweetzy/auctionhouse/api/AuctionAPI.java | 12 ++--- .../auctionhouse/commands/CommandSell.java | 3 +- .../_5_TransactionChangeMigration.java | 2 +- .../_7_TransactionBigIntMigration.java | 47 +++++++++++++++++++ .../auctionhouse/guis/GUIAuctionHouse.java | 2 + .../auctionhouse/guis/GUISellItem.java | 6 ++- .../guis/confirmation/GUIConfirmPurchase.java | 6 ++- .../auctionhouse/settings/LocaleSettings.java | 5 +- .../auctionhouse/tasks/TickAuctionsTask.java | 4 +- 11 files changed, 73 insertions(+), 19 deletions(-) create mode 100644 src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java diff --git a/pom.xml b/pom.xml index 907722b..f75481d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 ca.tweetzy auctionhouse - 2.25.2 + 2.25.3 UTF-8 diff --git a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java index a49c8a9..2c6624a 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/AuctionHouse.java @@ -144,7 +144,8 @@ public class AuctionHouse extends TweetyPlugin { new _3_BansMigration(), new _4_ItemsChangeMigration(), new _5_TransactionChangeMigration(), - new _6_BigIntMigration() + new _6_BigIntMigration(), + new _7_TransactionBigIntMigration() ); dataMigrationManager.runMigrations(); diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java index 128280c..dea6cda 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java +++ b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java @@ -3,8 +3,6 @@ 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.api.hook.PlaceholderAPI; -import ca.tweetzy.auctionhouse.auction.AuctionItem; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; import ca.tweetzy.auctionhouse.auction.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.AuctionedItem; @@ -20,7 +18,6 @@ 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 io.lumine.mythic.lib.api.itemtype.MMOItemType; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.WordUtils; import org.bukkit.Bukkit; @@ -554,7 +551,7 @@ public class AuctionAPI { * @param isBiddingItem States whether the item is an auction or bin item * @param isUsingBundle States whether the item is a bundled item */ - public void listAuction(Player seller, ItemStack original, ItemStack item, int seconds, double basePrice, double bidStartPrice, double bidIncPrice, double currentPrice, boolean isBiddingItem, boolean isUsingBundle) { + public void listAuction(Player seller, ItemStack original, ItemStack item, int seconds, double basePrice, double bidStartPrice, double bidIncPrice, double currentPrice, boolean isBiddingItem, boolean isUsingBundle, boolean requiresHandRemove) { AuctionedItem auctionedItem = new AuctionedItem(); auctionedItem.setId(UUID.randomUUID()); auctionedItem.setOwner(seller.getUniqueId()); @@ -578,7 +575,7 @@ public class AuctionAPI { } EconomyManager.withdrawBalance(seller, Settings.TAX_LISTING_FEE.getDouble()); AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller); } AuctionStartEvent startEvent = new AuctionStartEvent(seller, auctionedItem); @@ -591,7 +588,8 @@ public class AuctionAPI { if (isUsingBundle) { AuctionAPI.getInstance().removeSpecificItemQuantityFromPlayer(seller, original, totalOriginal); } else { - PlayerUtils.takeActiveItem(seller, CompatibleHand.MAIN_HAND, totalOriginal); + if (requiresHandRemove) + PlayerUtils.takeActiveItem(seller, CompatibleHand.MAIN_HAND, totalOriginal); } SoundManager.getInstance().playSound(seller, Settings.SOUNDS_LISTED_ITEM_ON_AUCTION_HOUSE.getString(), 1.0F, 1.0F); @@ -637,7 +635,7 @@ public class AuctionAPI { // If the item could not be added for whatever reason and the tax listing fee is enabled, refund them if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) { EconomyManager.deposit(seller, Settings.TAX_LISTING_FEE.getDouble()); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller); } return; } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java index 98e5925..c9a1828 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java @@ -233,7 +233,8 @@ public class CommandSell extends AbstractCommand { buyNowAllow ? isBiddingItem ? listingPrices.get(2) : 0 : isBiddingItem ? listingPrices.size() == 1 ? 1 : listingPrices.get(1) : 0, buyNowAllow ? isBiddingItem ? listingPrices.get(1) : listingPrices.get(0) : listingPrices.get(0), isBiddingItem, - isUsingBundle + isUsingBundle, + true ); return ReturnType.SUCCESS; diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_5_TransactionChangeMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_5_TransactionChangeMigration.java index 76a232d..2a6a204 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_5_TransactionChangeMigration.java +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_5_TransactionChangeMigration.java @@ -28,7 +28,7 @@ public class _5_TransactionChangeMigration extends DataMigration { "seller_name VARCHAR(16) NOT NULL, " + "buyer VARCHAR(36) NOT NULL," + "buyer_name VARCHAR(16) NOT NULL," + - "transaction_time TinyInt NOT NULL, " + + "transaction_time BigInt NOT NULL, " + "item TEXT NOT NULL, " + "auction_sale_type VARCHAR(32) NOT NULL, " + "final_price DOUBLE NOT NULL " + diff --git a/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java new file mode 100644 index 0000000..1813164 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/database/migrations/_7_TransactionBigIntMigration.java @@ -0,0 +1,47 @@ +package ca.tweetzy.auctionhouse.database.migrations; + +import ca.tweetzy.auctionhouse.AuctionHouse; +import ca.tweetzy.core.database.DataMigration; +import ca.tweetzy.core.database.MySQLConnector; + +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; + +/** + * The current file has been created by Kiran Hart + * Date Created: August 12 2021 + * Time Created: 11:58 a.m. + * Usage of any code found within this class is prohibited unless given explicit permission otherwise + */ +public class _7_TransactionBigIntMigration extends DataMigration { + + public _7_TransactionBigIntMigration() { + super(6); + } + + @Override + public void migrate(Connection connection, String tablePrefix) throws SQLException { + try (Statement statement = connection.createStatement()) { + + if (AuctionHouse.getInstance().getDatabaseConnector() instanceof MySQLConnector) { + statement.execute("ALTER TABLE " + tablePrefix + "transactions MODIFY COLUMN transaction_time BigInt(20)"); + + } else { + statement.execute("DROP TABLE " + tablePrefix + "transactions"); + statement.execute("CREATE TABLE " + tablePrefix + "transactions (" + + "id VARCHAR(36) PRIMARY KEY, " + + "seller VARCHAR(36) NOT NULL, " + + "seller_name VARCHAR(16) NOT NULL, " + + "buyer VARCHAR(36) NOT NULL," + + "buyer_name VARCHAR(16) NOT NULL," + + "transaction_time BigInt(20) NOT NULL, " + + "item TEXT NOT NULL, " + + "auction_sale_type VARCHAR(32) NOT NULL, " + + "final_price DOUBLE NOT NULL " + + " )"); + } + + } + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java index 97142a2..49cacb7 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIAuctionHouse.java @@ -9,11 +9,13 @@ import ca.tweetzy.auctionhouse.guis.transaction.GUITransactionList; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.managers.SoundManager; import ca.tweetzy.auctionhouse.settings.Settings; +import ca.tweetzy.core.compatibility.CompatibleHand; 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.PlayerUtils; import ca.tweetzy.core.utils.TextUtils; import ca.tweetzy.core.utils.items.TItemBuilder; import ca.tweetzy.core.utils.nms.NBTEditor; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java index bc2bb57..a7d42ea 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUISellItem.java @@ -12,6 +12,7 @@ import ca.tweetzy.core.input.ChatPrompt; import ca.tweetzy.core.utils.NumberUtils; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.core.utils.TextUtils; +import org.bukkit.Bukkit; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; @@ -210,14 +211,15 @@ public class GUISellItem extends Gui { AuctionAPI.getInstance().listAuction( e.player, - this.itemToBeListed, - this.itemToBeListed, + this.itemToBeListed.clone(), + this.itemToBeListed.clone(), this.auctionPlayer.getAllowedSellTime(), this.isBiddingItem && !isAllowingBuyNow || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? -1 : buyNowPrice, this.isBiddingItem ? bidStartPrice : 0, this.isBiddingItem ? bidIncrementPrice : 0, this.isBiddingItem ? bidStartPrice : buyNowPrice, this.isBiddingItem, + false, false ); 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 d730174..f4c5286 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmPurchase.java @@ -196,14 +196,16 @@ public class GUIConfirmPurchase extends Gui { double totalPrice = overwritePrice ? price : located.getBasePrice(); double tax = Settings.TAX_ENABLED.getBoolean() ? (Settings.TAX_SALES_TAX_BUY_NOW_PERCENTAGE.getDouble() / 100) * totalPrice : 0D; - 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); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(e.player))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice - tax : totalPrice)).sendPrefixedMessage(e.player); + AuctionHouse.getInstance().getLocale().getMessage("general.bought_item").processPlaceholder("amount", located.getItem().getAmount()).processPlaceholder("item", AuctionAPI.getInstance().getItemName(located.getItem())).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", AuctionAPI.getInstance().getItemName(this.auctionItem.getItem())) .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()); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(Bukkit.getOfflinePlayer(located.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? totalPrice : totalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(located.getOwner()).getPlayer()); } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java b/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java index 83e3f4e..73d0fa0 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java +++ b/src/main/java/ca/tweetzy/auctionhouse/settings/LocaleSettings.java @@ -43,6 +43,7 @@ public class LocaleSettings { languageNodes.put("general.something_went_wrong_while_listing", "&cSomething went wrong while listing item."); languageNodes.put("general.toggled listing.on", "&aYou turned on listing messages"); languageNodes.put("general.toggled listing.off", "&cYou turned off listing messages"); + languageNodes.put("general.bought_item", "&aYou bought &fx%amount% %item%&a for &a$%price%"); languageNodes.put("pricing.minbaseprice", "&cThe minimum base price must be &a$%price%"); @@ -52,8 +53,8 @@ public class LocaleSettings { languageNodes.put("pricing.maxstartingprice", "&cThe maximum starting bid price is &a$%price%"); languageNodes.put("pricing.maxbidincrementprice", "&cThe maximum bid increment is &a$%price%"); languageNodes.put("pricing.basepricetoolow", "&cThe buy now price must be higher than the starting bid."); - languageNodes.put("pricing.moneyremove", "&c&l- $%price%"); - languageNodes.put("pricing.moneyadd", "&a&l+ $%price%"); + languageNodes.put("pricing.moneyremove", "&c&l- $%price% &7(%player_balance%)"); + languageNodes.put("pricing.moneyadd", "&a&l+ $%price% &7(%player_balance%)"); languageNodes.put("prompts.enter new buy now price", "&aPlease enter the new buy now price in chat:"); languageNodes.put("prompts.enter new starting bid", "&aPlease enter the new starting bid in chat:"); diff --git a/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java b/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java index 1b3e3f2..e53698d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java +++ b/src/main/java/ca/tweetzy/auctionhouse/tasks/TickAuctionsTask.java @@ -98,7 +98,7 @@ public class TickAuctionsTask extends BukkitRunnable { .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()); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(Bukkit.getOfflinePlayer(auctionItem.getOwner())))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice : finalPrice - tax)).sendPrefixedMessage(Bukkit.getOfflinePlayer(auctionItem.getOwner()).getPlayer()); } if (auctionWinner.isOnline()) { @@ -108,7 +108,7 @@ public class TickAuctionsTask extends BukkitRunnable { .processPlaceholder("amount", itemStack.getAmount()) .processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)) .sendPrefixedMessage(auctionWinner.getPlayer()); - AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)).sendPrefixedMessage(auctionWinner.getPlayer()); + AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(auctionWinner.getPlayer()))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_CHARGE_SALES_TAX_TO_BUYER.getBoolean() ? finalPrice + tax : finalPrice)).sendPrefixedMessage(auctionWinner.getPlayer()); if (Settings.ALLOW_PURCHASE_IF_INVENTORY_FULL.getBoolean()) { PlayerUtils.giveItem(auctionWinner.getPlayer(), itemStack);