3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 23:30:17 +01:00

Fix closing the inventory from the server

Dieser Commit ist enthalten in:
Camotoy 2021-02-25 18:17:43 -05:00
Ursprung 0727008881
Commit e1db626529
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F
2 geänderte Dateien mit 10 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -36,6 +36,6 @@ public class JavaCloseWindowTranslator extends PacketTranslator<ServerCloseWindo
@Override
public void translate(ServerCloseWindowPacket packet, GeyserSession session) {
session.addInventoryTask(() -> InventoryUtils.closeInventory(session, packet.getWindowId(), true));
session.addInventoryTask(() -> InventoryUtils.closeInventory(session, packet.getWindowId(), (session.getOpenInventory() != null && session.getOpenInventory().getId() == packet.getWindowId())));
}
}

Datei anzeigen

@ -39,7 +39,10 @@ import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
import com.nukkitx.protocol.bedrock.packet.PlayerHotbarPacket;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.common.ChatColor;
import org.geysermc.connector.inventory.*;
import org.geysermc.connector.inventory.Container;
import org.geysermc.connector.inventory.GeyserItemStack;
import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.inventory.PlayerInventory;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
import org.geysermc.connector.network.translators.inventory.translators.LecternInventoryTranslator;
@ -70,19 +73,21 @@ public class InventoryUtils {
if (translator != null) {
translator.prepareInventory(session, inventory);
if (translator instanceof DoubleChestInventoryTranslator && !((Container) inventory).isUsingRealBlock()) {
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() ->
session.addInventoryTask(() -> {
Inventory openInv = session.getOpenInventory();
if (openInv != null && openInv.getId() == inventory.getId()) {
translator.openInventory(session, inventory);
translator.updateInventory(session, inventory);
}
});
}, 200, TimeUnit.MILLISECONDS);
}), 200, TimeUnit.MILLISECONDS);
} else {
translator.openInventory(session, inventory);
translator.updateInventory(session, inventory);
}
} else {
// Precaution - as of 1.16 every inventory should be translated so this shouldn't happen
session.setOpenInventory(null);
}
}