diff --git a/src/main/java/com/comphenix/protocol/PacketType.java b/src/main/java/com/comphenix/protocol/PacketType.java
index e690dc971..d7769de76 100644
--- a/src/main/java/com/comphenix/protocol/PacketType.java
+++ b/src/main/java/com/comphenix/protocol/PacketType.java
@@ -14,18 +14,18 @@
import java.util.UUID;
import java.util.function.BiConsumer;
-import org.apache.commons.lang.WordUtils;
-import org.bukkit.Bukkit;
-
import com.comphenix.protocol.PacketTypeLookup.ClassLookup;
import com.comphenix.protocol.events.ConnectionSide;
import com.comphenix.protocol.injector.packet.PacketRegistry;
import com.comphenix.protocol.scheduler.UniversalRunnable;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.utility.MinecraftVersion;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.Iterables;
+import org.apache.commons.lang.WordUtils;
+import org.bukkit.Bukkit;
/**
* Represents the type of a packet in a specific protocol.
*
@@ -477,8 +477,8 @@ public static class Client extends PacketTypeEnum {
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x35, "SignUpdate", "UpdateSign", "CPacketUpdateSign");
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x36, "Swing", "ArmAnimation", "CPacketAnimation");
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x37, "TeleportToEntity", "Spectate", "CPacketSpectate");
- public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x38, "UseItemOn", "UseItem", "CPacketPlayerTryUseItemOnBlock");
- public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x39, "BlockPlace", "CPacketPlayerTryUseItem");
+ public static final PacketType USE_ITEM_ON = new PacketType(PROTOCOL, SENDER, 0x38, "UseItemOn", "BlockPlace", "CPacketPlayerTryUseItemOnBlock");
+ public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x39, "UseItem", "CPacketPlayerTryUseItem");
/**
* @deprecated Removed in 1.17
@@ -498,6 +498,12 @@ public static class Client extends PacketTypeEnum {
@Deprecated
public static final PacketType CHAT_PREVIEW = new PacketType(PROTOCOL, SENDER, 253, "ChatPreview");
+ /**
+ * @deprecated Renamed to USE_ITEM_ON
+ */
+ @Deprecated
+ public static final PacketType BLOCK_PLACE = USE_ITEM_ON.clone();
+
private static final Client INSTANCE = new Client();
// Prevent accidental construction
diff --git a/src/main/java/com/comphenix/protocol/events/AbstractStructure.java b/src/main/java/com/comphenix/protocol/events/AbstractStructure.java
index ec8b9f2e5..b915ad38f 100644
--- a/src/main/java/com/comphenix/protocol/events/AbstractStructure.java
+++ b/src/main/java/com/comphenix/protocol/events/AbstractStructure.java
@@ -870,6 +870,55 @@ public StructureModifier getChatTypes() {
EnumWrappers.getChatTypeConverter());
}
+ /**
+ * Retrieve a read/write structure for the DisplaySlot enum in 1.20.2.
+ * @return A modifier for DisplaySlot enum fields.
+ */
+ public StructureModifier getDisplaySlots() {
+ return structureModifier.withType(
+ EnumWrappers.getDisplaySlotClass(),
+ EnumWrappers.getDisplaySlotConverter());
+ }
+
+ /**
+ * Retrieve a read/write structure for the RenderType enum.
+ * @return A modifier for RenderType enum fields.
+ */
+ public StructureModifier getRenderTypes() {
+ return structureModifier.withType(
+ EnumWrappers.getRenderTypeClass(),
+ EnumWrappers.getRenderTypeConverter());
+ }
+
+ /**
+ * Retrieve a read/write structure for the ChatFormatting enum.
+ * @return A modifier for ChatFormatting enum fields.
+ */
+ public StructureModifier getChatFormattings() {
+ return structureModifier.withType(
+ EnumWrappers.getChatFormattingClass(),
+ EnumWrappers.getChatFormattingConverter());
+ }
+
+ /**
+ * Retrieve a read/write structure for optional team parameters in 1.17+.
+ * @return A modifier for optional team parameters fields.
+ */
+ public StructureModifier> getOptionalTeamParameters() {
+ return getOptionals(BukkitConverters.getWrappedTeamParametersConverter());
+ }
+
+ /**
+ * Retrieve a read/write structure for the NumberFormat class in 1.20.4+.
+ * @return A modifier for NumberFormat fields.
+ */
+ public StructureModifier getNumberFormats() {
+ return structureModifier.withType(
+ MinecraftReflection.getNumberFormatClass().orElse(null),
+ BukkitConverters.getWrappedNumberFormatConverter());
+ }
+
+
/**
* Retrieve a read/write structure for the MinecraftKey class.
* @return A modifier for MinecraftKey fields.
diff --git a/src/main/java/com/comphenix/protocol/events/PacketContainer.java b/src/main/java/com/comphenix/protocol/events/PacketContainer.java
index 19ee953b6..ba50ca72f 100644
--- a/src/main/java/com/comphenix/protocol/events/PacketContainer.java
+++ b/src/main/java/com/comphenix/protocol/events/PacketContainer.java
@@ -31,6 +31,7 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Function;
+import javax.annotation.Nullable;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.injector.StructureCache;
@@ -58,10 +59,10 @@
import com.comphenix.protocol.utility.MinecraftVersion;
import com.comphenix.protocol.wrappers.Converters;
import com.comphenix.protocol.wrappers.WrappedStreamCodec;
+
import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import io.netty.util.ReferenceCountUtil;
-import javax.annotation.Nullable;
/**
* Represents a Minecraft packet indirectly.
@@ -80,7 +81,7 @@ public class PacketContainer extends AbstractStructure implements Serializable {
// Used to clone packets
private static final AggregateCloner DEEP_CLONER = AggregateCloner
.newBuilder()
- .instanceProvider(StructureCache::newPacket)
+ .instanceProvider(StructureCache::newInstance)
.andThen(BukkitCloner.class)
.andThen(ImmutableDetector.class)
.andThen(JavaOptionalCloner.class)
@@ -91,7 +92,7 @@ public class PacketContainer extends AbstractStructure implements Serializable {
private static final AggregateCloner SHALLOW_CLONER = AggregateCloner
.newBuilder()
- .instanceProvider(StructureCache::newPacket)
+ .instanceProvider(StructureCache::newInstance)
.andThen(param -> {
if (param == null)
throw new IllegalArgumentException("Cannot be NULL.");
diff --git a/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java b/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java
index 64a20cbb5..722ea5428 100644
--- a/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java
+++ b/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java
@@ -17,10 +17,25 @@
package com.comphenix.protocol.events;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
import com.comphenix.protocol.reflect.accessors.Accessors;
import com.comphenix.protocol.reflect.accessors.MethodAccessor;
import com.comphenix.protocol.utility.ByteBuddyFactory;
import com.comphenix.protocol.utility.Util;
+
import net.bytebuddy.description.ByteCodeElement;
import net.bytebuddy.description.modifier.Visibility;
import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
@@ -35,27 +50,19 @@
import net.bytebuddy.implementation.bind.annotation.RuntimeType;
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;
-import org.bukkit.*;
+import org.bukkit.BanEntry;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Material;
+import org.bukkit.OfflinePlayer;
+import org.bukkit.Statistic;
+import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.profile.PlayerProfile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.time.Duration;
-import java.time.Instant;
-import java.util.Date;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-
/**
* Represents a player object that can be serialized by Java.
*
diff --git a/src/main/java/com/comphenix/protocol/injector/StructureCache.java b/src/main/java/com/comphenix/protocol/injector/StructureCache.java
index 6b50b465f..cb50e3c73 100644
--- a/src/main/java/com/comphenix/protocol/injector/StructureCache.java
+++ b/src/main/java/com/comphenix/protocol/injector/StructureCache.java
@@ -32,7 +32,7 @@
import com.comphenix.protocol.reflect.accessors.ConstructorAccessor;
import com.comphenix.protocol.reflect.fuzzy.FuzzyMethodContract;
import com.comphenix.protocol.reflect.instances.DefaultInstances;
-import com.comphenix.protocol.reflect.instances.PacketCreator;
+import com.comphenix.protocol.reflect.instances.InstanceCreator;
import com.comphenix.protocol.utility.ByteBuddyFactory;
import com.comphenix.protocol.utility.MinecraftMethods;
import com.comphenix.protocol.utility.MinecraftReflection;
@@ -57,7 +57,7 @@
public class StructureCache {
// Structure modifiers
- private static final Map, Supplier