Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Add minimum delay between closing and opening a new window (#735)
Should fix new windows not showing up with some plugins like Lottery.
Dieser Commit ist enthalten in:
Ursprung
69a4cd3860
Commit
1d8995efe6
@ -53,8 +53,6 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId);
|
||||
session.getDownstream().getSession().send(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, windowId);
|
||||
} else if (openInventory != null && openInventory.getId() != windowId) {
|
||||
InventoryUtils.openInventory(session, openInventory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,10 +50,8 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
|
||||
Inventory openInventory = session.getInventoryCache().getOpenInventory();
|
||||
if (newTranslator == null) {
|
||||
if (openInventory != null) {
|
||||
ContainerClosePacket closePacket = new ContainerClosePacket();
|
||||
closePacket.setWindowId((byte)openInventory.getId());
|
||||
session.sendUpstreamPacket(closePacket);
|
||||
InventoryTranslator.INVENTORY_TRANSLATORS.get(openInventory.getWindowType()).closeInventory(session, openInventory);
|
||||
InventoryUtils.closeWindow(session, openInventory.getId());
|
||||
InventoryUtils.closeInventory(session, openInventory.getId());
|
||||
}
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(packet.getWindowId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
@ -80,10 +78,6 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
|
||||
if (!openTranslator.getClass().equals(newTranslator.getClass())) {
|
||||
InventoryUtils.closeWindow(session, openInventory.getId());
|
||||
InventoryUtils.closeInventory(session, openInventory.getId());
|
||||
session.getInventoryCache().setOpenInventory(newInventory);
|
||||
//The new window will be opened when the bedrock client sends the
|
||||
//window close confirmation in BedrockContainerCloseTranslator
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,18 @@ public class InventoryUtils {
|
||||
if (translator != null) {
|
||||
session.getInventoryCache().setOpenInventory(inventory);
|
||||
translator.prepareInventory(session, inventory);
|
||||
//Ensure at least half a second passes between closing and opening a new window
|
||||
//The client will not open the new window if it is still closing the old one
|
||||
long delay = 500 - (System.currentTimeMillis() - session.getLastWindowCloseTime());
|
||||
//TODO: find better way to handle double chest delay
|
||||
if (translator instanceof DoubleChestInventoryTranslator) {
|
||||
delay = Math.max(delay, 200);
|
||||
}
|
||||
if (delay > 0) {
|
||||
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
||||
translator.openInventory(session, inventory);
|
||||
translator.updateInventory(session, inventory);
|
||||
}, 200, TimeUnit.MILLISECONDS);
|
||||
}, delay, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
translator.openInventory(session, inventory);
|
||||
translator.updateInventory(session, inventory);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren