Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.garsooon</groupId>
<artifactId>Auctioneer</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<description>A simple chat based auction plugin for items in Beta 1.7.3 Minecraft with lots of settings for total control of its behavior.</description>

<properties>
Expand Down
26 changes: 25 additions & 1 deletion src/main/java/org/garsooon/AuctionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "%");
Expand Down Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/garsooon/Listener/PlayerJoinListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down