Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-27 08:30:12 +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);
|
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId);
|
||||||
session.getDownstream().getSession().send(closeWindowPacket);
|
session.getDownstream().getSession().send(closeWindowPacket);
|
||||||
InventoryUtils.closeInventory(session, windowId);
|
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();
|
Inventory openInventory = session.getInventoryCache().getOpenInventory();
|
||||||
if (newTranslator == null) {
|
if (newTranslator == null) {
|
||||||
if (openInventory != null) {
|
if (openInventory != null) {
|
||||||
ContainerClosePacket closePacket = new ContainerClosePacket();
|
InventoryUtils.closeWindow(session, openInventory.getId());
|
||||||
closePacket.setWindowId((byte)openInventory.getId());
|
InventoryUtils.closeInventory(session, openInventory.getId());
|
||||||
session.sendUpstreamPacket(closePacket);
|
|
||||||
InventoryTranslator.INVENTORY_TRANSLATORS.get(openInventory.getWindowType()).closeInventory(session, openInventory);
|
|
||||||
}
|
}
|
||||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(packet.getWindowId());
|
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(packet.getWindowId());
|
||||||
session.sendDownstreamPacket(closeWindowPacket);
|
session.sendDownstreamPacket(closeWindowPacket);
|
||||||
@ -80,10 +78,6 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
|
|||||||
if (!openTranslator.getClass().equals(newTranslator.getClass())) {
|
if (!openTranslator.getClass().equals(newTranslator.getClass())) {
|
||||||
InventoryUtils.closeWindow(session, openInventory.getId());
|
InventoryUtils.closeWindow(session, openInventory.getId());
|
||||||
InventoryUtils.closeInventory(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) {
|
if (translator != null) {
|
||||||
session.getInventoryCache().setOpenInventory(inventory);
|
session.getInventoryCache().setOpenInventory(inventory);
|
||||||
translator.prepareInventory(session, 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
|
//TODO: find better way to handle double chest delay
|
||||||
if (translator instanceof DoubleChestInventoryTranslator) {
|
if (translator instanceof DoubleChestInventoryTranslator) {
|
||||||
|
delay = Math.max(delay, 200);
|
||||||
|
}
|
||||||
|
if (delay > 0) {
|
||||||
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
|
||||||
translator.openInventory(session, inventory);
|
translator.openInventory(session, inventory);
|
||||||
translator.updateInventory(session, inventory);
|
translator.updateInventory(session, inventory);
|
||||||
}, 200, TimeUnit.MILLISECONDS);
|
}, delay, TimeUnit.MILLISECONDS);
|
||||||
} else {
|
} else {
|
||||||
translator.openInventory(session, inventory);
|
translator.openInventory(session, inventory);
|
||||||
translator.updateInventory(session, inventory);
|
translator.updateInventory(session, inventory);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren