diff --git a/pom.xml b/pom.xml index 303402a..a0f2c86 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.garsooon Auctioneer - 1.0.3 + 1.0.4 A simple chat based auction plugin for items in Beta 1.7.3 Minecraft with lots of settings for total control of its behavior. diff --git a/src/main/java/org/garsooon/AuctionManager.java b/src/main/java/org/garsooon/AuctionManager.java index 64a6c4e..b0604e7 100644 --- a/src/main/java/org/garsooon/AuctionManager.java +++ b/src/main/java/org/garsooon/AuctionManager.java @@ -103,7 +103,27 @@ public boolean startAuction(Player seller, ItemStack item, double price, String lastAuctionTime.put(seller.getUniqueId(), System.currentTimeMillis()); - Bukkit.broadcastMessage(ChatColor.GREEN + seller.getName() + " is auctioning " + ChatColor.YELLOW + item.getAmount() + "x " + getItemDisplayName(item) + ChatColor.GREEN + " starting at $" + startPrice); + //noinspection ExtractMethodRecommender + String durabilityInfo = ""; + short dur = item.getDurability(); + short maxDur = item.getType().getMaxDurability(); + + if (maxDur > 0) { + int remaining = maxDur - dur; + int pct = (int) ((remaining * 100.0) / maxDur); + + ChatColor durColor = ChatColor.GREEN; + if (pct <= 25) { + durColor = ChatColor.RED; + } else if (pct <= 50) { + durColor = ChatColor.GOLD; + } else if (pct <= 75) { + durColor = ChatColor.YELLOW; + } + durabilityInfo = durColor + " [" + remaining + "/" + maxDur + " durability]"; + } + + Bukkit.broadcastMessage(ChatColor.GREEN + seller.getName() + " is auctioning " + ChatColor.YELLOW + item.getAmount() + "x " + getItemDisplayName(item) + durabilityInfo + ChatColor.GREEN + " starting at $" + startPrice); if (percentBidIncrement > 0.0) { Bukkit.broadcastMessage(ChatColor.GRAY + "Minimum bid increase is set to " + percentBidIncrement + "%"); @@ -344,6 +364,10 @@ public double getCurrentBid() { return Math.floor(highestBid * 100) / 100.0; } + public ItemStack getCurrentItem() { + return currentItem; + } + public boolean isAuctionRunning() { return currentItem != null; } diff --git a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java index ffd7f55..0ca235f 100644 --- a/src/main/java/org/garsooon/Listener/PlayerJoinListener.java +++ b/src/main/java/org/garsooon/Listener/PlayerJoinListener.java @@ -28,6 +28,25 @@ public void onPlayerJoin(final PlayerJoinEvent event) { String sellerName = auctionManager.getCurrentSellerName(); double currentBid = auctionManager.getCurrentBid(); + @SuppressWarnings("unused") String durabilityInfo = ""; + org.bukkit.inventory.ItemStack item = auctionManager.getCurrentItem(); + short dur = item.getDurability(); + short maxDur = item.getType().getMaxDurability(); + if (maxDur > 0) { + int remaining = maxDur - dur; + int pct = (int) ((remaining * 100.0) / maxDur); + ChatColor durColor = ChatColor.GREEN; + if (pct <= 25) { + durColor = ChatColor.RED; + } else if (pct <= 50) { + durColor = ChatColor.GOLD; + } else if (pct <= 75) { + durColor = ChatColor.YELLOW; + } + //noinspection UnusedAssignment + durabilityInfo = durColor + " [" + remaining + "/" + maxDur + " durability]"; + } + 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)); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 71cb3bd..169a71b 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Auctioneer -version: 1.0.3 +version: 1.0.4 main: org.garsooon.AuctionPlugin softdepend: [Essentials, Fundamentals, ZCore, MultiCurrency, iCo4, iCo5, iCo6, BOSE6, BOSE7]