Large Auction Cleanup + Auction Events

- Auction Enums
- Better Notification Handling
- Auction Cancelation Events
- Lang Key Cleanup
This commit is contained in:
Kam committed 2026-02-18 04:55:03 -05:00
1 parent 0512588a7a
commit 4510b3bbd1
31 files changed
+889 -578

No files matched your search

@@ -6,11 +6,13 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.constants.EnumClaimType;
import noppes.npcs.controllers.AuctionController;
import noppes.npcs.constants.EnumTradeSlotType;
import noppes.npcs.controllers.data.AuctionClaim;
import noppes.npcs.controllers.data.AuctionListing;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@@ -34,7 +36,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
private int maxTradeSlots = 8; // Player's max trade slots (permission-aware, synced from server)
// Slot type tracking for proper accessor methods
private int[] slotTypes = new int[SLOT_COUNT]; // 0=empty, 1=selling, 2=bidding, 3=claim
private EnumTradeSlotType[] slotTypes = new EnumTradeSlotType[SLOT_COUNT];
private int[] slotDataIndex = new int[SLOT_COUNT]; // Index into respective list
public ContainerAuctionTrades(EntityNPCInterface npc, EntityPlayer player) {
@@ -117,8 +119,8 @@ public class ContainerAuctionTrades extends ContainerAuction {
displayInventory.clear();
// Reset slot tracking
Arrays.fill(slotTypes, EnumTradeSlotType.EMPTY);
for (int i = 0; i < SLOT_COUNT; i++) {
slotTypes[i] = 0;
slotDataIndex[i] = -1;
}
}
@@ -156,7 +158,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
if (slot >= SLOT_COUNT) break;
claims.add(claim);
displayInventory.setClaimItem(slot, claim);
slotTypes[slot] = 3; // claim
slotTypes[slot] = EnumTradeSlotType.CLAIM;
slotDataIndex[slot] = claims.size() - 1;
slot++;
}
@@ -166,7 +168,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
if (slot >= SLOT_COUNT) break;
claims.add(claim);
displayInventory.setClaimItem(slot, claim);
slotTypes[slot] = 3; // claim
slotTypes[slot] = EnumTradeSlotType.CLAIM;
slotDataIndex[slot] = claims.size() - 1;
slot++;
}
@@ -176,7 +178,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
if (slot >= SLOT_COUNT) break;
claims.add(claim);
displayInventory.setClaimItem(slot, claim);
slotTypes[slot] = 3; // claim
slotTypes[slot] = EnumTradeSlotType.CLAIM;
slotDataIndex[slot] = claims.size() - 1;
slot++;
}
@@ -186,7 +188,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
for (AuctionListing listing : activeListings) {
if (slot >= SLOT_COUNT) break;
if (listing.item != null) displayInventory.setInventorySlotContents(slot, listing.item.copy());
slotTypes[slot] = 1; // selling
slotTypes[slot] = EnumTradeSlotType.SELLING;
slotDataIndex[slot] = listingIdx;
slot++;
listingIdx++;
@@ -197,7 +199,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
for (AuctionListing bid : activeBids) {
if (slot >= SLOT_COUNT) break;
if (bid.item != null) displayInventory.setInventorySlotContents(slot, bid.item.copy());
slotTypes[slot] = 2; // bidding
slotTypes[slot] = EnumTradeSlotType.BIDDING;
slotDataIndex[slot] = bidIdx;
slot++;
bidIdx++;
@@ -208,7 +210,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
if (slot >= SLOT_COUNT) break;
claims.add(claim);
displayInventory.setClaimItem(slot, claim);
slotTypes[slot] = 3; // claim
slotTypes[slot] = EnumTradeSlotType.CLAIM;
slotDataIndex[slot] = claims.size() - 1;
slot++;
}
@@ -219,13 +221,13 @@ public class ContainerAuctionTrades extends ContainerAuction {
/** Get listing at slot (or null if claim/empty) */
public AuctionListing getListingAt(int slot) {
if (slot < 0 || slot >= SLOT_COUNT) return null;
int type = slotTypes[slot];
EnumTradeSlotType type = slotTypes[slot];
int idx = slotDataIndex[slot];
if (idx < 0) return null;
if (type == 1 && idx < activeListings.size()) {
if (type == EnumTradeSlotType.SELLING && idx < activeListings.size()) {
return activeListings.get(idx);
} else if (type == 2 && idx < activeBids.size()) {
} else if (type == EnumTradeSlotType.BIDDING && idx < activeBids.size()) {
return activeBids.get(idx);
}
return null;
@@ -234,7 +236,7 @@ public class ContainerAuctionTrades extends ContainerAuction {
/** Get claim at slot (or null if listing/empty) */
public AuctionClaim getClaimAt(int slot) {
if (slot < 0 || slot >= SLOT_COUNT) return null;
if (slotTypes[slot] == 3) {
if (slotTypes[slot] == EnumTradeSlotType.CLAIM) {
int idx = slotDataIndex[slot];
if (idx >= 0 && idx < claims.size()) {
return claims.get(idx);
@@ -245,12 +247,12 @@ public class ContainerAuctionTrades extends ContainerAuction {
/** Check if slot is player's active listing */
public boolean isSellingAt(int slot) {
return slot >= 0 && slot < SLOT_COUNT && slotTypes[slot] == 1;
return slot >= 0 && slot < SLOT_COUNT && slotTypes[slot] == EnumTradeSlotType.SELLING;
}
/** Check if slot is player's active bid */
public boolean isBiddingAt(int slot) {
return slot >= 0 && slot < SLOT_COUNT && slotTypes[slot] == 2;
return slot >= 0 && slot < SLOT_COUNT && slotTypes[slot] == EnumTradeSlotType.BIDDING;
}
/** Find listing matching item (searches both selling and bidding) */
@@ -324,23 +326,23 @@ public class ContainerAuctionTrades extends ContainerAuction {
private void restoreSlotItem(int slot) {
if (slot < 0 || slot >= SLOT_COUNT) return;
int type = slotTypes[slot];
EnumTradeSlotType type = slotTypes[slot];
int idx = slotDataIndex[slot];
if (idx < 0) return;
if (type == 1 && idx < activeListings.size()) {
if (type == EnumTradeSlotType.SELLING && idx < activeListings.size()) {
// Selling
AuctionListing listing = activeListings.get(idx);
if (listing != null && listing.item != null) {
displayInventory.setInventorySlotContents(slot, listing.item.copy());
}
} else if (type == 2 && idx < activeBids.size()) {
} else if (type == EnumTradeSlotType.BIDDING && idx < activeBids.size()) {
// Bidding
AuctionListing bid = activeBids.get(idx);
if (bid != null && bid.item != null) {
displayInventory.setInventorySlotContents(slot, bid.item.copy());
}
} else if (type == 3 && idx < claims.size()) {
} else if (type == EnumTradeSlotType.CLAIM && idx < claims.size()) {
// Claim
displayInventory.setClaimItem(slot, claims.get(idx));
}