Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 00:00:41 +01:00
Fix maps with negative IDs causing out of bounds errors
Dieser Commit ist enthalten in:
Ursprung
ba736575f7
Commit
c454e443df
@ -39,12 +39,16 @@ 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(mapID));
|
session.sendUpstreamPacket(session.getStoredMaps().get(finalMapID));
|
||||||
session.getStoredMaps().remove(mapID);
|
session.getStoredMaps().remove(finalMapID);
|
||||||
}, 100, TimeUnit.MILLISECONDS);
|
}, 100, TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,11 @@ 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) {
|
||||||
session.getStoredMaps().put(mapItemDataPacket.getUniqueMapId(), mapItemDataPacket);
|
long uniqueMapId = mapItemDataPacket.getUniqueMapId();
|
||||||
|
if (uniqueMapId <= -1l) {
|
||||||
|
uniqueMapId = 0l;
|
||||||
|
}
|
||||||
|
session.getStoredMaps().put(uniqueMapId, mapItemDataPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send anyway just in case
|
// Send anyway just in case
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren