Refactor auction system: consolidate controllers, add lang keys, remove categories

- Consolidate AuctionLogger and AuctionNotificationController into AuctionController
- Add inline logging and notification methods to AuctionController
- Add comprehensive LANG keys for all auction GUI strings
- Update EnumAuctionSort and EnumAuctionDuration to use lang keys
- Remove category filtering system (EnumAuctionCategory deleted)
- Update AuctionFilter to remove category references
- Update GuiAuction and all sub-GUIs to use StatCollector.translateToLocal()
- Update AuctionListing to remove category field and NBT serialization
This commit is contained in:
Claude committed 2026-01-04 10:26:56 +00:00
1 parent a1de79053b
commit 740c2852e5
15 files changed
+374 -1165

No files matched your search

@@ -3,17 +3,13 @@ package noppes.npcs.client.gui.player;
import kamkeel.npcs.network.packets.player.AuctionActionPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.config.ConfigMarket;
import noppes.npcs.constants.EnumAuctionCategory;
import noppes.npcs.constants.EnumAuctionSort;
import noppes.npcs.constants.EnumAuctionStatus;
import noppes.npcs.containers.ContainerAuction;
import noppes.npcs.controllers.data.AuctionFilter;
import noppes.npcs.controllers.data.AuctionListing;
@@ -26,13 +22,11 @@ import java.util.List;
/**
* Main auction house browse GUI.
* Displays listings with search, filter, sort, and pagination.
* Displays listings with search, sort, and pagination.
*/
public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
ICustomScrollListener, NoppesUtil.IAuctionData {
private static final ResourceLocation background = new ResourceLocation("customnpcs", "textures/gui/auction.png");
// GUI Components
private GuiNpcTextField searchField;
private GuiCustomScroll listingScroll;
@@ -56,7 +50,7 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
public GuiAuction(EntityNPCInterface npc, ContainerAuction container) {
super(npc, container);
this.title = "Auction House";
this.title = "";
this.xSize = 256;
this.ySize = 222;
this.closeOnEsc = true;
@@ -71,70 +65,50 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
super.initGui();
// Tab buttons at top
addTopButton(new GuiMenuTopButton(0, guiLeft + 4, guiTop - 17, "Browse"));
addTopButton(new GuiMenuTopButton(1, guiLeft + 54, guiTop - 17, "My Listings"));
addTopButton(new GuiMenuTopButton(2, guiLeft + 114, guiTop - 17, "My Bids"));
addTopButton(new GuiMenuTopButton(3, guiLeft + 164, guiTop - 17, "Claims"));
addTopButton(new GuiMenuTopButton(4, guiLeft + 214, guiTop - 17, "Sell"));
addTopButton(new GuiMenuTopButton(0, guiLeft + 4, guiTop - 17, StatCollector.translateToLocal("auction.browse")));
addTopButton(new GuiMenuTopButton(1, guiLeft + 54, guiTop - 17, StatCollector.translateToLocal("auction.myListings")));
addTopButton(new GuiMenuTopButton(2, guiLeft + 114, guiTop - 17, StatCollector.translateToLocal("auction.myBids")));
addTopButton(new GuiMenuTopButton(3, guiLeft + 164, guiTop - 17, StatCollector.translateToLocal("auction.claims")));
addTopButton(new GuiMenuTopButton(4, guiLeft + 214, guiTop - 17, StatCollector.translateToLocal("auction.sell")));
getTopButton(currentTab).setEnabled(false);
// Search field
searchField = new GuiNpcTextField(10, this, guiLeft + 8, guiTop + 6, 120, 14, currentFilter.searchText);
searchField = new GuiNpcTextField(10, this, guiLeft + 8, guiTop + 6, 140, 14, currentFilter.searchText);
searchField.setMaxStringLength(50);
addTextField(searchField);
// Search button
addButton(new GuiNpcButton(11, guiLeft + 130, guiTop + 5, 30, 16, "Search"));
addButton(new GuiNpcButton(11, guiLeft + 150, guiTop + 5, 40, 16, StatCollector.translateToLocal("auction.search")));
// Category buttons (simplified row)
String[] categories = {"All", "Weapons", "Armor", "Tools", "Potions", "Blocks", "Other"};
for (int i = 0; i < categories.length; i++) {
GuiNpcButton btn = new GuiNpcButton(20 + i, guiLeft + 8 + i * 35, guiTop + 24, 33, 14, categories[i]);
btn.setEnabled(currentFilter.category.ordinal() != getCategoryOrdinal(i));
addButton(btn);
}
// Sort dropdown button
addButton(new GuiNpcButton(30, guiLeft + 170, guiTop + 5, 78, 16, currentFilter.sortOrder.getDisplayName()));
// Sort button
addButton(new GuiNpcButton(30, guiLeft + 8, guiTop + 24, 120, 16, currentFilter.sortOrder.getDisplayName()));
// Listing scroll area
listingScroll = new GuiCustomScroll(this, 0);
listingScroll.guiLeft = guiLeft + 8;
listingScroll.guiTop = guiTop + 42;
listingScroll.setSize(160, 130);
listingScroll.guiTop = guiTop + 44;
listingScroll.setSize(160, 128);
addScroll(listingScroll);
updateListingDisplay();
// Pagination buttons
addButton(new GuiNpcButton(40, guiLeft + 8, guiTop + 176, 40, 16, "< Prev"));
addButton(new GuiNpcButton(40, guiLeft + 8, guiTop + 176, 40, 16, StatCollector.translateToLocal("auction.prevPage")));
addLabel(new GuiNpcLabel(41, getPageLabel(), guiLeft + 90, guiTop + 180, CustomNpcResourceListener.DefaultTextColor));
addButton(new GuiNpcButton(42, guiLeft + 128, guiTop + 176, 40, 16, "Next >"));
addButton(new GuiNpcButton(42, guiLeft + 128, guiTop + 176, 40, 16, StatCollector.translateToLocal("auction.nextPage")));
// Action buttons (right side)
addButton(new GuiNpcButton(50, guiLeft + 175, guiTop + 50, 73, 20, "View Details"));
addButton(new GuiNpcButton(51, guiLeft + 175, guiTop + 75, 73, 20, "Place Bid"));
addButton(new GuiNpcButton(52, guiLeft + 175, guiTop + 100, 73, 20, "Buyout"));
addButton(new GuiNpcButton(53, guiLeft + 175, guiTop + 125, 73, 20, "Refresh"));
addButton(new GuiNpcButton(50, guiLeft + 175, guiTop + 50, 73, 20, StatCollector.translateToLocal("auction.viewDetails")));
addButton(new GuiNpcButton(51, guiLeft + 175, guiTop + 75, 73, 20, StatCollector.translateToLocal("auction.placeBid")));
addButton(new GuiNpcButton(52, guiLeft + 175, guiTop + 100, 73, 20, StatCollector.translateToLocal("auction.buyout")));
addButton(new GuiNpcButton(53, guiLeft + 175, guiTop + 125, 73, 20, StatCollector.translateToLocal("auction.refresh")));
// Balance display
addLabel(new GuiNpcLabel(60, "Balance: " + formatCurrency(playerBalance),
addLabel(new GuiNpcLabel(60, String.format(StatCollector.translateToLocal("auction.balance"), formatCurrency(playerBalance)),
guiLeft + 175, guiTop + 155, 0x00AA00));
updateButtonStates();
}
private int getCategoryOrdinal(int buttonIndex) {
switch (buttonIndex) {
case 0: return EnumAuctionCategory.ALL.ordinal();
case 1: return EnumAuctionCategory.WEAPONS.ordinal();
case 2: return EnumAuctionCategory.ARMOR.ordinal();
case 3: return EnumAuctionCategory.TOOLS.ordinal();
case 4: return EnumAuctionCategory.POTIONS.ordinal();
case 5: return EnumAuctionCategory.BLOCKS.ordinal();
default: return EnumAuctionCategory.MISC.ordinal();
}
}
@Override
public void updateScreen() {
super.updateScreen();
@@ -160,10 +134,6 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
else if (id == 11) {
performSearch();
}
// Category buttons
else if (id >= 20 && id <= 26) {
setCategory(getCategoryOrdinal(id - 20));
}
// Sort button
else if (id == 30) {
cycleSortOrder();
@@ -218,14 +188,6 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
AuctionActionPacket.QueryListings(currentFilter);
}
private void setCategory(int categoryOrdinal) {
currentFilter.category = EnumAuctionCategory.values()[categoryOrdinal];
currentFilter.page = 0;
currentPage = 0;
AuctionActionPacket.QueryListings(currentFilter);
initGui();
}
private void cycleSortOrder() {
currentFilter.sortOrder = currentFilter.sortOrder.next();
currentFilter.page = 0;
@@ -321,7 +283,7 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
}
private String formatTimeRemaining(long millis) {
if (millis <= 0) return "Ended";
if (millis <= 0) return StatCollector.translateToLocal("auction.ended");
long seconds = millis / 1000;
long minutes = seconds / 60;
@@ -350,9 +312,9 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
private String getPageLabel() {
if (totalPages == 0) {
return "No results";
return StatCollector.translateToLocal("auction.noResults");
}
return "Page " + (currentPage + 1) + " of " + totalPages;
return String.format(StatCollector.translateToLocal("auction.page"), currentPage + 1, totalPages);
}
private void updateButtonStates() {
@@ -378,7 +340,7 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
drawDefaultBackground();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
// Draw background (using a standard size, can be customized)
// Draw background
mc.renderEngine.bindTexture(new ResourceLocation("customnpcs", "textures/gui/bgfilled.png"));
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
@@ -413,17 +375,18 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
CustomNpcResourceListener.DefaultTextColor);
// Results count
fontRendererObj.drawString(totalResults + " listings", 175, 42, 0x666666);
String listingsLabel = String.format(StatCollector.translateToLocal("auction.listings"), totalResults);
fontRendererObj.drawString(listingsLabel, 175, 42, 0x666666);
}
private String getTabTitle() {
switch (currentTab) {
case 0: return "Browse Auctions";
case 1: return "My Listings";
case 2: return "My Active Bids";
case 3: return "Claim Items";
case 4: return "Create Listing";
default: return "Auction House";
case 0: return StatCollector.translateToLocal("auction.browseTitle");
case 1: return StatCollector.translateToLocal("auction.myListingsTitle");
case 2: return StatCollector.translateToLocal("auction.myBidsTitle");
case 3: return StatCollector.translateToLocal("auction.claimsTitle");
case 4: return StatCollector.translateToLocal("auction.sellTitle");
default: return StatCollector.translateToLocal("auction.title");
}
}
@@ -443,13 +406,13 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
// Handled above
}
// IGuiData - Receive NBT data from server
// IGuiData
@Override
public void setGuiData(NBTTagCompound compound) {
// This can be used for initial setup data
}
// IAuctionData - Receive auction listing data
// IAuctionData
@Override
public void onAuctionDataReceived(int dataType, NBTTagCompound data,
int totalResults, int currentPage, int totalPages,
@@ -478,7 +441,7 @@ public class GuiAuction extends GuiContainerNPCInterface implements IGuiData,
getLabel(41).label = getPageLabel();
}
if (getLabel(60) != null) {
getLabel(60).label = "Balance: " + formatCurrency(playerBalance);
getLabel(60).label = String.format(StatCollector.translateToLocal("auction.balance"), formatCurrency(playerBalance));
}
}
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.player;
import kamkeel.npcs.network.packets.player.AuctionActionPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
@@ -35,39 +36,39 @@ public class SubGuiAuctionBid extends SubGuiInterface {
int labelColor = 0x404040;
// Title
addLabel(new GuiNpcLabel(0, "Place Bid", guiLeft + 70, y, labelColor));
addLabel(new GuiNpcLabel(0, StatCollector.translateToLocal("auction.placeBid"), guiLeft + 70, y, labelColor));
y += 18;
// Item name
addLabel(new GuiNpcLabel(1, "Item: " + listing.item.getDisplayName(), guiLeft + 15, y, 0x000000));
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("auction.item") + " " + listing.item.getDisplayName(), guiLeft + 15, y, 0x000000));
y += 14;
// Current price
long currentPrice = listing.currentBid > 0 ? listing.currentBid : listing.startingPrice;
addLabel(new GuiNpcLabel(2, "Current Price:", guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("auction.currentPrice"), guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(3, formatCurrency(currentPrice), guiLeft + 100, y, 0x008800));
y += 14;
// Minimum bid
long minBid = listing.getMinimumBid();
addLabel(new GuiNpcLabel(4, "Minimum Bid:", guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(4, StatCollector.translateToLocal("auction.minimumBid"), guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(5, formatCurrency(minBid), guiLeft + 100, y, 0x0066AA));
y += 14;
// Your balance
addLabel(new GuiNpcLabel(6, "Your Balance:", guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(6, StatCollector.translateToLocal("auction.yourBalance"), guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(7, formatCurrency(playerBalance), guiLeft + 100, y,
playerBalance >= minBid ? 0x008800 : 0xAA0000));
y += 14;
// Time remaining
addLabel(new GuiNpcLabel(8, "Time Left:", guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(8, StatCollector.translateToLocal("auction.timeLeft"), guiLeft + 15, y, labelColor));
addLabel(new GuiNpcLabel(9, formatTimeRemaining(listing.getTimeRemaining()), guiLeft + 100, y,
getTimeColor(listing.getTimeRemaining())));
y += 18;
// Bid input
addLabel(new GuiNpcLabel(10, "Your Bid:", guiLeft + 15, y + 3, labelColor));
addLabel(new GuiNpcLabel(10, StatCollector.translateToLocal("auction.yourBid"), guiLeft + 15, y + 3, labelColor));
bidField = new GuiNpcTextField(11, this, guiLeft + 80, y, 100, 16, String.valueOf(minBid));
bidField.setNumbersOnly();
bidField.setMinMaxDefault(minBid, 999999999, minBid);
@@ -75,24 +76,24 @@ public class SubGuiAuctionBid extends SubGuiInterface {
y += 24;
// Quick bid buttons
addButton(new GuiNpcButton(20, guiLeft + 15, y, 55, 16, "Min Bid"));
addButton(new GuiNpcButton(21, guiLeft + 73, y, 55, 16, "+10%"));
addButton(new GuiNpcButton(22, guiLeft + 131, y, 55, 16, "+25%"));
addButton(new GuiNpcButton(20, guiLeft + 15, y, 55, 16, StatCollector.translateToLocal("auction.minBid")));
addButton(new GuiNpcButton(21, guiLeft + 73, y, 55, 16, StatCollector.translateToLocal("auction.bidPlus10")));
addButton(new GuiNpcButton(22, guiLeft + 131, y, 55, 16, StatCollector.translateToLocal("auction.bidPlus25")));
y += 22;
// Place bid button
GuiNpcButton bidButton = new GuiNpcButton(30, guiLeft + 15, y, 80, 20, "Place Bid");
GuiNpcButton bidButton = new GuiNpcButton(30, guiLeft + 15, y, 80, 20, StatCollector.translateToLocal("auction.placeBid"));
bidButton.setEnabled(playerBalance >= minBid && listing.isActive());
addButton(bidButton);
// Cancel button
addButton(new GuiNpcButton(31, guiLeft + 105, y, 80, 20, "Cancel"));
addButton(new GuiNpcButton(31, guiLeft + 105, y, 80, 20, StatCollector.translateToLocal("gui.cancel")));
// Error message area
if (playerBalance < minBid) {
addLabel(new GuiNpcLabel(40, "Insufficient funds!", guiLeft + 50, guiTop + ySize - 15, 0xAA0000));
addLabel(new GuiNpcLabel(40, StatCollector.translateToLocal("auction.insufficientFunds"), guiLeft + 50, guiTop + ySize - 15, 0xAA0000));
} else if (!listing.isActive()) {
addLabel(new GuiNpcLabel(40, "Auction has ended!", guiLeft + 50, guiTop + ySize - 15, 0xAA0000));
addLabel(new GuiNpcLabel(40, StatCollector.translateToLocal("auction.auctionEnded"), guiLeft + 50, guiTop + ySize - 15, 0xAA0000));
}
}
@@ -101,7 +102,7 @@ public class SubGuiAuctionBid extends SubGuiInterface {
}
private String formatTimeRemaining(long millis) {
if (millis <= 0) return "Ended";
if (millis <= 0) return StatCollector.translateToLocal("auction.ended");
long seconds = millis / 1000;
long minutes = seconds / 60;
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.player;
import kamkeel.npcs.network.packets.player.AuctionActionPacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
@@ -21,8 +22,6 @@ public class SubGuiAuctionCreate extends SubGuiInterface {
private GuiNpcTextField buyoutPriceField;
private int selectedDuration = 1; // Default to MEDIUM
private static final String[] DURATION_NAMES = {"Short", "Medium", "Long", "Very Long"};
public SubGuiAuctionCreate(GuiAuction parent, ContainerAuction container) {
this.container = container;
setBackground("menubg.png");
@@ -36,54 +35,54 @@ public class SubGuiAuctionCreate extends SubGuiInterface {
super.initGui();
// Title
addLabel(new GuiNpcLabel(0, "Create Auction Listing", guiLeft + 50, guiTop + 8, 0x404040));
addLabel(new GuiNpcLabel(0, StatCollector.translateToLocal("auction.createListing"), guiLeft + 50, guiTop + 8, 0x404040));
// Item slot instructions
addLabel(new GuiNpcLabel(1, "Place item in slot below:", guiLeft + 20, guiTop + 28, 0x404040));
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("auction.placeItemBelow"), guiLeft + 20, guiTop + 28, 0x404040));
// Item info (shows when item is in slot)
ItemStack item = container.getListingItem();
if (item != null) {
addLabel(new GuiNpcLabel(2, "Item: " + item.getDisplayName(), guiLeft + 20, guiTop + 50, 0x008800));
addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("auction.item") + " " + item.getDisplayName(), guiLeft + 20, guiTop + 50, 0x008800));
} else {
addLabel(new GuiNpcLabel(2, "(No item selected)", guiLeft + 20, guiTop + 50, 0x888888));
addLabel(new GuiNpcLabel(2, StatCollector.translateToLocal("auction.noItemSelected"), guiLeft + 20, guiTop + 50, 0x888888));
}
// Starting price
addLabel(new GuiNpcLabel(10, "Starting Price:", guiLeft + 20, guiTop + 70, 0x404040));
addLabel(new GuiNpcLabel(10, StatCollector.translateToLocal("auction.startingPrice"), guiLeft + 20, guiTop + 70, 0x404040));
startingPriceField = new GuiNpcTextField(11, this, guiLeft + 100, guiTop + 68, 80, 14, "100");
startingPriceField.setNumbersOnly();
startingPriceField.setMinMaxDefault(1, 999999999, 100);
addTextField(startingPriceField);
// Buyout price (optional)
addLabel(new GuiNpcLabel(20, "Buyout Price:", guiLeft + 20, guiTop + 90, 0x404040));
addLabel(new GuiNpcLabel(20, StatCollector.translateToLocal("auction.buyoutPrice"), guiLeft + 20, guiTop + 90, 0x404040));
buyoutPriceField = new GuiNpcTextField(21, this, guiLeft + 100, guiTop + 88, 80, 14, "0");
buyoutPriceField.setNumbersOnly();
buyoutPriceField.setMinMaxDefault(0, 999999999, 0);
addTextField(buyoutPriceField);
addLabel(new GuiNpcLabel(22, "(0 = no buyout)", guiLeft + 185, guiTop + 90, 0x888888));
addLabel(new GuiNpcLabel(22, StatCollector.translateToLocal("auction.noBuyoutHint"), guiLeft + 185, guiTop + 90, 0x888888));
// Duration selection
addLabel(new GuiNpcLabel(30, "Duration:", guiLeft + 20, guiTop + 112, 0x404040));
addLabel(new GuiNpcLabel(30, StatCollector.translateToLocal("auction.duration"), guiLeft + 20, guiTop + 112, 0x404040));
addButton(new GuiNpcButton(31, guiLeft + 100, guiTop + 108, 100, 20, getDurationDisplay()));
// Fee display
long fee = getListingFee();
addLabel(new GuiNpcLabel(40, "Listing Fee: " + fee + " " + ConfigMarket.CurrencyName,
addLabel(new GuiNpcLabel(40, StatCollector.translateToLocal("auction.listingFee") + " " + fee + " " + ConfigMarket.CurrencyName,
guiLeft + 20, guiTop + 135, fee > 0 ? 0xAA0000 : 0x008800));
// Create button
addButton(new GuiNpcButton(50, guiLeft + 20, guiTop + 155, 80, 20, "Create Listing"));
addButton(new GuiNpcButton(50, guiLeft + 20, guiTop + 155, 80, 20, StatCollector.translateToLocal("auction.create")));
getButton(50).setEnabled(item != null);
// Cancel button
addButton(new GuiNpcButton(51, guiLeft + 120, guiTop + 155, 80, 20, "Cancel"));
addButton(new GuiNpcButton(51, guiLeft + 120, guiTop + 155, 80, 20, StatCollector.translateToLocal("gui.cancel")));
}
private String getDurationDisplay() {
EnumAuctionDuration duration = EnumAuctionDuration.values()[selectedDuration];
return DURATION_NAMES[selectedDuration] + " (" + duration.getHours() + "h)";
return duration.getDisplayName();
}
private long getListingFee() {
@@ -147,7 +146,7 @@ public class SubGuiAuctionCreate extends SubGuiInterface {
if (item != null) {
if (itemLabel != null) {
itemLabel.label = "Item: " + item.getDisplayName();
itemLabel.label = StatCollector.translateToLocal("auction.item") + " " + item.getDisplayName();
itemLabel.color = 0x008800;
}
if (createButton != null) {
@@ -155,7 +154,7 @@ public class SubGuiAuctionCreate extends SubGuiInterface {
}
} else {
if (itemLabel != null) {
itemLabel.label = "(No item selected)";
itemLabel.label = StatCollector.translateToLocal("auction.noItemSelected");
itemLabel.color = 0x888888;
}
if (createButton != null) {
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.player;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
@@ -34,70 +35,70 @@ public class SubGuiAuctionDetails extends SubGuiInterface {
int valueColor = 0x000000;
// Title
addLabel(new GuiNpcLabel(0, "Auction Details", guiLeft + 80, y, labelColor));
addLabel(new GuiNpcLabel(0, StatCollector.translateToLocal("auction.auctionDetails"), guiLeft + 80, y, labelColor));
y += 16;
// Item name
addLabel(new GuiNpcLabel(1, "Item:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(1, StatCollector.translateToLocal("auction.item"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(2, listing.item.getDisplayName(), guiLeft + 80, y, valueColor));
y += 14;
// Quantity
addLabel(new GuiNpcLabel(3, "Quantity:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(3, StatCollector.translateToLocal("auction.quantity"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(4, String.valueOf(listing.item.stackSize), guiLeft + 80, y, valueColor));
y += 14;
// Seller
addLabel(new GuiNpcLabel(5, "Seller:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(5, StatCollector.translateToLocal("auction.seller"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(6, listing.sellerName, guiLeft + 80, y, valueColor));
y += 14;
// Starting price
addLabel(new GuiNpcLabel(10, "Starting Price:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(10, StatCollector.translateToLocal("auction.startingPrice"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(11, formatCurrency(listing.startingPrice), guiLeft + 100, y, valueColor));
y += 14;
// Current bid
if (listing.currentBid > 0) {
addLabel(new GuiNpcLabel(12, "Current Bid:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(12, StatCollector.translateToLocal("auction.currentBid"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(13, formatCurrency(listing.currentBid), guiLeft + 100, y, 0x008800));
y += 14;
// High bidder
addLabel(new GuiNpcLabel(14, "High Bidder:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(14, StatCollector.translateToLocal("auction.highBidder"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(15, listing.highBidderName, guiLeft + 100, y, valueColor));
y += 14;
// Bid count
addLabel(new GuiNpcLabel(16, "Total Bids:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(16, StatCollector.translateToLocal("auction.totalBids"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(17, String.valueOf(listing.bidCount), guiLeft + 100, y, valueColor));
y += 14;
} else {
addLabel(new GuiNpcLabel(12, "Current Bid:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(13, "No bids yet", guiLeft + 100, y, 0x888888));
addLabel(new GuiNpcLabel(12, StatCollector.translateToLocal("auction.currentBid"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(13, StatCollector.translateToLocal("auction.noBidsYet"), guiLeft + 100, y, 0x888888));
y += 14;
}
// Buyout price
if (listing.buyoutPrice > 0) {
addLabel(new GuiNpcLabel(20, "Buyout Price:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(20, StatCollector.translateToLocal("auction.buyoutPrice"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(21, formatCurrency(listing.buyoutPrice), guiLeft + 100, y, 0xAA6600));
y += 14;
}
// Minimum bid
addLabel(new GuiNpcLabel(22, "Minimum Bid:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(22, StatCollector.translateToLocal("auction.minimumBid"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(23, formatCurrency(listing.getMinimumBid()), guiLeft + 100, y, 0x0066AA));
y += 14;
// Time remaining (will be updated)
addLabel(new GuiNpcLabel(30, "Time Left:", guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(30, StatCollector.translateToLocal("auction.timeLeft"), guiLeft + 20, y, labelColor));
addLabel(new GuiNpcLabel(31, formatTimeRemaining(listing.getTimeRemaining()), guiLeft + 100, y,
getTimeColor(listing.getTimeRemaining())));
y += 20;
// Close button
addButton(new GuiNpcButton(50, guiLeft + 80, guiTop + 175, 80, 20, "Close"));
addButton(new GuiNpcButton(50, guiLeft + 80, guiTop + 175, 80, 20, StatCollector.translateToLocal("gui.close")));
}
private String formatCurrency(long amount) {
@@ -105,7 +106,7 @@ public class SubGuiAuctionDetails extends SubGuiInterface {
}
private String formatTimeRemaining(long millis) {
if (millis <= 0) return "Auction Ended";
if (millis <= 0) return StatCollector.translateToLocal("auction.ended");
long seconds = millis / 1000;
long minutes = seconds / 60;