Reuse previously sent enforces-secure-chat value

This commit is contained in:
Nassim Jahnke 2024-04-22 16:05:40 +02:00
parent 079671060c
commit 5069b26c2f
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
3 changed files with 14 additions and 4 deletions

View File

@ -197,8 +197,6 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
final String dimensionKey = wrapper.read(Type.STRING);
final DimensionData data = tracker(wrapper.user()).dimensionData(dimensionKey);
wrapper.write(Type.VAR_INT, data.id());
wrapper.user().get(AcknowledgedMessagesStorage.class).clear();
});
map(Type.STRING); // World
map(Type.LONG); // Seed
@ -208,10 +206,17 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
map(Type.BOOLEAN); // Flat
map(Type.OPTIONAL_GLOBAL_POSITION); // Last death location
map(Type.VAR_INT); // Portal cooldown
create(Type.BOOLEAN, false); // Enforces secure chat - moved from server data (which is unfortunately sent a while after this)
handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
handler(playerTrackerHandler());
handler(wrapper -> {
// Enforces secure chat - moved from server data (which is unfortunately sent a while after this)
// Just put in what we know if this is sent multiple times
final AcknowledgedMessagesStorage storage = wrapper.user().get(AcknowledgedMessagesStorage.class);
wrapper.write(Type.BOOLEAN, storage.isSecureChatEnforced());
storage.clear();
// Handle creative interaction range
final byte gamemode = wrapper.get(Type.BYTE, 0);
if (gamemode == CREATIVE_MODE_ID) {
sendRangeAttributes(wrapper.user(), true);

View File

@ -118,4 +118,9 @@ public final class AcknowledgedMessagesStorage implements StorableObject {
this.lastMessage = null;
Arrays.fill(this.trackedMessages, false);
}
@Override
public boolean clearOnServerSwitch() {
return false;
}
}

View File

@ -4,7 +4,7 @@ metadata.format.version = "1.1"
gson = "2.10.1"
fastutil = "8.5.12"
vianbt = "4.4.3"
vianbt = "4.4.4"
mcstructs = "2.5.0-SNAPSHOT"
# Common provided