diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java index 94af96b3..c0961173 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketContainer.java @@ -73,10 +73,13 @@ import com.comphenix.protocol.wrappers.ChunkPosition; import com.comphenix.protocol.wrappers.EnumWrappers; 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.EntityUseAction; import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode; import com.comphenix.protocol.wrappers.EnumWrappers.ResourcePackStatus; +import com.comphenix.protocol.wrappers.EnumWrappers.TitleAction; +import com.comphenix.protocol.wrappers.EnumWrappers.WorldBorderAction; import com.comphenix.protocol.wrappers.WrappedAttribute; import com.comphenix.protocol.wrappers.WrappedChatComponent; import com.comphenix.protocol.wrappers.WrappedDataWatcher; @@ -701,6 +704,36 @@ public class PacketContainer implements Serializable { EnumWrappers.getResourcePackStatusClass(), EnumWrappers.getResourcePackStatusConverter()); } + /** + * Retrieve a read/write structure for the TitleAction enum in 1.8.0. + * @return A modifier for TitleAction enum fields. + */ + public StructureModifier getTitleActions() { + // Convert to and from the wrapper + return structureModifier.withType( + EnumWrappers.getTitleActionClass(), EnumWrappers.getTitleActionConverter()); + } + + /** + * Retrieve a read/write structure for the WorldBorderAction enum in 1.8.0. + * @return A modifier for WorldBorderAction enum fields. + */ + public StructureModifier getWorldBorderActions() { + // Convert to and from the wrapper + return structureModifier.withType( + EnumWrappers.getWorldBorderActionClass(), EnumWrappers.getWorldBorderActionConverter()); + } + + /** + * Retrieve a read/write structure for the CombatEvent enum in 1.8.0. + * @return A modifier for CombatEvent enum fields. + */ + public StructureModifier getCombatEvents() { + // Convert to and from the wrapper + return structureModifier.withType( + EnumWrappers.getCombatEventTypeClass(), EnumWrappers.getCombatEventTypeConverter()); + } + /** * Retrieves the ID of this packet. *

diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java index 07f59187..34d70714 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/EnumWrappers.java @@ -67,6 +67,29 @@ public abstract class EnumWrappers { ACCEPTED; } + public enum TitleAction { + TITLE, + SUBTITLE, + TIMES, + CLEAR, + RESET; + } + + public enum WorldBorderAction { + SET_SIZE, + LERP_SIZE, + SET_CENTER, + INITIALIZE, + SET_WARNING_TIME, + SET_WARNING_BLOCKS; + } + + public enum CombatEventType { + ENTER_COMBAT, + END_COMBAT, + ENTITY_DIED; + } + private static Class PROTOCOL_CLASS = null; private static Class CLIENT_COMMAND_CLASS = null; private static Class CHAT_VISIBILITY_CLASS = null; @@ -74,6 +97,9 @@ public abstract class EnumWrappers { private static Class ENTITY_USE_ACTION_CLASS = null; private static Class GAMEMODE_CLASS = null; private static Class RESOURCE_PACK_STATUS_CLASS = null; + private static Class TITLE_ACTION_CLASS = null; + private static Class WORLD_BORDER_ACTION_CLASS = null; + private static Class COMBAT_EVENT_TYPE_CLASS = null; private static boolean INITIALIZED = false; private static Map, EquivalentConverter> FROM_NATIVE = Maps.newHashMap(); @@ -96,6 +122,9 @@ public abstract class EnumWrappers { ENTITY_USE_ACTION_CLASS = getEnum(PacketType.Play.Client.USE_ENTITY.getPacketClass(), 0); GAMEMODE_CLASS = getEnum(PacketType.Play.Server.LOGIN.getPacketClass(), 0); RESOURCE_PACK_STATUS_CLASS = getEnum(PacketType.Play.Client.RESOURCE_PACK_STATUS.getPacketClass(), 0); + TITLE_ACTION_CLASS = getEnum(PacketType.Play.Server.TITLE.getPacketClass(), 0); + WORLD_BORDER_ACTION_CLASS = getEnum(PacketType.Play.Server.WORLD_BORDER.getPacketClass(), 0); + COMBAT_EVENT_TYPE_CLASS = getEnum(PacketType.Play.Server.COMBAT_EVENT.getPacketClass(), 0); associate(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter()); associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter()); @@ -104,6 +133,9 @@ public abstract class EnumWrappers { associate(ENTITY_USE_ACTION_CLASS, EntityUseAction.class, getEntityUseActionConverter()); associate(GAMEMODE_CLASS, NativeGameMode.class, getGameModeConverter()); associate(RESOURCE_PACK_STATUS_CLASS, ResourcePackStatus.class, getResourcePackStatusConverter()); + associate(TITLE_ACTION_CLASS, TitleAction.class, getTitleActionConverter()); + associate(WORLD_BORDER_ACTION_CLASS, WorldBorderAction.class, getWorldBorderActionConverter()); + associate(COMBAT_EVENT_TYPE_CLASS, CombatEventType.class, getCombatEventTypeConverter()); INITIALIZED = true; } @@ -166,6 +198,21 @@ public abstract class EnumWrappers { return RESOURCE_PACK_STATUS_CLASS; } + public static Class getTitleActionClass() { + initialize(); + return TITLE_ACTION_CLASS; + } + + public static Class getWorldBorderActionClass() { + initialize(); + return WORLD_BORDER_ACTION_CLASS; + } + + public static Class getCombatEventTypeClass() { + initialize(); + return COMBAT_EVENT_TYPE_CLASS; + } + // Get the converters public static EquivalentConverter getProtocolConverter() { return new EnumConverter(Protocol.class); @@ -195,6 +242,18 @@ public abstract class EnumWrappers { return new EnumConverter(ResourcePackStatus.class); } + public static EquivalentConverter getTitleActionConverter() { + return new EnumConverter(TitleAction.class); + } + + public static EquivalentConverter getWorldBorderActionConverter() { + return new EnumConverter(WorldBorderAction.class); + } + + public static EquivalentConverter getCombatEventTypeConverter() { + return new EnumConverter(CombatEventType.class); + } + // The common enum converter @SuppressWarnings({ "rawtypes", "unchecked" }) private static class EnumConverter> implements EquivalentConverter {