Only set chat UUID if not already set

Fixes #1310
This commit is contained in:
Dan Mulloy 2021-07-08 23:33:17 -04:00
parent 153dd61994
commit 95a884974a
No known key found for this signature in database
GPG Key ID: 2B62F7DACFF133E8
2 changed files with 12 additions and 5 deletions

View File

@ -43,6 +43,7 @@ import com.comphenix.protocol.reflect.*;
import com.comphenix.protocol.reflect.cloning.*;
import com.comphenix.protocol.reflect.cloning.AggregateCloner.BuilderParameters;
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
import com.comphenix.protocol.reflect.instances.MinecraftGenerator;
import com.comphenix.protocol.utility.MinecraftMethods;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.utility.MinecraftVersion;
@ -149,11 +150,17 @@ public class PacketContainer extends AbstractStructure implements Serializable {
this.type = type;
if (type == PacketType.Play.Server.CHAT) {
getUUIDs().writeSafely(0, new UUID(0L, 0L));
setDefaults();
}
private void setDefaults() {
if (MinecraftVersion.NETHER_UPDATE.atOrAbove() && type == PacketType.Play.Server.CHAT) {
if (!getUUIDs().optionRead(0).isPresent()) {
getUUIDs().writeSafely(0, MinecraftGenerator.SYS_UUID);
}
}
}
/**
* Construct a new packet container from a given handle.
* @param packet - the NMS packet.

View File

@ -14,9 +14,9 @@ import java.util.concurrent.ConcurrentHashMap;
public class MinecraftGenerator {
// system unique id representation
private static final UUID SYS_UUID;
public static final UUID SYS_UUID;
// minecraft default types
private static final Object AIR_ITEM_STACK;
public static final Object AIR_ITEM_STACK;
private static Object DEFAULT_ENTITY_TYPES; // modern servers only (older servers will use an entity type id)
// minecraft method accessors
private static final MethodAccessor NON_NULL_LIST_CREATE;