all items can be partially purchased (non bid ones with a stack size greater than 1 by default), players can provide -e or -entirestack to the sell command to negate that

Took 10 minutes
This commit is contained in:
Kiran Hart 2022-05-17 12:34:06 -04:00
parent 698c43aeda
commit 25a2c6fb87
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
9 changed files with 51 additions and 7 deletions

View File

@ -185,7 +185,8 @@ public class AuctionHouse extends TweetyPlugin {
new _10_InfiniteItemsMigration(),
new _11_AdminLogMigration(),
new _12_SerializeFormatDropMigration(),
new _13_MinItemPriceMigration()
new _13_MinItemPriceMigration(),
new _14_PartialQtyBuyMigration()
);
dataMigrationManager.runMigrations();

View File

@ -622,7 +622,7 @@ public class AuctionAPI {
}
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) {
listAuction(seller, original, item, seconds, basePrice, bidStartPrice, bidIncPrice, currentPrice, isBiddingItem, isUsingBundle, requiresHandRemove, false);
listAuction(seller, original, item, seconds, basePrice, bidStartPrice, bidIncPrice, currentPrice, isBiddingItem, isUsingBundle, requiresHandRemove, false, true);
}
/**
@ -639,7 +639,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, boolean requiresHandRemove, boolean isInfinite) {
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, boolean isInfinite, boolean allowPartialBuy) {
if (McMMOHook.isUsingAbility(seller)) {
AuctionHouse.getInstance().getLocale().getMessage("general.mcmmo_ability_active").sendPrefixedMessage(seller);
return;
@ -679,6 +679,7 @@ public class AuctionAPI {
auctionedItem.setListedWorld(seller.getWorld().getName());
auctionedItem.setInfinite(isInfinite);
auctionedItem.setAllowPartialBuy(allowPartialBuy);
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
if (!EconomyManager.hasBalance(seller, calculateListingFee(basePrice))) {

View File

@ -52,6 +52,7 @@ public class AuctionedItem {
private String listedWorld = null;
private boolean infinite = false;
private boolean allowPartialBuy = false;
public AuctionedItem() {
}

View File

@ -141,7 +141,7 @@ public final class CommandSell extends AbstractCommand {
boolean isBundle = false;
boolean isInfinite = false;
boolean isStackPrice = false;
boolean noPartialBuy = false;
for (int i = 0; i < args.length; i++) {
if (NumberUtils.isDouble(args[i])) {
@ -156,6 +156,9 @@ public final class CommandSell extends AbstractCommand {
if (args[i].equalsIgnoreCase("-b") || args[i].equalsIgnoreCase("-bundle"))
isBundle = true;
if (args[i].equalsIgnoreCase("-e") || args[i].equalsIgnoreCase("-entirestack"))
noPartialBuy = true;
if (player.hasPermission("auctionhouse.cmdflag.stack") && args[i].equalsIgnoreCase("-s") || args[i].equalsIgnoreCase("-stack"))
isStackPrice = true;
@ -298,7 +301,8 @@ public final class CommandSell extends AbstractCommand {
isBiddingItem || !buyNowAllow,
isBundle,
true,
isInfinite
isInfinite,
!noPartialBuy
);
}

View File

@ -295,7 +295,7 @@ public class DataManager extends DataManagerAbstract {
public void insertAuction(AuctionedItem item, Callback<AuctionedItem> callback) {
this.databaseConnector.connect(connection -> {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + this.getTablePrefix() + "auctions(id, owner, highest_bidder, owner_name, highest_bidder_name, category, base_price, bid_start_price, bid_increment_price, current_price, expired, expires_at, item_material, item_name, item_lore, item_enchants, item, listed_world, infinite) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
try (PreparedStatement statement = connection.prepareStatement("INSERT INTO " + this.getTablePrefix() + "auctions(id, owner, highest_bidder, owner_name, highest_bidder_name, category, base_price, bid_start_price, bid_increment_price, current_price, expired, expires_at, item_material, item_name, item_lore, item_enchants, item, listed_world, infinite, allow_partial_buys) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) {
PreparedStatement fetch = connection.prepareStatement("SELECT * FROM " + this.getTablePrefix() + "auctions WHERE id = ?");
fetch.setString(1, item.getId().toString());
@ -318,6 +318,7 @@ public class DataManager extends DataManagerAbstract {
statement.setString(17, AuctionAPI.encodeItem(item.getItem()));
statement.setString(18, item.getListedWorld());
statement.setBoolean(19, item.isInfinite());
statement.setBoolean(20, item.isAllowPartialBuy());
statement.executeUpdate();
if (callback != null) {
@ -548,6 +549,7 @@ public class DataManager extends DataManagerAbstract {
auctionItem.setListedWorld(resultSet.getString("listed_world"));
auctionItem.setInfinite(hasColumn(resultSet, "infinite") && resultSet.getBoolean("infinite"));
auctionItem.setAllowPartialBuy(hasColumn(resultSet, "allow_partial_buys") && resultSet.getBoolean("allow_partial_buys"));
return auctionItem;
}

View File

@ -0,0 +1,28 @@
package ca.tweetzy.auctionhouse.database.migrations;
import ca.tweetzy.core.database.DataMigration;
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 _14_PartialQtyBuyMigration extends DataMigration {
public _14_PartialQtyBuyMigration() {
super(14);
}
@Override
public void migrate(Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD allow_partial_buys BOOLEAN NULL");
}
}
}

View File

@ -370,6 +370,11 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
}
if (e.clickType == ClickType.valueOf(Settings.CLICKS_NON_BID_ITEM_QTY_PURCHASE.getString().toUpperCase())) {
if (!auctionItem.isAllowPartialBuy()) {
AuctionHouse.getInstance().getLocale().getMessage("general.qtybuydisabled").processPlaceholder("item_owner", auctionItem.getOwnerName()).sendPrefixedMessage(e.player);
return;
}
handleNonBidItem(auctionItem, e, true);
return;
}

View File

@ -79,7 +79,8 @@ public class GUIConfirmListing extends AbstractPlaceholderGui {
this.isBiddingItem,
this.isBundle,
this.requiresHandRemove,
this.isInfinite
this.isInfinite,
!this.isBiddingItem
);
e.gui.close();
});

View File

@ -64,6 +64,7 @@ public class LocaleSettings {
languageNodes.put("general.transaction delete begin", "&cBeginning transaction deletion, this may take some time.");
languageNodes.put("general.min price already added", "&cThere is already a minimum price set, please delete the existing one first.");
languageNodes.put("general.added min price", "&aSuccessfully set minimum price for %item% &ato &2$%price%");
languageNodes.put("general.qtybuydisabled", "&4%item_owner%&c is only accepting purchases of the entire stack.");
languageNodes.put("pricing.minbaseprice", "&cThe minimum base price must be &a$%price%");