3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-25 15:50:14 +01:00

Fix bug with maps

Dieser Commit ist enthalten in:
AJ Ferguson 2020-07-06 15:52:38 -08:00
Ursprung 02905c2a35
Commit 699402e635
3 geänderte Dateien mit 8 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -48,6 +48,7 @@ import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.*;
import com.nukkitx.protocol.bedrock.packet.*;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
@ -107,7 +108,7 @@ public class GeyserSession implements CommandSender {
private TeleportCache teleportCache;
@Getter
private final Long2ObjectMap<ClientboundMapItemDataPacket> storedMaps = new Long2ObjectOpenHashMap<>();
private final Long2ObjectMap<ClientboundMapItemDataPacket> storedMaps = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>());
/**
* A map of Vector3i positions to Java entity IDs.

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.connector.network.translators.bedrock;
import com.nukkitx.protocol.bedrock.packet.ClientboundMapItemDataPacket;
import com.nukkitx.protocol.bedrock.packet.MapInfoRequestPacket;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
@ -39,16 +40,14 @@ public class BedrockMapInfoRequestTranslator extends PacketTranslator<MapInfoReq
@Override
public void translate(MapInfoRequestPacket packet, GeyserSession session) {
long mapID = packet.getUniqueMapId();
if (mapID <= -1l) {
mapID = 0l;
}
if (session.getStoredMaps().containsKey(mapID)) {
// Delay the packet 100ms to prevent the client from ignoring the packet
long finalMapID = mapID;
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
session.sendUpstreamPacket(session.getStoredMaps().get(finalMapID));
session.getStoredMaps().remove(finalMapID);
ClientboundMapItemDataPacket mapPacket = session.getStoredMaps().remove(mapID);
if (mapPacket != null) {
session.sendUpstreamPacket(mapPacket);
}
}, 100, TimeUnit.MILLISECONDS);
}
}

Datei anzeigen

@ -85,11 +85,7 @@ public class JavaMapDataTranslator extends PacketTranslator<ServerMapDataPacket>
// Store the map to send when the client requests it, as bedrock expects the data after a MapInfoRequestPacket
if (shouldStore) {
long uniqueMapId = mapItemDataPacket.getUniqueMapId();
if (uniqueMapId <= -1l) {
uniqueMapId = 0l;
}
session.getStoredMaps().put(uniqueMapId, mapItemDataPacket);
session.getStoredMaps().put(mapItemDataPacket.getUniqueMapId(), mapItemDataPacket);
}
// Send anyway just in case