diff --git a/modules/API/src/main/java/com/comphenix/protocol/events/PacketContainer.java b/modules/API/src/main/java/com/comphenix/protocol/events/PacketContainer.java index d1fb1d35..7cf089c1 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/events/PacketContainer.java +++ b/modules/API/src/main/java/com/comphenix/protocol/events/PacketContainer.java @@ -401,7 +401,25 @@ public class PacketContainer implements Serializable { MinecraftReflection.getItemStackArrayClass(), BukkitConverters.getIgnoreNull(new ItemStackArrayConverter())); } - + + /** + * Retrieves a read/write structure for lists of ItemStacks. + *
+ * This modifier will automatically marshal between the Bukkit ItemStack and the
+ * internal Minecraft ItemStack.
+ * @return A modifier for ItemStack list fields.
+ */
+ public StructureModifier
diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java
index 952102b3..1e387e5b 100644
--- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java
+++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
+import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
@@ -219,34 +220,24 @@ public class PacketContainerTest {
return item;
}
- // TODO: It's a list now
- /* @Test
- public void testGetItemArrayModifier() {
+ @Test
+ public void testGetItemListModifier() {
PacketContainer windowItems = new PacketContainer(PacketType.Play.Server.WINDOW_ITEMS);
- StructureModifier> getItemListModifier() {
+ // Convert to and from the Bukkit wrapper
+ return structureModifier.withType(
+ List.class,
+ BukkitConverters.getListConverter(
+ MinecraftReflection.getItemStackClass(),
+ BukkitConverters.getItemStackConverter()
+ )
+ );
+ }
+
/**
* Retrieve a read/write structure for maps of statistics.
*
> itemAccess = windowItems.getItemListModifier();
- ItemStack[] itemArray = new ItemStack[] {
- itemWithData(),
- new ItemStack(Material.DIAMOND_AXE)
- };
+ List