mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Send trade packet for every new viewer
This commit is contained in:
parent
c080750a88
commit
52d0ef7f53
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user