Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-28 00:50:20 +01:00
Add delay when reopening inventory
Dieser Commit ist enthalten in:
Ursprung
3812712a06
Commit
8ae803b9a5
@ -30,6 +30,7 @@ import com.nukkitx.protocol.bedrock.data.ContainerId;
|
|||||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||||
import com.nukkitx.protocol.bedrock.packet.ContainerClosePacket;
|
import com.nukkitx.protocol.bedrock.packet.ContainerClosePacket;
|
||||||
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
|
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
|
||||||
|
import org.geysermc.api.Geyser;
|
||||||
import org.geysermc.connector.inventory.Inventory;
|
import org.geysermc.connector.inventory.Inventory;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
@ -37,6 +38,7 @@ import org.geysermc.connector.network.translators.TranslatorsInit;
|
|||||||
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket> {
|
public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket> {
|
||||||
|
|
||||||
@ -53,6 +55,7 @@ public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket>
|
|||||||
cursorPacket.setSlot(ItemData.AIR);
|
cursorPacket.setSlot(ItemData.AIR);
|
||||||
session.getUpstream().sendPacket(cursorPacket);
|
session.getUpstream().sendPacket(cursorPacket);
|
||||||
|
|
||||||
|
Geyser.getGeneralThreadPool().schedule(() -> {
|
||||||
Inventory inventory = session.getInventoryCache().getOpenInventory();
|
Inventory inventory = session.getInventoryCache().getOpenInventory();
|
||||||
if (inventory != null) {
|
if (inventory != null) {
|
||||||
session.setReopeningWindow(inventory.getId());
|
session.setReopeningWindow(inventory.getId());
|
||||||
@ -60,8 +63,9 @@ public class JavaSetSlotTranslator extends PacketTranslator<ServerSetSlotPacket>
|
|||||||
inventory = session.getInventory();
|
inventory = session.getInventory();
|
||||||
}
|
}
|
||||||
ContainerClosePacket closePacket = new ContainerClosePacket();
|
ContainerClosePacket closePacket = new ContainerClosePacket();
|
||||||
closePacket.setWindowId((byte)inventory.getId());
|
closePacket.setWindowId((byte) inventory.getId());
|
||||||
session.getUpstream().sendPacket(closePacket);
|
session.getUpstream().sendPacket(closePacket);
|
||||||
|
}, 150, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getInventory().setCursor(packet.getItem());
|
session.getInventory().setCursor(packet.getItem());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren