From e7f6177be89084345123db0a5d1810fc072c8c9a Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 4 Jan 2026 20:36:40 +0000 Subject: [PATCH] Add Auctioneer role to NPC GUI and connect auction system - Add Auctioneer to role dropdown in GuiNpcAdvanced - Create GuiNpcAuctioneer setup GUI for configuring: - Tab visibility (browse, my listings, my bids, claims) - Player actions (create, bid, buyout) - Custom welcome/disabled messages - Add PlayerAuction container handler in CommonProxy - Add PlayerAuction GUI handler in ClientProxy - Add all role.auctioneer lang keys to en_US.lang --- src/main/java/noppes/npcs/CommonProxy.java | 4 + .../java/noppes/npcs/client/ClientProxy.java | 5 + .../client/gui/mainmenu/GuiNpcAdvanced.java | 5 +- .../client/gui/roles/GuiNpcAuctioneer.java | 144 ++++++++++++++++++ .../assets/customnpcs/lang/en_US.lang | 13 ++ 5 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 src/main/java/noppes/npcs/client/gui/roles/GuiNpcAuctioneer.java diff --git a/src/main/java/noppes/npcs/CommonProxy.java b/src/main/java/noppes/npcs/CommonProxy.java index 58f931ab8..a73c179e4 100644 --- a/src/main/java/noppes/npcs/CommonProxy.java +++ b/src/main/java/noppes/npcs/CommonProxy.java @@ -15,6 +15,7 @@ import noppes.npcs.api.IWorld; import noppes.npcs.blocks.tiles.TileNpcContainer; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.containers.ContainerAnvilRepair; +import noppes.npcs.containers.ContainerAuction; import noppes.npcs.containers.ContainerCarpentryBench; import noppes.npcs.containers.ContainerCrate; import noppes.npcs.containers.ContainerCustomGui; @@ -131,6 +132,9 @@ public class CommonProxy implements IGuiHandler { if (gui == EnumGuiType.CompanionInv) return new ContainerNPCCompanion(npc, player); + if (gui == EnumGuiType.PlayerAuction) + return new ContainerAuction(npc, player); + return null; } diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 7cc3d7b76..cbe2d3da7 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -104,6 +104,7 @@ import noppes.npcs.client.gui.player.GuiCrate; import noppes.npcs.client.gui.player.GuiMailbox; import noppes.npcs.client.gui.player.GuiMailmanWrite; import noppes.npcs.client.gui.player.GuiNPCBankChest; +import noppes.npcs.client.gui.player.GuiAuction; import noppes.npcs.client.gui.player.GuiNPCTrader; import noppes.npcs.client.gui.player.GuiNpcAnvil; import noppes.npcs.client.gui.player.GuiNpcCarpentryBench; @@ -177,6 +178,7 @@ import noppes.npcs.config.ConfigMain; import noppes.npcs.config.StringCache; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.containers.ContainerAnvilRepair; +import noppes.npcs.containers.ContainerAuction; import noppes.npcs.containers.ContainerCarpentryBench; import noppes.npcs.containers.ContainerCrate; import noppes.npcs.containers.ContainerCustomGui; @@ -568,6 +570,9 @@ public class ClientProxy extends CommonProxy { else if (gui == EnumGuiType.MagicBook) return new GuiNpcMagicBook(); + else if (gui == EnumGuiType.PlayerAuction) + return new GuiAuction(npc, (ContainerAuction) container); + else if (gui == EnumGuiType.GlobalRemote) return new GuiNPCGlobalMainMenu(null); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java index 6452145a6..8c6248e40 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAdvanced.java @@ -25,6 +25,7 @@ import noppes.npcs.client.gui.roles.GuiNpcFollowerJob; import noppes.npcs.client.gui.roles.GuiNpcGuard; import noppes.npcs.client.gui.roles.GuiNpcHealer; import noppes.npcs.client.gui.roles.GuiNpcSpawner; +import noppes.npcs.client.gui.roles.GuiNpcAuctioneer; import noppes.npcs.client.gui.roles.GuiNpcMount; import noppes.npcs.client.gui.roles.GuiNpcTransporter; import noppes.npcs.client.gui.util.GuiNPCInterface2; @@ -48,7 +49,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData { super.initGui(); int y = guiTop + 10; this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit")); - this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)"), "role.mount"}, npc.advanced.role.ordinal())); + this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)"), "role.mount", "role.auctioneer"}, npc.advanced.role.ordinal())); getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman); this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit")); @@ -151,6 +152,8 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData { displayGuiScreen(new GuiNpcCompanion(npc)); else if (npc.advanced.role == EnumRoleType.Mount) displayGuiScreen(new GuiNpcMount(npc)); + else if (npc.advanced.role == EnumRoleType.Auctioneer) + displayGuiScreen(new GuiNpcAuctioneer(npc)); } else if (compound.hasKey("JobData")) { if (npc.jobInterface != null) npc.jobInterface.readFromNBT(compound); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcAuctioneer.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcAuctioneer.java new file mode 100644 index 000000000..d5fb8e962 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcAuctioneer.java @@ -0,0 +1,144 @@ +package noppes.npcs.client.gui.roles; + +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.request.role.RoleSavePacket; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.nbt.NBTTagCompound; +import noppes.npcs.client.gui.util.GuiNPCInterface2; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiNpcLabel; +import noppes.npcs.client.gui.util.GuiNpcTextField; +import noppes.npcs.client.gui.util.ITextfieldListener; +import noppes.npcs.entity.EntityNPCInterface; +import noppes.npcs.roles.RoleAuctioneer; + +public class GuiNpcAuctioneer extends GuiNPCInterface2 implements ITextfieldListener { + + private final RoleAuctioneer role; + + public GuiNpcAuctioneer(EntityNPCInterface npc) { + super(npc); + this.role = npc.roleInterface instanceof RoleAuctioneer ? (RoleAuctioneer) npc.roleInterface : null; + } + + @Override + public void initGui() { + super.initGui(); + if (role == null) { + close(); + return; + } + + int y = guiTop + 10; + + // Left column - Tab visibility + addLabel(new GuiNpcLabel(0, "role.auctioneer.tabs", guiLeft + 10, y, 0x404040)); + y += 18; + + addLabel(new GuiNpcLabel(1, "role.auctioneer.showBrowse", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(1, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.showActiveListings ? 1 : 0)); + y += 22; + + addLabel(new GuiNpcLabel(2, "role.auctioneer.showMyListings", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(2, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.showMyListings ? 1 : 0)); + y += 22; + + addLabel(new GuiNpcLabel(3, "role.auctioneer.showMyBids", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(3, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.showMyBids ? 1 : 0)); + y += 22; + + addLabel(new GuiNpcLabel(4, "role.auctioneer.showClaims", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(4, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.showClaims ? 1 : 0)); + y += 30; + + // Actions + addLabel(new GuiNpcLabel(10, "role.auctioneer.actions", guiLeft + 10, y, 0x404040)); + y += 18; + + addLabel(new GuiNpcLabel(11, "role.auctioneer.allowCreate", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(11, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.allowCreatingListings ? 1 : 0)); + y += 22; + + addLabel(new GuiNpcLabel(12, "role.auctioneer.allowBid", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(12, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.allowBidding ? 1 : 0)); + y += 22; + + addLabel(new GuiNpcLabel(13, "role.auctioneer.allowBuyout", guiLeft + 10, y + 5, 0x404040)); + addButton(new GuiNpcButton(13, guiLeft + 140, y, 50, 20, new String[]{"gui.no", "gui.yes"}, role.allowBuyout ? 1 : 0)); + + // Right column - Messages + int rightX = guiLeft + 210; + int rightY = guiTop + 10; + + addLabel(new GuiNpcLabel(20, "role.auctioneer.messages", rightX, rightY, 0x404040)); + rightY += 18; + + addLabel(new GuiNpcLabel(21, "role.auctioneer.welcome", rightX, rightY + 5, 0x404040)); + rightY += 18; + GuiNpcTextField welcomeField = new GuiNpcTextField(21, this, rightX, rightY, 180, 20, role.welcomeMessage); + welcomeField.setMaxStringLength(200); + addTextField(welcomeField); + rightY += 28; + + addLabel(new GuiNpcLabel(22, "role.auctioneer.noAuction", rightX, rightY + 5, 0x404040)); + rightY += 18; + GuiNpcTextField noAuctionField = new GuiNpcTextField(22, this, rightX, rightY, 180, 20, role.noAuctionMessage); + noAuctionField.setMaxStringLength(200); + addTextField(noAuctionField); + } + + @Override + public void buttonEvent(GuiButton guibutton) { + if (role == null) return; + + if (guibutton instanceof GuiNpcButton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + boolean value = button.getValue() == 1; + + switch (button.id) { + case 1: + role.showActiveListings = value; + break; + case 2: + role.showMyListings = value; + break; + case 3: + role.showMyBids = value; + break; + case 4: + role.showClaims = value; + break; + case 11: + role.allowCreatingListings = value; + break; + case 12: + role.allowBidding = value; + break; + case 13: + role.allowBuyout = value; + break; + } + } + } + + @Override + public void unFocused(GuiNpcTextField textfield) { + if (role == null) return; + + switch (textfield.id) { + case 21: + role.welcomeMessage = textfield.getText(); + break; + case 22: + role.noAuctionMessage = textfield.getText(); + break; + } + } + + @Override + public void save() { + if (role != null) { + PacketClient.sendClient(new RoleSavePacket(role.writeToNBT(new NBTTagCompound()))); + } + } +} diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index 88c10066c..efec9bd2f 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -429,6 +429,19 @@ role.mount.hover=Hover role.mount.ascendspeed=Ascend Speed role.mount.descendspeed=Descend Speed role.mount.walkspeed=Walk Speed: %s +role.auctioneer=Auctioneer +role.auctioneer.tabs=Tab Visibility +role.auctioneer.showBrowse=Show Browse +role.auctioneer.showMyListings=Show My Listings +role.auctioneer.showMyBids=Show My Bids +role.auctioneer.showClaims=Show Claims +role.auctioneer.actions=Player Actions +role.auctioneer.allowCreate=Allow Create +role.auctioneer.allowBid=Allow Bid +role.auctioneer.allowBuyout=Allow Buyout +role.auctioneer.messages=Messages +role.auctioneer.welcome=Welcome Message +role.auctioneer.noAuction=Auction Disabled Message trader.insufficient=Insufficient Currency trader.sufficient=Sufficient Currency