3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-07-29 16:48:09 +02:00

Clear chunk on dimension switch

This should resolve chunks being leftover in instances such as server switches in proxies.
Dieser Commit ist enthalten in:
Camotoy 2021-08-30 15:12:17 -04:00 committet von SupremeMortal
Ursprung b9541505af
Commit ab2f5b326f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: DDBB25F8EE4FA29A
3 geänderte Dateien mit 26 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -67,7 +67,7 @@ public class ChunkCache {
chunks.put(chunkPosition, geyserColumn); chunks.put(chunkPosition, geyserColumn);
} }
public GeyserColumn getChunk(int chunkX, int chunkZ) { public GeyserColumn getChunk(int chunkX, int chunkZ) {
long chunkPosition = MathUtils.chunkPositionToLong(chunkX, chunkZ); long chunkPosition = MathUtils.chunkPositionToLong(chunkX, chunkZ);
return chunks.getOrDefault(chunkPosition, null); return chunks.getOrDefault(chunkPosition, null);
} }
@ -136,6 +136,19 @@ public class ChunkCache {
chunks.remove(chunkPosition); chunks.remove(chunkPosition);
} }
/**
* Manually clears all entries in the chunk cache.
* The server is responsible for clearing chunk entries if out of render distance (for example) or switching dimensions,
* but it is the client that must clear chunks in the event of proxy switches.
*/
public void clear() {
if (!cache) {
return;
}
chunks.clear();
}
public int getChunkMinY() { public int getChunkMinY() {
return minY >> 4; return minY >> 4;
} }

Datei anzeigen

@ -60,6 +60,7 @@ public class DimensionUtils {
int bedrockDimension = javaToBedrock(javaDimension); int bedrockDimension = javaToBedrock(javaDimension);
Entity player = session.getPlayerEntity(); Entity player = session.getPlayerEntity();
session.getChunkCache().clear();
session.getEntityCache().removeAllEntities(); session.getEntityCache().removeAllEntities();
session.getItemFrameCache().clear(); session.getItemFrameCache().clear();
session.getLecternCache().clear(); session.getLecternCache().clear();

Datei anzeigen

@ -57,6 +57,7 @@ import java.security.KeyPairGenerator;
import java.security.PublicKey; import java.security.PublicKey;
import java.security.interfaces.ECPublicKey; import java.security.interfaces.ECPublicKey;
import java.security.spec.ECGenParameterSpec; import java.security.spec.ECGenParameterSpec;
import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
public class LoginEncryptionUtils { public class LoginEncryptionUtils {
@ -70,8 +71,10 @@ public class LoginEncryptionUtils {
} }
ECPublicKey lastKey = null; ECPublicKey lastKey = null;
boolean validChain = false; boolean mojangSigned = false;
for (JsonNode node : data) { Iterator<JsonNode> iterator = data.iterator();
while (iterator.hasNext()) {
JsonNode node = iterator.next();
JWSObject jwt = JWSObject.parse(node.asText()); JWSObject jwt = JWSObject.parse(node.asText());
// x509 cert is expected in every claim // x509 cert is expected in every claim
@ -92,8 +95,12 @@ public class LoginEncryptionUtils {
return false; return false;
} }
if (mojangSigned) {
return !iterator.hasNext();
}
if (lastKey.equals(EncryptionUtils.getMojangPublicKey())) { if (lastKey.equals(EncryptionUtils.getMojangPublicKey())) {
validChain = true; mojangSigned = true;
} }
Object payload = JSONValue.parse(jwt.getPayload().toString()); Object payload = JSONValue.parse(jwt.getPayload().toString());
@ -104,7 +111,7 @@ public class LoginEncryptionUtils {
lastKey = EncryptionUtils.generateKey((String) identityPublicKey); lastKey = EncryptionUtils.generateKey((String) identityPublicKey);
} }
return validChain; return mojangSigned;
} }
public static void encryptPlayerConnection(GeyserSession session, LoginPacket loginPacket) { public static void encryptPlayerConnection(GeyserSession session, LoginPacket loginPacket) {