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 3e7506c3..6471d946 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 @@ -80,6 +80,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand; import com.comphenix.protocol.wrappers.EnumWrappers.CombatEventType; import com.comphenix.protocol.wrappers.EnumWrappers.Difficulty; import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction; +import com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot; import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; import com.comphenix.protocol.wrappers.EnumWrappers.Particle; import com.comphenix.protocol.wrappers.EnumWrappers.PlayerAction; @@ -866,6 +867,15 @@ public class PacketContainer implements Serializable { EnumWrappers.getSoundCategoryClass(), EnumWrappers.getSoundCategoryConverter()); } + /** + * Retrive a read/write structure for the ItemSlot enum in 1.9. + * @return A modifier for ItemSlot enum fields. + */ + public StructureModifier getItemSlots() { + return structureModifier.withType( + EnumWrappers.getItemSlotClass(), EnumWrappers.getItemSlotConverter()); + } + /** * Retrieves the ID of this packet. *

diff --git a/modules/API/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java b/modules/API/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java index 7689ab9b..523ad764 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java +++ b/modules/API/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java @@ -306,6 +306,15 @@ public abstract class EnumWrappers { } } + public enum ItemSlot { + MAINHAND, + OFFHAND, + FEET, + LEGS, + CHEST, + HEAD; + } + private static Class PROTOCOL_CLASS = null; private static Class CLIENT_COMMAND_CLASS = null; private static Class CHAT_VISIBILITY_CLASS = null; @@ -322,6 +331,7 @@ public abstract class EnumWrappers { private static Class SCOREBOARD_ACTION_CLASS = null; private static Class PARTICLE_CLASS = null; private static Class SOUND_CATEGORY_CLASS = null; + private static Class ITEM_SLOT_CLASS = null; private static boolean INITIALIZED = false; private static Map, EquivalentConverter> FROM_NATIVE = Maps.newHashMap(); @@ -355,6 +365,7 @@ public abstract class EnumWrappers { SCOREBOARD_ACTION_CLASS = getEnum(PacketType.Play.Server.SCOREBOARD_SCORE.getPacketClass(), 0); PARTICLE_CLASS = getEnum(PacketType.Play.Server.WORLD_PARTICLES.getPacketClass(), 0); SOUND_CATEGORY_CLASS = getEnum(PacketType.Play.Server.CUSTOM_SOUND_EFFECT.getPacketClass(), 0); + ITEM_SLOT_CLASS = getEnum(PacketType.Play.Server.ENTITY_EQUIPMENT.getPacketClass(), 0); associate(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter()); associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter()); @@ -372,6 +383,7 @@ public abstract class EnumWrappers { associate(SCOREBOARD_ACTION_CLASS, ScoreboardAction.class, getUpdateScoreActionConverter()); associate(PARTICLE_CLASS, Particle.class, getParticleConverter()); associate(SOUND_CATEGORY_CLASS, SoundCategory.class, getSoundCategoryConverter()); + associate(ITEM_SLOT_CLASS, ItemSlot.class, getItemSlotConverter()); INITIALIZED = true; } @@ -485,6 +497,11 @@ public abstract class EnumWrappers { return SOUND_CATEGORY_CLASS; } + public static Class getItemSlotClass() { + initialize(); + return ITEM_SLOT_CLASS; + } + // Get the converters public static EquivalentConverter getProtocolConverter() { return new EnumConverter(Protocol.class); @@ -550,6 +567,10 @@ public abstract class EnumWrappers { return new EnumConverter(SoundCategory.class); } + public static EquivalentConverter getItemSlotConverter() { + return new EnumConverter(ItemSlot.class); + } + /** * Retrieve a generic enum converter for use with StructureModifiers. * @param enumClass - Enum class