Skip to content

Commit

Permalink
Fix confirming when the server double-sends a window ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Feb 27, 2021
1 parent ab9501d commit f02105e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public void translate(ServerOpenWindowPacket packet, GeyserSession session) {

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);
Expand Down

0 comments on commit f02105e

Please sign in to comment.