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 fe892f61..b3174952 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 @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentMap; import javax.annotation.Nonnull; @@ -77,6 +78,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility; 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.Direction; import com.comphenix.protocol.wrappers.EnumWrappers.EntityUseAction; import com.comphenix.protocol.wrappers.EnumWrappers.EnumConverter; import com.comphenix.protocol.wrappers.EnumWrappers.Hand; @@ -332,7 +334,15 @@ public class PacketContainer implements Serializable { public StructureModifier getStrings() { return structureModifier.withType(String.class); } - + + /** + * Retrieves a read/write structure for every UUID field. + * @return A modifier for every UUID field. + */ + public StructureModifier getUUIDs() { + return structureModifier.withType(UUID.class); + } + /** * Retrieves a read/write structure for every String array field. * @return A modifier for every String array field. @@ -368,7 +378,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for ItemStack. *

- * This modifier will automatically marshall between the Bukkit ItemStack and the + * This modifier will automatically marshal between the Bukkit ItemStack and the * internal Minecraft ItemStack. * @return A modifier for ItemStack fields. */ @@ -381,7 +391,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for arrays of ItemStacks. *

- * This modifier will automatically marshall between the Bukkit ItemStack and the + * This modifier will automatically marshal between the Bukkit ItemStack and the * internal Minecraft ItemStack. * @return A modifier for ItemStack array fields. */ @@ -410,7 +420,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for the world type enum. *

- * This modifier will automatically marshall between the Bukkit world type and the + * This modifier will automatically marshal between the Bukkit world type and the * internal Minecraft world type. * @return A modifier for world type fields. */ @@ -524,7 +534,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for collections of attribute snapshots. *

- * This modifier will automatically marshall between the visible ProtocolLib WrappedAttribute and the + * This modifier will automatically marshal between the visible ProtocolLib WrappedAttribute and the * internal Minecraft AttributeSnapshot. * @return A modifier for AttributeSnapshot collection fields. */ @@ -541,7 +551,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for collections of chunk positions. *

- * This modifier will automatically marshall between the visible ProtocolLib ChunkPosition and the + * This modifier will automatically marshal between the visible ProtocolLib ChunkPosition and the * internal Minecraft ChunkPosition. * * @return A modifier for ChunkPosition list fields. @@ -559,7 +569,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for collections of chunk positions. *

- * This modifier will automatically marshall between the visible ProtocolLib BlockPosition and the + * This modifier will automatically marshal between the visible ProtocolLib BlockPosition and the * internal Minecraft BlockPosition. * * @return A modifier for ChunkPosition list fields. @@ -577,7 +587,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for collections of watchable objects. *

- * This modifier will automatically marshall between the visible WrappedWatchableObject and the + * This modifier will automatically marshal between the visible WrappedWatchableObject and the * internal Minecraft WatchableObject. * @return A modifier for watchable object list fields. */ @@ -594,7 +604,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for block fields. *

- * This modifier will automatically marshall between Material and the + * This modifier will automatically marshal between Material and the * internal Minecraft Block. * @return A modifier for GameProfile fields. */ @@ -607,7 +617,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for game profiles in Minecraft 1.7.2. *

- * This modifier will automatically marshall between WrappedGameProfile and the + * This modifier will automatically marshal between WrappedGameProfile and the * internal Minecraft GameProfile. * @return A modifier for GameProfile fields. */ @@ -620,7 +630,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for BlockData in Minecraft 1.8. *

- * This modifier will automatically marshall between WrappedBlockData and the + * This modifier will automatically marshal between WrappedBlockData and the * internal Minecraft IBlockData. * @return A modifier for BlockData fields. */ @@ -633,7 +643,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for MultiBlockChangeInfo arrays in Minecraft 1.8. *

- * This modifier will automatically marshall between MultiBlockChangeInfo and the + * This modifier will automatically marshal between MultiBlockChangeInfo and the * internal Minecraft MultiBlockChangeInfo. * @return A modifier for BlockData fields. */ @@ -648,7 +658,7 @@ public class PacketContainer implements Serializable { /** * Retrieves a read/write structure for chat components in Minecraft 1.7.2. *

- * This modifier will automatically marshall between WrappedChatComponent and the + * This modifier will automatically marshal between WrappedChatComponent and the * internal Minecraft IChatBaseComponent. * @return A modifier for ChatComponent fields. */ @@ -887,7 +897,7 @@ public class PacketContainer implements Serializable { } /** - * Retrive a read/write structure for the ItemSlot enum in 1.9. + * Retrieve a read/write structure for the ItemSlot enum in 1.9. * @return A modifier for ItemSlot enum fields. */ public StructureModifier getItemSlots() { @@ -896,7 +906,7 @@ public class PacketContainer implements Serializable { } /** - * Retrive a read/write structure for the Hand enum in 1.9. + * Retrieve a read/write structure for the Hand enum in 1.9. * @return A modifier for Hand enum fields. */ public StructureModifier getHands() { @@ -904,6 +914,15 @@ public class PacketContainer implements Serializable { EnumWrappers.getHandClass(), EnumWrappers.getHandConverter()); } + /** + * Retrieve a read/write structure for the Direction enum in 1.10. + * @return A modifier for Direction enum fields. + */ + public StructureModifier getDirections() { + return structureModifier.withType( + EnumWrappers.getDirectionClass(), EnumWrappers.getDirectionConverter()); + } + /** * Retrieve a read/write structure for an enum. This allows for the use of * user-created enums that may not exist in ProtocolLib. The specific (user 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 72ded7b0..2d21fdb0 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 @@ -320,6 +320,15 @@ public abstract class EnumWrappers { OFF_HAND; } + public enum Direction { + DOWN(), + UP(), + NORTH(), + SOUTH(), + WEST(), + EAST(); + } + private static Class PROTOCOL_CLASS = null; private static Class CLIENT_COMMAND_CLASS = null; private static Class CHAT_VISIBILITY_CLASS = null; @@ -338,6 +347,7 @@ public abstract class EnumWrappers { private static Class SOUND_CATEGORY_CLASS = null; private static Class ITEM_SLOT_CLASS = null; private static Class HAND_CLASS = null; + private static Class DIRECTION_CLASS = null; private static boolean INITIALIZED = false; private static Map, EquivalentConverter> FROM_NATIVE = Maps.newHashMap(); @@ -373,6 +383,7 @@ public abstract class EnumWrappers { SOUND_CATEGORY_CLASS = getEnum(PacketType.Play.Server.CUSTOM_SOUND_EFFECT.getPacketClass(), 0); ITEM_SLOT_CLASS = getEnum(PacketType.Play.Server.ENTITY_EQUIPMENT.getPacketClass(), 0); HAND_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 1); + DIRECTION_CLASS = getEnum(PacketType.Play.Client.USE_ITEM.getPacketClass(), 0); associate(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter()); associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter()); @@ -392,6 +403,7 @@ public abstract class EnumWrappers { associate(SOUND_CATEGORY_CLASS, SoundCategory.class, getSoundCategoryConverter()); associate(ITEM_SLOT_CLASS, ItemSlot.class, getItemSlotConverter()); associate(HAND_CLASS, Hand.class, getHandConverter()); + associate(DIRECTION_CLASS, Direction.class, getDirectionConverter()); INITIALIZED = true; } @@ -515,6 +527,11 @@ public abstract class EnumWrappers { return HAND_CLASS; } + public static Class getDirectionClass() { + initialize(); + return DIRECTION_CLASS; + } + // Get the converters public static EquivalentConverter getProtocolConverter() { return new EnumConverter(Protocol.class); @@ -588,6 +605,10 @@ public abstract class EnumWrappers { return new EnumConverter(Hand.class); } + public static EquivalentConverter getDirectionConverter() { + return new EnumConverter(Direction.class); + } + /** * Retrieve a generic enum converter for use with StructureModifiers. * @param enumClass - Enum class