diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java index d2d1099..235aa1a 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandExpired.java @@ -19,16 +19,19 @@ import java.util.List; */ public class CommandExpired extends AbstractCommand { + final AuctionHouse instance; + + public CommandExpired() { super(CommandType.PLAYER_ONLY, "expired"); + instance = AuctionHouse.getInstance(); } @Override protected ReturnType runCommand(CommandSender sender, String... args) { final Player player = (Player) sender; if (CommandMiddleware.handle(player) == ReturnType.FAILURE) return ReturnType.FAILURE; - - final AuctionHouse instance = AuctionHouse.getInstance(); + if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) == null) { instance.getLocale().newMessage(TextUtils.formatText("&cCould not find auction player instance for&f: &e" + player.getName() + "&c creating one now.")).sendPrefixedMessage(Bukkit.getConsoleSender()); instance.getAuctionPlayerManager().addPlayer(new AuctionPlayer(player)); diff --git a/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java b/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java index bdcd5b6..c529b6d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java +++ b/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java @@ -12,6 +12,7 @@ import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.enums.AuctionStatisticType; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.transaction.Transaction; +import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -30,7 +31,7 @@ public class AuctionListeners implements Listener { public void onAuctionStart(AuctionStartEvent e) { // new stat system final Player seller = e.getSeller(); - final AuctionedItem auctionedItem = e.getAuctionedItem(); + final AuctionedItem auctionedItem = e.getAuctionItem(); new AuctionStatistic(seller.getUniqueId(), auctionedItem.isBidItem() ? AuctionStatisticType.CREATED_AUCTION : AuctionStatisticType.CREATED_BIN, 1).store(null); if (Settings.DISCORD_ENABLED.getBoolean() && Settings.DISCORD_ALERT_ON_AUCTION_START.getBoolean()) { @@ -54,9 +55,9 @@ public class AuctionListeners implements Listener { @EventHandler public void onAuctionEnd(AuctionEndEvent e) { // new stat system - final Player originalOwner = e.getOriginalOwner(), buyer = e.getBuyer(); + final OfflinePlayer originalOwner = e.getOriginalOwner(), buyer = e.getBuyer(); final UUID originalOwnerUUID = originalOwner.getUniqueId(), buyerUUID = buyer.getUniqueId(); - final AuctionedItem auctionedItem = e.getAuctionedItem(); + final AuctionedItem auctionedItem = e.getAuctionItem(); new AuctionStatistic(originalOwnerUUID, auctionedItem.isBidItem() ? AuctionStatisticType.SOLD_AUCTION : AuctionStatisticType.SOLD_BIN, 1).store(null); new AuctionStatistic(originalOwnerUUID, AuctionStatisticType.MONEY_EARNED, e.getSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM ? auctionedItem.getCurrentPrice() : auctionedItem.getBasePrice()).store(null); new AuctionStatistic(buyerUUID, AuctionStatisticType.MONEY_SPENT, e.getSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM ? auctionedItem.getCurrentPrice() : auctionedItem.getBasePrice()).store(null); diff --git a/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionStatisticManager.java b/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionStatisticManager.java index 61d8715..b9da634 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionStatisticManager.java +++ b/src/main/java/ca/tweetzy/auctionhouse/managers/AuctionStatisticManager.java @@ -47,7 +47,8 @@ public final class AuctionStatisticManager { this.statistics.add(statistic); final UUID owner = statistic.getStatOwner(); - final double value = value; + final double value = statistic.getValue(); + switch (statistic.getStatisticType()) { case CREATED_AUCTION: this.createdAuctionCount.put(owner, this.createdAuctionCount.getOrDefault(owner, 0D) + value);