Skip to content

Commit

Permalink
Only set chat UUID if not already set
Browse files Browse the repository at this point in the history
Fixes #1310
  • Loading branch information
dmulloy2 committed Jul 9, 2021
1 parent 153dd61 commit 95a8849
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/comphenix/protocol/events/PacketContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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;
Expand Down Expand Up @@ -149,11 +150,17 @@ public PacketContainer(PacketType type, Object handle, StructureModifier<Object>

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

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;
Expand Down

0 comments on commit 95a8849

Please sign in to comment.