🚀 priority listing data columns

Took 13 seconds
This commit is contained in:
Kiran Hart 2024-08-19 12:15:23 -04:00
parent af89cbc2be
commit 22dc21ebbb
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 34 additions and 1 deletions

View File

@ -76,6 +76,10 @@ public class AuctionedItem {
private boolean isRequest = false;
private int requestAmount = 0;
// priority listing
private boolean hasListingPriority = false;
private long priorityExpiresAt = 0;
public AuctionedItem() {
}
@ -137,7 +141,6 @@ public class AuctionedItem {
return requested;
}
public ItemStack getBidStack(Player player) {
QuickItem itemStack = QuickItem.of(this.item.clone());
itemStack.amount(Math.max(this.item.getAmount(), 1));
@ -304,4 +307,8 @@ public class AuctionedItem {
public boolean containsValidBid() {
return isBidItem() && !this.highestBidder.equals(this.owner);
}
public boolean isListingPriorityActive() {
return this.hasListingPriority && this.priorityExpiresAt > System.currentTimeMillis();
}
}

View File

@ -424,6 +424,10 @@ public class DataManager extends DataManagerAbstract {
auctionItem.setRequest(resultSet.getBoolean("is_request"));
auctionItem.setRequestAmount(resultSet.getInt("request_count"));
auctionItem.setHasListingPriority(resultSet.getBoolean("listing_priority"));
auctionItem.setPriorityExpiresAt(resultSet.getLong("priority_expires_at"));
return auctionItem;
}

View File

@ -0,0 +1,22 @@
package ca.tweetzy.auctionhouse.database.migrations;
import ca.tweetzy.flight.database.DataMigration;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
public final class _28_PriorityListingMigration extends DataMigration {
public _28_PriorityListingMigration() {
super(28);
}
@Override
public void migrate(Connection connection, String tablePrefix) throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD listing_priority BOOLEAN default 0");
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD priority_expires_at BigInt default 0");
}
}
}