mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-21 05:15:11 +01:00
✨ create classes for new events, add ListingBuilder for new bin/auction system
Took 17 minutes
This commit is contained in:
parent
f792b82a59
commit
309af4bd02
@ -181,8 +181,11 @@ public class AuctionHouse extends TweetyPlugin {
|
||||
new _20_AuctionRequestsMigration(),
|
||||
new _21_RequestsDynAmtMigration(),
|
||||
new _22_BansV2Migration(),
|
||||
// ================ BEGIN MAJOR CHANGES ================ //
|
||||
new _23_ItemToNBTSerializationMigration(),
|
||||
new _24_RemainingItemToNBTSerializationMigration()
|
||||
new _24_RemainingItemToNBTSerializationMigration(),
|
||||
new _25_BidHistoryMigration(),
|
||||
new _26_MultiSerAndCurrencyMigration()
|
||||
);
|
||||
|
||||
dataMigrationManager.runMigrations();
|
||||
|
@ -5,6 +5,6 @@ public enum CategoryConditionType {
|
||||
MATERIAL,
|
||||
NAME,
|
||||
LORE,
|
||||
ENCHANTMENT;
|
||||
|
||||
ENCHANTMENT,
|
||||
MODEL_DATA;
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionAdminEvent {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionBidEvent {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionListingEndEvent {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionListingStartEvent {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionPlayerBanEvent {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionPreListingStartEvent {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package ca.tweetzy.auctionhouse.api.event;
|
||||
|
||||
public final class AuctionProfileUpdateEvent {
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
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 _25_BidHistoryMigration extends DataMigration {
|
||||
|
||||
public _25_BidHistoryMigration() {
|
||||
super(25);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "bids (" +
|
||||
"id VARCHAR(36) NOT NULL PRIMARY KEY, " +
|
||||
"listing_id VARCHAR(36) NOT NULL, " +
|
||||
"bidder_uuid VARCHAR(36) NOT NULL, " +
|
||||
"bidder_name VARCHAR(16) NOT NULL, " +
|
||||
"currency TEXT NOT NULL DEFAULT 'Vault/Vault'," +
|
||||
"currency_item TEXT NULL," +
|
||||
"amount TEXT NOT NULL, " +
|
||||
"world TEXT NOT NULL, " +
|
||||
"server BOOLEAN NOT NULL, " +
|
||||
"created_at BigInt NOT NULL )");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
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 _26_MultiSerAndCurrencyMigration extends DataMigration {
|
||||
|
||||
public _26_MultiSerAndCurrencyMigration() {
|
||||
super(26);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD currency TEXT NOT NULL DEFAULT 'Vault/Vault' ");
|
||||
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD currency_item TEXT NULL");
|
||||
statement.execute("ALTER TABLE " + tablePrefix + "auctions ADD listed_server TEXT NULL");
|
||||
}
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ public final class AuctionListing extends BinListing implements Biddable {
|
||||
}
|
||||
|
||||
public UUID getHighestBidderUUID() {
|
||||
return highestBidderUUID;
|
||||
return this.highestBidderUUID;
|
||||
}
|
||||
|
||||
public void setHighestBidderUUID(@NonNull final UUID highestBidderUUID) {
|
||||
@ -92,7 +92,7 @@ public final class AuctionListing extends BinListing implements Biddable {
|
||||
}
|
||||
|
||||
public String getHighestBidderName() {
|
||||
return highestBidderName;
|
||||
return this.highestBidderName;
|
||||
}
|
||||
|
||||
public void setHighestBidderName(@NonNull String highestBidderName) {
|
||||
|
163
src/main/java/ca/tweetzy/auctionhouse/model/ListingBuilder.java
Normal file
163
src/main/java/ca/tweetzy/auctionhouse/model/ListingBuilder.java
Normal file
@ -0,0 +1,163 @@
|
||||
package ca.tweetzy.auctionhouse.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import ca.tweetzy.auctionhouse.api.auction.Bid;
|
||||
import ca.tweetzy.auctionhouse.api.auction.ListingType;
|
||||
import ca.tweetzy.auctionhouse.impl.listing.AuctionListing;
|
||||
import ca.tweetzy.auctionhouse.impl.listing.BinListing;
|
||||
import ca.tweetzy.flight.comp.enums.CompMaterial;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ListingBuilder {
|
||||
|
||||
// Common fields
|
||||
private UUID uuid;
|
||||
private UUID ownerUUID;
|
||||
private String ownerName;
|
||||
private ItemStack item;
|
||||
private String currency;
|
||||
private ItemStack currencyItem;
|
||||
private double binPrice;
|
||||
private String listedWorld;
|
||||
private String listedServer;
|
||||
private long listedAt;
|
||||
private long expiresAt;
|
||||
|
||||
// Auction-specific fields
|
||||
private double startingBid;
|
||||
private UUID highestBidderUUID;
|
||||
private String highestBidderName;
|
||||
private List<Bid> bids;
|
||||
private boolean isAuction;
|
||||
|
||||
public static ListingBuilder auction(@NonNull final Player player, @NonNull final ItemStack item) {
|
||||
return of(player, item, ListingType.AUCTION);
|
||||
}
|
||||
|
||||
public static ListingBuilder bin(@NonNull final Player player, @NonNull final ItemStack item) {
|
||||
return of(player, item, ListingType.BIN);
|
||||
}
|
||||
|
||||
public static ListingBuilder of(Player player, ItemStack item, ListingType listingType) {
|
||||
ListingBuilder builder = new ListingBuilder();
|
||||
builder.setOwner(player);
|
||||
builder.setItem(item);
|
||||
builder.setListedWorld(player.getWorld().getName());
|
||||
builder.setListedServer(player.getServer().getName());
|
||||
|
||||
if (listingType == ListingType.AUCTION) {
|
||||
builder.isAuction = true;
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
public ListingBuilder() {
|
||||
// Initialize default values
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.currency = "Vault/Vault";
|
||||
this.currencyItem = CompMaterial.AIR.parseItem();
|
||||
this.listedAt = System.currentTimeMillis();
|
||||
this.expiresAt = this.listedAt + 1000 * 60 * 60; // Default to 1 hour
|
||||
this.bids = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ListingBuilder setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setOwner(UUID ownerUUID, String ownerName) {
|
||||
this.ownerUUID = ownerUUID;
|
||||
this.ownerName = ownerName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setOwner(Player player) {
|
||||
this.ownerUUID = player.getUniqueId();
|
||||
this.ownerName = player.getName();
|
||||
this.listedWorld = player.getWorld().getName();
|
||||
this.listedServer = player.getServer().getName();
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setItem(ItemStack item) {
|
||||
this.item = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setCurrencyItem(ItemStack currencyItem) {
|
||||
this.currencyItem = currencyItem;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setBinPrice(double binPrice) {
|
||||
this.binPrice = binPrice;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setListedWorld(String listedWorld) {
|
||||
this.listedWorld = listedWorld;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setListedServer(String listedServer) {
|
||||
this.listedServer = listedServer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setListedAt(long listedAt) {
|
||||
this.listedAt = listedAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setExpiresAt(long expiresAt) {
|
||||
this.expiresAt = expiresAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setAuction() {
|
||||
this.isAuction = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setStartingBid(double startingBid) {
|
||||
this.startingBid = startingBid;
|
||||
this.isAuction = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setHighestBidder(UUID highestBidderUUID, String highestBidderName) {
|
||||
this.highestBidderUUID = highestBidderUUID;
|
||||
this.highestBidderName = highestBidderName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ListingBuilder setBids(List<Bid> bids) {
|
||||
this.bids = bids;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AuctionListing buildAuctionListing() {
|
||||
if (!isAuction) {
|
||||
throw new IllegalStateException("This builder is not configured for an auction listing.");
|
||||
}
|
||||
return new AuctionListing(uuid, ownerUUID, ownerName, item, currency, currencyItem, startingBid, binPrice, listedWorld, listedServer, highestBidderUUID, highestBidderName, bids, listedAt, expiresAt);
|
||||
}
|
||||
|
||||
public BinListing buildBinListing() {
|
||||
if (isAuction) {
|
||||
throw new IllegalStateException("This builder is configured for an auction listing.");
|
||||
}
|
||||
return new BinListing(ListingType.BIN, uuid, ownerUUID, ownerName, item, currency, currencyItem, binPrice, listedWorld, listedServer, listedAt, expiresAt);
|
||||
}
|
||||
}
|
@ -232,7 +232,7 @@ public class Settings {
|
||||
public static final ConfigSetting SEARCH_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.search", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting SELF_FILTER_ENABLED = new ConfigSetting(config, "auction setting.enabled filters.self", true, "Should this filter be enabled?");
|
||||
public static final ConfigSetting USE_AUCTION_CHEST_MODE = new ConfigSetting(config, "auction setting.use auction chest mode", false, "Enabling this will make it so players can only access the auction through the auction chest");
|
||||
public static final ConfigSetting AUTO_BSTATS = new ConfigSetting(config, "auction setting.auto bstats", true, "Auto enable bStats");
|
||||
public static final ConfigSetting AUTO_BSTATS = new ConfigSetting(config, "auction setting.use bstats", true, "Auto enable bStats");
|
||||
public static final ConfigSetting FORCE_MATERIAL_NAMES_FOR_DISCORD = new ConfigSetting(config, "auction setting.force material names for discord", false, "If true, auction house will use the actual material name rather than custom name");
|
||||
|
||||
public static final ConfigSetting ALLOW_ITEM_BUNDLES = new ConfigSetting(config, "auction setting.bundles.enabled", true, "If true, players can use -b in the sell command to bundle all similar items into a single item.");
|
||||
|
Loading…
Reference in New Issue
Block a user