3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-20 06:50:09 +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.data.*;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap; 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.longs.Long2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap; import it.unimi.dsi.fastutil.objects.Object2LongMap;
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
@ -107,7 +108,7 @@ public class GeyserSession implements CommandSender {
private TeleportCache teleportCache; private TeleportCache teleportCache;
@Getter @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. * A map of Vector3i positions to Java entity IDs.

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.connector.network.translators.bedrock; package org.geysermc.connector.network.translators.bedrock;
import com.nukkitx.protocol.bedrock.packet.ClientboundMapItemDataPacket;
import com.nukkitx.protocol.bedrock.packet.MapInfoRequestPacket; import com.nukkitx.protocol.bedrock.packet.MapInfoRequestPacket;
import org.geysermc.connector.GeyserConnector; import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
@ -39,16 +40,14 @@ public class BedrockMapInfoRequestTranslator extends PacketTranslator<MapInfoReq
@Override @Override
public void translate(MapInfoRequestPacket packet, GeyserSession session) { public void translate(MapInfoRequestPacket packet, GeyserSession session) {
long mapID = packet.getUniqueMapId(); long mapID = packet.getUniqueMapId();
if (mapID <= -1l) {
mapID = 0l;
}
if (session.getStoredMaps().containsKey(mapID)) { if (session.getStoredMaps().containsKey(mapID)) {
// Delay the packet 100ms to prevent the client from ignoring the packet // Delay the packet 100ms to prevent the client from ignoring the packet
long finalMapID = mapID;
GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> { GeyserConnector.getInstance().getGeneralThreadPool().schedule(() -> {
session.sendUpstreamPacket(session.getStoredMaps().get(finalMapID)); ClientboundMapItemDataPacket mapPacket = session.getStoredMaps().remove(mapID);
session.getStoredMaps().remove(finalMapID); if (mapPacket != null) {
session.sendUpstreamPacket(mapPacket);
}
}, 100, TimeUnit.MILLISECONDS); }, 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 // Store the map to send when the client requests it, as bedrock expects the data after a MapInfoRequestPacket
if (shouldStore) { if (shouldStore) {
long uniqueMapId = mapItemDataPacket.getUniqueMapId(); session.getStoredMaps().put(mapItemDataPacket.getUniqueMapId(), mapItemDataPacket);
if (uniqueMapId <= -1l) {
uniqueMapId = 0l;
}
session.getStoredMaps().put(uniqueMapId, mapItemDataPacket);
} }
// Send anyway just in case // Send anyway just in case