diff --git a/src/main/java/org/garsooon/AuctionManager.java b/src/main/java/org/garsooon/AuctionManager.java index 9a162b0..2b666ba 100644 --- a/src/main/java/org/garsooon/AuctionManager.java +++ b/src/main/java/org/garsooon/AuctionManager.java @@ -357,12 +357,16 @@ public int getItemAmount() { return currentItem != null ? currentItem.getAmount() : 0; } - public String getCurrentSellerName() { - return currentSeller != null ? currentSeller.getName() : "Unknown"; + public Player getCurrentSeller() { return currentSeller; } + + public Player getCurrentHighestBidder() { return highestBidder; } + + public double getStartPrice() { + return roundDown2(highestBid); } public double getCurrentBid() { - return Math.floor(highestBid * 100) / 100.0; + return roundDown2(highestBid); } public ItemStack getCurrentItem() { @@ -373,6 +377,10 @@ public boolean isAuctionRunning() { return currentItem != null; } + public long getAuctionEndTime() { + return auctionEndTime; + } + // Handler and case returns for items with internal data values private String getItemDisplayName(ItemStack item) { int id = item.getTypeId(); diff --git a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java index 0ca235f..973bcfd 100644 --- a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java +++ b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; import org.garsooon.AuctionManager; @@ -25,11 +26,14 @@ public void onPlayerJoin(final PlayerJoinEvent event) { Player player = event.getPlayer(); String itemName = auctionManager.getCurrentItemDisplayName(); int itemAmount = auctionManager.getItemAmount(); - String sellerName = auctionManager.getCurrentSellerName(); + Player seller = auctionManager.getCurrentSeller(); + Player highestBidder = auctionManager.getCurrentHighestBidder(); + double startPrice = auctionManager.getStartPrice(); double currentBid = auctionManager.getCurrentBid(); + long auctionEndTime = auctionManager.getAuctionEndTime(); @SuppressWarnings("unused") String durabilityInfo = ""; - org.bukkit.inventory.ItemStack item = auctionManager.getCurrentItem(); + ItemStack item = auctionManager.getCurrentItem(); short dur = item.getDurability(); short maxDur = item.getType().getMaxDurability(); if (maxDur > 0) { @@ -48,8 +52,16 @@ public void onPlayerJoin(final PlayerJoinEvent event) { } player.sendMessage(ChatColor.GOLD + "An auction is currently running!"); - player.sendMessage(ChatColor.GREEN + sellerName + " is auctioning " + ChatColor.YELLOW + itemAmount + - "x " + itemName + ChatColor.GREEN + " starting at $" + String.format("%.2f", currentBid)); + player.sendMessage(ChatColor.GREEN + seller.getName() + " is auctioning " + ChatColor.YELLOW + itemAmount + + "x " + itemName + durabilityInfo + ChatColor.GREEN + " starting at $" + startPrice); + + if (highestBidder != null) { + player.sendMessage(ChatColor.AQUA + "Current highest bid is $" + currentBid + " by " + highestBidder.getName()); + } + + long timeLeft = (auctionEndTime - System.currentTimeMillis()) / 1000L; + player.sendMessage(ChatColor.GRAY + "Auction time remaining: " + timeLeft + " seconds"); + }, 1L); //Tick delay to stop showing above motd } }