Clear chunk on dimension switch

This should resolve chunks being leftover in instances such as server switches in proxies.
This commit is contained in:
Camotoy 2021-08-30 15:12:17 -04:00 committed by SupremeMortal
parent b9541505af
commit ab2f5b326f
No known key found for this signature in database
GPG Key ID: DDBB25F8EE4FA29A
3 changed files with 26 additions and 5 deletions

View File

@ -67,7 +67,7 @@ public class ChunkCache {
chunks.put(chunkPosition, geyserColumn);
}
public GeyserColumn getChunk(int chunkX, int chunkZ) {
public GeyserColumn getChunk(int chunkX, int chunkZ) {
long chunkPosition = MathUtils.chunkPositionToLong(chunkX, chunkZ);
return chunks.getOrDefault(chunkPosition, null);
}
@ -136,6 +136,19 @@ public class ChunkCache {
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() {
return minY >> 4;
}

View File

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

View File

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