Fix confirming when the server double-sends a window ID

This commit is contained in:
Camotoy 2021-02-26 20:19:14 -05:00
parent ab9501da69
commit f02105e9c7
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 6 additions and 2 deletions

View file

@ -36,6 +36,9 @@ public class JavaCloseWindowTranslator extends PacketTranslator<ServerCloseWindo
@Override
public void translate(ServerCloseWindowPacket packet, GeyserSession session) {
session.addInventoryTask(() -> InventoryUtils.closeInventory(session, packet.getWindowId(), (session.getOpenInventory() != null && session.getOpenInventory().getId() == packet.getWindowId())));
session.addInventoryTask(() ->
// Sometimes the server can request a window close of ID 0... when the window isn't even open
// Don't confirm in this instance
InventoryUtils.closeInventory(session, packet.getWindowId(), (session.getOpenInventory() != null && session.getOpenInventory().getId() == packet.getWindowId())));
}
}

View file

@ -63,7 +63,8 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
Inventory newInventory = newTranslator.createInventory(name, packet.getWindowId(), packet.getType(), session.getPlayerInventory());
if (openInventory != null) {
InventoryUtils.closeInventory(session, openInventory.getId(), true);
// Sometimes the server can double-open an inventory with the same ID - don't confirm in that instance.
InventoryUtils.closeInventory(session, openInventory.getId(), openInventory.getId() != packet.getWindowId());
}
session.setInventoryTranslator(newTranslator);