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
14 changes: 11 additions & 3 deletions src/main/java/org/garsooon/AuctionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/org/garsooon/Listener/PlayerJoinListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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) {
Expand All @@ -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
}
}
Loading