mirror of
https://github.com/kiranhart/Auction-House.git
synced 2024-11-22 05:25:11 +01:00
commit to move to new branch
Took 9 minutes
This commit is contained in:
parent
044a21a537
commit
0d441601ac
@ -18,9 +18,16 @@
|
||||
|
||||
package ca.tweetzy.auctionhouse.ahv3.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface Storeable<T> {
|
||||
|
||||
void store(Consumer<T> storedItem);
|
||||
|
||||
default void unStore(@Nullable final Consumer<SynchronizeResult> syncResult) {
|
||||
if (syncResult != null)
|
||||
syncResult.accept(SynchronizeResult.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package ca.tweetzy.auctionhouse.ahv3.api;
|
||||
|
||||
public enum SynchronizeResult {
|
||||
|
||||
SUCCESS,
|
||||
FAILURE
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Statistic> stored) {
|
||||
|
||||
}
|
||||
}
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<Bid> 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<Bid> 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<Bid> bids
|
||||
) {
|
||||
super(ListingType.AUCTION, player, item, binPrice);
|
||||
this.startingBid = startingBid;
|
||||
this.bids = bids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getStartingPrice() {
|
||||
return this.startingBid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Bid> getBids() {
|
||||
return this.bids;
|
||||
}
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue
Block a user