From 13f5c14599e0c0fe05d2c5712746f1a4df1f0497 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 24 Aug 2020 11:40:47 -0400 Subject: [PATCH] Fix bytecode breakage with StructureModifier Fixes #935 --- .../comphenix/protocol/events/PacketContainer.java | 4 ++-- .../protocol/reflect/StructureModifier.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/comphenix/protocol/events/PacketContainer.java b/src/main/java/com/comphenix/protocol/events/PacketContainer.java index 51e2a38b..465e0e90 100644 --- a/src/main/java/com/comphenix/protocol/events/PacketContainer.java +++ b/src/main/java/com/comphenix/protocol/events/PacketContainer.java @@ -926,7 +926,7 @@ public class PacketContainer implements Serializable { */ public StructureModifier getDimensions() { if (NEW_DIMENSIONS) { - return structureModifier.withType( + return structureModifier.withParamType( MinecraftReflection.getMinecraftClass("ResourceKey"), BukkitConverters.getDimensionIDConverter(), MinecraftReflection.getMinecraftClass("DimensionManager") @@ -977,7 +977,7 @@ public class PacketContainer implements Serializable { * @return The Structure Modifier */ public StructureModifier getWorldKeys() { - return structureModifier.withType( + return structureModifier.withParamType( MinecraftReflection.getMinecraftClass("ResourceKey"), BukkitConverters.getWorldKeyConverter(), MinecraftReflection.getNmsWorldClass() diff --git a/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java b/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java index e9eadd15..1577570f 100644 --- a/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java +++ b/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java @@ -477,8 +477,20 @@ public class StructureModifier { * @param converter - converts objects into the given type. * @return A structure modifier for fields of this type. */ + public StructureModifier withType(Class fieldType, EquivalentConverter converter) { + return withParamType(fieldType, converter); + } + + /** + * Retrieves a structure modifier that only reads and writes fields of a given type. + * @param Type + * @param fieldType - the type, or supertype, of every field to modify. + * @param converter - converts objects into the given type. + * @param paramTypes - field type parameters + * @return A structure modifier for fields of this type. + */ @SuppressWarnings("unchecked") - public StructureModifier withType(Class fieldType, EquivalentConverter converter, Class... paramTypes) { + public StructureModifier withParamType(Class fieldType, EquivalentConverter converter, Class... paramTypes) { if (fieldType == null) { // It's not supported in this version, so return an empty modifier return new StructureModifier() {