diff --git a/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/Storeable.java b/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/Storeable.java index 2e7e27f..41bc79d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/Storeable.java +++ b/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/Storeable.java @@ -18,9 +18,16 @@ package ca.tweetzy.auctionhouse.ahv3.api; +import org.jetbrains.annotations.Nullable; + import java.util.function.Consumer; public interface Storeable { void store(Consumer storedItem); + + default void unStore(@Nullable final Consumer syncResult) { + if (syncResult != null) + syncResult.accept(SynchronizeResult.SUCCESS); + } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/SynchronizeResult.java b/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/SynchronizeResult.java new file mode 100644 index 0000000..c6c564d --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/ahv3/api/SynchronizeResult.java @@ -0,0 +1,7 @@ +package ca.tweetzy.auctionhouse.ahv3.api; + +public enum SynchronizeResult { + + SUCCESS, + FAILURE +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/AuctionStatistic.java b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/AuctionStatistic.java new file mode 100644 index 0000000..cc212f5 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/AuctionStatistic.java @@ -0,0 +1,72 @@ +/* + * Auction House + * Copyright 2023 Kiran Hart + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package ca.tweetzy.auctionhouse.ahv3.impl; + +import ca.tweetzy.auctionhouse.ahv3.api.auction.Statistic; +import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType; +import lombok.AllArgsConstructor; +import lombok.NonNull; + +import java.util.UUID; +import java.util.function.Consumer; + +@AllArgsConstructor +public final class AuctionStatistic implements Statistic { + + private final UUID id; + private final AuctionStatisticType type; + private final UUID owner; + private final double value; + private final long createdAt; + + @Override + public @NonNull UUID getId() { + return this.id; + } + + @Override + public @NonNull AuctionStatisticType getType() { + return this.type; + } + + @Override + public @NonNull UUID getOwner() { + return this.owner; + } + + @Override + public double getValue() { + return this.value; + } + + @Override + public long getTimeCreated() { + return this.createdAt; + } + + @Override + public long getLastUpdated() { + return this.getTimeCreated(); + } + + @Override + public void store(Consumer stored) { + + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionListing.java b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionListing.java new file mode 100644 index 0000000..a8a1c05 --- /dev/null +++ b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionListing.java @@ -0,0 +1,76 @@ +/* + * Auction House + * Copyright 2023 Kiran Hart + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package ca.tweetzy.auctionhouse.ahv3.impl.auction; + +import ca.tweetzy.auctionhouse.ahv3.api.ListingType; +import ca.tweetzy.auctionhouse.ahv3.api.auction.Bid; +import ca.tweetzy.auctionhouse.ahv3.api.auction.Biddable; +import lombok.NonNull; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.math.BigDecimal; +import java.util.List; +import java.util.UUID; + +public final class AuctionListing extends BinListing implements Biddable { + + private final BigDecimal startingBid; + private final List bids; + + public AuctionListing( + @NonNull UUID uuid, + @NonNull UUID ownerUUID, + @NonNull String ownerName, + @NonNull ItemStack item, + @NonNull BigDecimal startingBid, + @NonNull BigDecimal binPrice, + @NonNull String listedWorld, + @NonNull String listedServer, + @NonNull List bids, + long listedAt, + long expiresAt + ) { + super(ListingType.AUCTION, uuid, ownerUUID, ownerName, item, binPrice, listedWorld, listedServer, listedAt, expiresAt); + this.startingBid = startingBid; + this.bids = bids; + } + + public AuctionListing( + @NonNull Player player, + @NonNull ItemStack item, + @NonNull BigDecimal startingBid, + @NonNull final BigDecimal binPrice, + @NonNull List bids + ) { + super(ListingType.AUCTION, player, item, binPrice); + this.startingBid = startingBid; + this.bids = bids; + } + + @Override + public BigDecimal getStartingPrice() { + return this.startingBid; + } + + @Override + public List getBids() { + return this.bids; + } +} diff --git a/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/BinAuctionItem.java b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/BinListing.java similarity index 84% rename from src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/BinAuctionItem.java rename to src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/BinListing.java index 2596058..547290c 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/BinAuctionItem.java +++ b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/BinListing.java @@ -27,7 +27,7 @@ import java.math.BigDecimal; import java.util.UUID; import java.util.function.Consumer; -public final class BinAuctionItem extends AuctionItem { +public class BinListing extends AuctionItem { private final UUID uuid; private final UUID ownerUUID; @@ -41,7 +41,8 @@ public final class BinAuctionItem extends AuctionItem { private final long listedAt; private long expiresAt; - public BinAuctionItem( + public BinListing( + @NonNull final ListingType listingType, @NonNull final UUID uuid, @NonNull final UUID ownerUUID, @NonNull final String ownerName, @@ -52,7 +53,7 @@ public final class BinAuctionItem extends AuctionItem { final long listedAt, final long expiresAt ) { - super(item, ListingType.BIN); + super(item, listingType); this.uuid = uuid; this.ownerUUID = ownerUUID; this.ownerName = ownerName; @@ -63,8 +64,13 @@ public final class BinAuctionItem extends AuctionItem { this.expiresAt = expiresAt; } - public BinAuctionItem(@NonNull final Player player, @NonNull final ItemStack item, @NonNull final BigDecimal price) { - this(UUID.randomUUID(), player.getUniqueId(), player.getName(), item, price, player.getWorld().getName(), player.getServer().getName(), System.currentTimeMillis(), System.currentTimeMillis() + 1000 * 60 * 60); + public BinListing( + @NonNull final ListingType listingType, + @NonNull final Player player, + @NonNull final ItemStack item, + @NonNull final BigDecimal price + ) { + this(listingType, UUID.randomUUID(), player.getUniqueId(), player.getName(), item, price, player.getWorld().getName(), player.getServer().getName(), System.currentTimeMillis(), System.currentTimeMillis() + 1000 * 60 * 60); } @NonNull