From 7859bd66029ace355f598ddbcc9d51e9bc4f4a3a Mon Sep 17 00:00:00 2001 From: svgaming234 Date: Tue, 2 Dec 2025 14:49:26 +0100 Subject: [PATCH 1/3] make join message more descriptive, fix inconsistent rounding --- .../java/org/garsooon/AuctionManager.java | 15 ++++++++--- .../garsooon/Listener/PlayerJoinListener.java | 26 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/garsooon/AuctionManager.java b/src/main/java/org/garsooon/AuctionManager.java index b0604e7..e7b876e 100644 --- a/src/main/java/org/garsooon/AuctionManager.java +++ b/src/main/java/org/garsooon/AuctionManager.java @@ -84,6 +84,7 @@ public boolean startAuction(Player seller, ItemStack item, double price, String parseIncrement(incrementArg); currentSeller = seller; + // currentItem defines if auctions are started within isAuctionRunning() currentItem = item; startPrice = roundDown2(price); @@ -356,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() { @@ -372,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..0772810 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) { @@ -37,9 +41,9 @@ public void onPlayerJoin(final PlayerJoinEvent event) { int pct = (int) ((remaining * 100.0) / maxDur); ChatColor durColor = ChatColor.GREEN; if (pct <= 25) { - durColor = ChatColor.RED; - } else if (pct <= 50) { - durColor = ChatColor.GOLD; +// durColor = ChatColor.RED; +// } else if (pct <= 50) { +// durColor = ChatColor.GOLD; } else if (pct <= 75) { durColor = ChatColor.YELLOW; } @@ -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 + 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 } } From 60e04d616f6aa51026da9f042d06678d7682de53 Mon Sep 17 00:00:00 2001 From: svgaming234 Date: Tue, 2 Dec 2025 19:30:51 +0100 Subject: [PATCH 2/3] add durability to view --- .../java/org/garsooon/Listener/PlayerJoinListener.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java index 0772810..3e7c0e7 100644 --- a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java +++ b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java @@ -41,9 +41,9 @@ public void onPlayerJoin(final PlayerJoinEvent event) { int pct = (int) ((remaining * 100.0) / maxDur); ChatColor durColor = ChatColor.GREEN; if (pct <= 25) { -// durColor = ChatColor.RED; -// } else if (pct <= 50) { -// durColor = ChatColor.GOLD; + durColor = ChatColor.RED; + } else if (pct <= 50) { + durColor = ChatColor.GOLD; } else if (pct <= 75) { durColor = ChatColor.YELLOW; } @@ -53,7 +53,7 @@ public void onPlayerJoin(final PlayerJoinEvent event) { player.sendMessage(ChatColor.GOLD + "An auction is currently running!"); player.sendMessage(ChatColor.GREEN + seller.getName() + " is auctioning " + ChatColor.YELLOW + itemAmount + - "x " + itemName + ChatColor.GREEN + " starting at $" + startPrice); + "x " + itemName + ChatColor.GREEN + durabilityInfo + " starting at $" + startPrice); if (highestBidder != null) { player.sendMessage(ChatColor.AQUA + "Current highest bid is $" + currentBid + " by " + highestBidder.getName()); From 9245af239931d5ad1aee872a902f0b7e09743bc8 Mon Sep 17 00:00:00 2001 From: svgaming234 Date: Tue, 2 Dec 2025 19:33:22 +0100 Subject: [PATCH 3/3] fix color code --- src/main/java/org/garsooon/Listener/PlayerJoinListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java index 3e7c0e7..973bcfd 100644 --- a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java +++ b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java @@ -53,7 +53,7 @@ public void onPlayerJoin(final PlayerJoinEvent event) { player.sendMessage(ChatColor.GOLD + "An auction is currently running!"); player.sendMessage(ChatColor.GREEN + seller.getName() + " is auctioning " + ChatColor.YELLOW + itemAmount + - "x " + itemName + ChatColor.GREEN + durabilityInfo + " starting at $" + startPrice); + "x " + itemName + durabilityInfo + ChatColor.GREEN + " starting at $" + startPrice); if (highestBidder != null) { player.sendMessage(ChatColor.AQUA + "Current highest bid is $" + currentBid + " by " + highestBidder.getName());