This commit is contained in:
Kiran Hart 2021-08-16 01:08:29 -04:00
parent e74d2aecb0
commit b8844a5494
11 changed files with 73 additions and 19 deletions

View File

@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId>
<version>2.25.2</version>
<version>2.25.3</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -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();

View File

@ -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;
}

View File

@ -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;

View File

@ -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 " +

View File

@ -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 " +
" )");
}
}
}
}

View File

@ -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;

View File

@ -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
);

View File

@ -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());
}
}

View File

@ -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:");

View File

@ -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);