diff --git a/src/main/java/net/minestom/server/inventory/type/VillagerInventory.java b/src/main/java/net/minestom/server/inventory/type/VillagerInventory.java index 91790d0c5..e7a521376 100644 --- a/src/main/java/net/minestom/server/inventory/type/VillagerInventory.java +++ b/src/main/java/net/minestom/server/inventory/type/VillagerInventory.java @@ -1,9 +1,11 @@ package net.minestom.server.inventory.type; +import net.minestom.server.entity.Player; import net.minestom.server.inventory.Inventory; import net.minestom.server.inventory.InventoryType; import net.minestom.server.network.packet.server.play.TradeListPacket; import net.minestom.server.utils.ArrayUtils; +import org.jetbrains.annotations.NotNull; public class VillagerInventory extends Inventory { @@ -79,6 +81,15 @@ public class VillagerInventory extends Inventory { sendPacketToViewers(tradeListPacket); // Refresh window } + @Override + public boolean addViewer(@NotNull Player player) { + final boolean result = super.addViewer(player); + if (result) { + player.getPlayerConnection().sendPacket(tradeListPacket); + } + return result; + } + private void setupPacket() { this.tradeListPacket = new TradeListPacket(); this.tradeListPacket.windowId = getWindowId();