From 3887ba27d2f3b66831e4dc1bc70d03e581c5cd02 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Sun, 14 May 2017 14:28:56 -0400 Subject: [PATCH] Update to the 1.12 pre-release - Now requires Java 8 - Added new packets - Added ChatType enum (replaces magic value) - Missing protocol version --- modules/API/pom.xml | 10 +- .../com/comphenix/protocol/PacketType.java | 216 +++++++++--------- .../protocol/events/ListeningWhitelist.java | 7 +- .../protocol/events/PacketContainer.java | 10 + .../protocol/events/ScheduledPacket.java | 7 +- .../events/SerializedOfflinePlayer.java | 1 - .../injector/netty/NettyByteBufAdapter.java | 47 +++- .../protocol/reflect/MethodInfo.java | 1 - .../comphenix/protocol/utility/Constants.java | 2 +- .../utility/MinecraftProtocolVersion.java | 1 + .../protocol/utility/MinecraftVersion.java | 5 + .../protocol/wrappers/EnumWrappers.java | 44 +++- .../protocol/wrappers/WrappedAttribute.java | 21 +- .../wrappers/WrappedSignedProperty.java | 6 +- modules/ProtocolLib/pom.xml | 10 +- .../injector/netty/ChannelInjector.java | 27 ++- .../protocol/injector/netty/ChannelProxy.java | 17 ++ .../injector/netty/EventLoopProxy.java | 4 + .../injector/netty/PipelineProxy.java | 21 ++ .../protocol/BukkitInitialization.java | 10 +- .../comphenix/protocol/PacketTypeTest.java | 2 +- .../protocol/events/PacketContainerTest.java | 18 +- .../protocol/injector/WirePacketTest.java | 3 + .../reflect/cloning/AggregateClonerTest.java | 6 +- .../utility/MinecraftReflectionTest.java | 24 +- .../utility/StreamSerializerTest.java | 2 +- .../wrappers/ChunkCoordIntPairTest.java | 8 +- .../protocol/wrappers/EnumWrappersTest.java | 12 +- .../wrappers/WrappedAttributeTest.java | 6 +- .../wrappers/WrappedDataWatcherTest.java | 8 +- .../protocol/wrappers/nbt/NbtFactoryTest.java | 4 +- pom.xml | 1 + 32 files changed, 339 insertions(+), 222 deletions(-) diff --git a/modules/API/pom.xml b/modules/API/pom.xml index 28067e4e..ecf00464 100644 --- a/modules/API/pom.xml +++ b/modules/API/pom.xml @@ -3,7 +3,7 @@ 4.0.0 ProtocolLib-API ProtocolLib-API - 4.2.2-SNAPSHOT + 4.3.0-SNAPSHOT Provides read/write access to the Minecraft protocol. http://www.spigotmc.org/resources/protocollib.1997/ @@ -41,8 +41,8 @@ maven-compiler-plugin 3.5.1 - 1.7 - 1.7 + 1.8 + 1.8 @@ -203,13 +203,13 @@ org.spigotmc spigot-api - 1.11.2-R0.1-SNAPSHOT + ${spigotVersion} provided org.spigotmc spigot - 1.11.2-R0.1-SNAPSHOT + ${spigotVersion} provided diff --git a/modules/API/src/main/java/com/comphenix/protocol/PacketType.java b/modules/API/src/main/java/com/comphenix/protocol/PacketType.java index 0ce84d0f..4d62e2f2 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/PacketType.java +++ b/modules/API/src/main/java/com/comphenix/protocol/PacketType.java @@ -106,82 +106,84 @@ public class PacketType implements Serializable, Cloneable, Comparable { private final static Sender SENDER = Sender.SERVER; - public static final PacketType SPAWN_ENTITY = new PacketType(PROTOCOL, SENDER, 0x00, 0x0E, "SpawnEntity"); - public static final PacketType SPAWN_ENTITY_EXPERIENCE_ORB = new PacketType(PROTOCOL, SENDER, 0x01, 0x11, "SpawnEntityExperienceOrb"); - public static final PacketType SPAWN_ENTITY_WEATHER = new PacketType(PROTOCOL, SENDER, 0x02, 0x2C, "SpawnEntityWeather"); - public static final PacketType SPAWN_ENTITY_LIVING = new PacketType(PROTOCOL, SENDER, 0x03, 0x0F, "SpawnEntityLiving"); - public static final PacketType SPAWN_ENTITY_PAINTING = new PacketType(PROTOCOL, SENDER, 0x04, 0x10, "SpawnEntityPainting"); - public static final PacketType NAMED_ENTITY_SPAWN = new PacketType(PROTOCOL, SENDER, 0x05, 0x0C, "NamedEntitySpawn"); - public static final PacketType ANIMATION = new PacketType(PROTOCOL, SENDER, 0x06, 0x0B, "Animation"); - public static final PacketType STATISTIC = new PacketType(PROTOCOL, SENDER, 0x07, 0x37, "Statistic"); - public static final PacketType BLOCK_BREAK_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x08, 0x25, "BlockBreakAnimation"); - public static final PacketType TILE_ENTITY_DATA = new PacketType(PROTOCOL, SENDER, 0x09, 0x35, "TileEntityData"); - public static final PacketType BLOCK_ACTION = new PacketType(PROTOCOL, SENDER, 0x0A, 0x24, "BlockAction"); - public static final PacketType BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x0B, 0x23, "BlockChange"); - public static final PacketType BOSS = new PacketType(PROTOCOL, SENDER, 0x0C, 0xFF, "Boss"); - public static final PacketType SERVER_DIFFICULTY = new PacketType(PROTOCOL, SENDER, 0x0D, 0x41, "ServerDifficulty"); - public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0E, 0x3A, "TabComplete"); - public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x0F, 0x02, "Chat"); - public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x10, 0x22, "MultiBlockChange"); - public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x11, 0x32, "Transaction"); - public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x12, 0x2E, "CloseWindow"); - public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x13, 0x2D, "OpenWindow"); - public static final PacketType WINDOW_ITEMS = new PacketType(PROTOCOL, SENDER, 0x14, 0x30, "WindowItems"); - public static final PacketType WINDOW_DATA = new PacketType(PROTOCOL, SENDER, 0x15, 0x31, "WindowData"); - public static final PacketType SET_SLOT = new PacketType(PROTOCOL, SENDER, 0x16, 0x2F, "SetSlot"); - public static final PacketType SET_COOLDOWN = new PacketType(PROTOCOL, SENDER, 0x17, 0xFC, "SetCooldown"); - public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x18, 0x3F, "CustomPayload"); - public static final PacketType CUSTOM_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x19, 0xFD, "CustomSoundEffect"); - public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x40, "KickDisconnect"); - public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1B, 0x1A, "EntityStatus"); - public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x1C, 0x27, "Explosion"); - public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x1D, 0xFA, "UnloadChunk"); - public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x1E, 0x2B, "GameStateChange"); - public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x1F, 0x00, "KeepAlive"); - public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x20, 0x21, "MapChunk"); - public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x21, 0x28, "WorldEvent"); - public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x22, 0x2A, "WorldParticles"); - public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x23, 0x01, "Login"); - public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x24, 0x34, "Map"); - public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x25, 0x15, "RelEntityMove"); - public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x26, 0x17, "RelEntityMoveLook"); - public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x27, 0x16, "EntityLook"); - public static final PacketType ENTITY = new PacketType(PROTOCOL, SENDER, 0x28, 0x14, "Entity"); - public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x29, 0xFE, "VehicleMove"); - public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x2A, 0x36, "OpenSignEditor"); - public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x2B, 0x39, "Abilities"); - public static final PacketType COMBAT_EVENT = new PacketType(PROTOCOL, SENDER, 0x2C, 0x42, "CombatEvent"); - public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x2D, 0x38, "PlayerInfo"); - public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x2E, 0x08, "Position"); - public static final PacketType BED = new PacketType(PROTOCOL, SENDER, 0x2F, 0x0A, "Bed"); - public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x30, 0x13, "EntityDestroy"); - public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x31, 0x1E, "RemoveEntityEffect"); - public static final PacketType RESOURCE_PACK_SEND = new PacketType(PROTOCOL, SENDER, 0x32, 0x48, "ResourcePackSend"); - public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x33, 0x07, "Respawn"); - public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x34, 0x19, "EntityHeadRotation"); - public static final PacketType WORLD_BORDER = new PacketType(PROTOCOL, SENDER, 0x35, 0x44, "WorldBorder"); - public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x36, 0x43, "Camera"); - public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x37, 0x09, "HeldItemSlot"); - public static final PacketType SCOREBOARD_DISPLAY_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x38, 0x3D, "ScoreboardDisplayObjective"); - public static final PacketType ENTITY_METADATA = new PacketType(PROTOCOL, SENDER, 0x39, 0x1C, "EntityMetadata"); - public static final PacketType ATTACH_ENTITY = new PacketType(PROTOCOL, SENDER, 0x3A, 0x1B, "AttachEntity"); - public static final PacketType ENTITY_VELOCITY = new PacketType(PROTOCOL, SENDER, 0x3B, 0x12, "EntityVelocity"); - public static final PacketType ENTITY_EQUIPMENT = new PacketType(PROTOCOL, SENDER, 0x3C, 0x04, "EntityEquipment"); - public static final PacketType EXPERIENCE = new PacketType(PROTOCOL, SENDER, 0x3D, 0x1F, "Experience"); - public static final PacketType UPDATE_HEALTH = new PacketType(PROTOCOL, SENDER, 0x3E, 0x06, "UpdateHealth"); - public static final PacketType SCOREBOARD_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x3F, 0x3B, "ScoreboardObjective"); - public static final PacketType MOUNT = new PacketType(PROTOCOL, SENDER, 0x40, 0xFB, "Mount"); - public static final PacketType SCOREBOARD_TEAM = new PacketType(PROTOCOL, SENDER, 0x41, 0x3E, "ScoreboardTeam"); - public static final PacketType SCOREBOARD_SCORE = new PacketType(PROTOCOL, SENDER, 0x42, 0x3C, "ScoreboardScore"); - public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x43, 0x05, "SpawnPosition"); - public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x44, 0x03, "UpdateTime"); - public static final PacketType TITLE = new PacketType(PROTOCOL, SENDER, 0x45, 0x45, "Title"); - public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x46, 0x47, "NamedSoundEffect"); - public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x47, 0x48, "PlayerListHeaderFooter"); - public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x48, 0x49, "Collect"); - public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x49, 0x4A, "EntityTeleport"); - public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x4A, 0x4B, "UpdateAttributes"); - public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4B, 0x4C, "EntityEffect"); + public static final PacketType SPAWN_ENTITY = new PacketType(PROTOCOL, SENDER, 0x00, 0x00, "SpawnEntity"); + public static final PacketType SPAWN_ENTITY_EXPERIENCE_ORB = new PacketType(PROTOCOL, SENDER, 0x01, 0x01, "SpawnEntityExperienceOrb"); + public static final PacketType SPAWN_ENTITY_WEATHER = new PacketType(PROTOCOL, SENDER, 0x02, 0x02, "SpawnEntityWeather"); + public static final PacketType SPAWN_ENTITY_LIVING = new PacketType(PROTOCOL, SENDER, 0x03, 0x03, "SpawnEntityLiving"); + public static final PacketType SPAWN_ENTITY_PAINTING = new PacketType(PROTOCOL, SENDER, 0x04, 0x04, "SpawnEntityPainting"); + public static final PacketType NAMED_ENTITY_SPAWN = new PacketType(PROTOCOL, SENDER, 0x05, 0x05, "NamedEntitySpawn"); + public static final PacketType ANIMATION = new PacketType(PROTOCOL, SENDER, 0x06, 0x06, "Animation"); + public static final PacketType STATISTIC = new PacketType(PROTOCOL, SENDER, 0x07, 0x07, "Statistic"); + public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x08, 0x08, "Advancements"); + public static final PacketType BLOCK_BREAK_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x09, 0x08, "BlockBreakAnimation"); + public static final PacketType TILE_ENTITY_DATA = new PacketType(PROTOCOL, SENDER, 0x0A, 0x09, "TileEntityData"); + public static final PacketType BLOCK_ACTION = new PacketType(PROTOCOL, SENDER, 0x0B, 0x0A, "BlockAction"); + public static final PacketType BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x0C, 0x0B, "BlockChange"); + public static final PacketType BOSS = new PacketType(PROTOCOL, SENDER, 0x0D, 0x0C, "Boss"); + public static final PacketType SERVER_DIFFICULTY = new PacketType(PROTOCOL, SENDER, 0x0E, 0x0D, "ServerDifficulty"); + public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0F, 0x0E, "TabComplete"); + public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x10, 0x0F, "Chat"); + public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x11, 0x10, "MultiBlockChange"); + public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x12, 0x11, "Transaction"); + public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x13, 0x12, "CloseWindow"); + public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x14, 0x13, "OpenWindow"); + public static final PacketType WINDOW_ITEMS = new PacketType(PROTOCOL, SENDER, 0x15, 0x14, "WindowItems"); + public static final PacketType WINDOW_DATA = new PacketType(PROTOCOL, SENDER, 0x16, 0x15, "WindowData"); + public static final PacketType SET_SLOT = new PacketType(PROTOCOL, SENDER, 0x17, 0x16, "SetSlot"); + public static final PacketType SET_COOLDOWN = new PacketType(PROTOCOL, SENDER, 0x18, 0x17, "SetCooldown"); + public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x19, 0x18, "CustomPayload"); + public static final PacketType CUSTOM_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x19, "CustomSoundEffect"); + public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x1B, 0x1A, "KickDisconnect"); + public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1C, 0x1B, "EntityStatus"); + public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x1D, 0x1C, "Explosion"); + public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x1E, 0x1D, "UnloadChunk"); + public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x1F, 0x1E, "GameStateChange"); + public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x20, 0x1F, "KeepAlive"); + public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x21, 0x20, "MapChunk"); + public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x22, 0x21, "WorldEvent"); + public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x23, 0x22, "WorldParticles"); + public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x24, 0x23, "Login"); + public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x25, 0x24, "Map"); + public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x26, 0x25, "RelEntityMove"); + public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x27, 0x26, "RelEntityMoveLook"); + public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x28, 0x27, "EntityLook"); + public static final PacketType ENTITY = new PacketType(PROTOCOL, SENDER, 0x29, 0x28, "Entity"); + public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x2A, 0x29, "VehicleMove"); + public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x2B, 0x2A, "OpenSignEditor"); + public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x2C, 0x2B, "Abilities"); + public static final PacketType COMBAT_EVENT = new PacketType(PROTOCOL, SENDER, 0x2D, 0x2C, "CombatEvent"); + public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x2E, 0x2D, "PlayerInfo"); + public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x2F, 0x2E, "Position"); + public static final PacketType BED = new PacketType(PROTOCOL, SENDER, 0x30, 0x2F, "Bed"); + public static final PacketType RECIPES = new PacketType(PROTOCOL, SENDER, 0x31, 0x31, "Recipes"); + public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x32, 0x30, "EntityDestroy"); + public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x33, 0x31, "RemoveEntityEffect"); + public static final PacketType RESOURCE_PACK_SEND = new PacketType(PROTOCOL, SENDER, 0x34, 0x32, "ResourcePackSend"); + public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x35, 0x33, "Respawn"); + public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x36, 0x34, "EntityHeadRotation"); + public static final PacketType WORLD_BORDER = new PacketType(PROTOCOL, SENDER, 0x37, 0x35, "WorldBorder"); + public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x38, 0x36, "Camera"); + public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x39, 0x37, "HeldItemSlot"); + public static final PacketType SCOREBOARD_DISPLAY_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x3A, 0x38, "ScoreboardDisplayObjective"); + public static final PacketType ENTITY_METADATA = new PacketType(PROTOCOL, SENDER, 0x3B, 0x39, "EntityMetadata"); + public static final PacketType ATTACH_ENTITY = new PacketType(PROTOCOL, SENDER, 0x3C, 0x3A, "AttachEntity"); + public static final PacketType ENTITY_VELOCITY = new PacketType(PROTOCOL, SENDER, 0x3D, 0x3B, "EntityVelocity"); + public static final PacketType ENTITY_EQUIPMENT = new PacketType(PROTOCOL, SENDER, 0x3E, 0x3C, "EntityEquipment"); + public static final PacketType EXPERIENCE = new PacketType(PROTOCOL, SENDER, 0x3F, 0x3D, "Experience"); + public static final PacketType UPDATE_HEALTH = new PacketType(PROTOCOL, SENDER, 0x40, 0x3E, "UpdateHealth"); + public static final PacketType SCOREBOARD_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x41, 0x3F, "ScoreboardObjective"); + public static final PacketType MOUNT = new PacketType(PROTOCOL, SENDER, 0x42, 0x40, "Mount"); + public static final PacketType SCOREBOARD_TEAM = new PacketType(PROTOCOL, SENDER, 0x43, 0x41, "ScoreboardTeam"); + public static final PacketType SCOREBOARD_SCORE = new PacketType(PROTOCOL, SENDER, 0x44, 0x42, "ScoreboardScore"); + public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x45, 0x43, "SpawnPosition"); + public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x46, 0x44, "UpdateTime"); + public static final PacketType TITLE = new PacketType(PROTOCOL, SENDER, 0x47, 0x45, "Title"); + public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x48, 0x46, "NamedSoundEffect"); + public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x49, 0x47, "PlayerListHeaderFooter"); + public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x4A, 0x48, "Collect"); + public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x4B, 0x49, "EntityTeleport"); + public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x4C, 0x4A, "UpdateAttributes"); + public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4D, 0x4B, "EntityEffect"); // ---- Removed in 1.9 @@ -258,36 +260,38 @@ public class PacketType implements Serializable, Cloneable, Comparable { private final static Sender SENDER = Sender.CLIENT; - public static final PacketType TELEPORT_ACCEPT = new PacketType(PROTOCOL, SENDER, 0x00, 0xF9, "TeleportAccept"); - public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x01, 0x14, "TabComplete"); - public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x02, 0x01, "Chat"); - public static final PacketType CLIENT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x03, 0x16, "ClientCommand"); - public static final PacketType SETTINGS = new PacketType(PROTOCOL, SENDER, 0x04, 0x15, "Settings"); - public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x05, 0x0F, "Transaction"); - public static final PacketType ENCHANT_ITEM = new PacketType(PROTOCOL, SENDER, 0x06, 0x11, "EnchantItem"); - public static final PacketType WINDOW_CLICK = new PacketType(PROTOCOL, SENDER, 0x07, 0x0E, "WindowClick"); - public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x08, 0x0D, "CloseWindow"); - public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x09, 0x17, "CustomPayload"); - public static final PacketType USE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x0A, 0x02, "UseEntity"); - public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x0B, 0x00, "KeepAlive"); - public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x0C, 0x04, "Position"); - public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x0D, 0x06, "PositionLook"); - public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x0E, 0x05, "Look"); - public static final PacketType FLYING = new PacketType(PROTOCOL, SENDER, 0x0F, 0x03, "Flying"); - public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x10, 0xF8, "VehicleMove"); - public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x11, 0xF7, "BoatMove"); - public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x12, 0x13, "Abilities"); - public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x13, 0x07, "BlockDig"); - public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x14, 0x0B, "EntityAction"); - public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x15, 0x0C, "SteerVehicle"); - public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x16, 0x19, "ResourcePackStatus"); - public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x17, 0x09, "HeldItemSlot"); - public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x18, 0x10, "SetCreativeSlot"); - public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x19, 0x12, "UpdateSign"); - public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x1A, 0x0A, "ArmAnimation"); - public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x1B, 0x18, "Spectate"); - public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x1C, 0xF6, "UseItem"); - public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x1D, 0x08, "BlockPlace"); + public static final PacketType TELEPORT_ACCEPT = new PacketType(PROTOCOL, SENDER, 0x00, 0x00, "TeleportAccept"); + public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x01, 0x01, "AutoRecipe"); + public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x02, 0x01, "TabComplete"); + public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x03, 0x02, "Chat"); + public static final PacketType CLIENT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x04, 0x03, "ClientCommand"); + public static final PacketType SETTINGS = new PacketType(PROTOCOL, SENDER, 0x05, 0x04, "Settings"); + public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x06, 0x05, "Transaction"); + public static final PacketType ENCHANT_ITEM = new PacketType(PROTOCOL, SENDER, 0x07, 0x06, "EnchantItem"); + public static final PacketType WINDOW_CLICK = new PacketType(PROTOCOL, SENDER, 0x08, 0x07, "WindowClick"); + public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x09, 0x08, "CloseWindow"); + public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x0A, 0x09, "CustomPayload"); + public static final PacketType USE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x0B, 0x0A, "UseEntity"); + public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x0C, 0x0B, "KeepAlive"); + public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x0D, 0x0C, "Position"); + public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x0E, 0x0D, "PositionLook"); + public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x0F, 0x0E, "Look"); + public static final PacketType FLYING = new PacketType(PROTOCOL, SENDER, 0x10, 0x0F, "Flying"); + public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x11, 0x10, "VehicleMove"); + public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x12, 0x11, "BoatMove"); + public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x13, 0x12, "Abilities"); + public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x14, 0x13, "BlockDig"); + public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x15, 0x14, "EntityAction"); + public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x16, 0x15, "SteerVehicle"); + public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x17, 0x17, "RecipeDisplayed"); + public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x18, 0x16, "ResourcePackStatus"); + public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x19, 0x17, "HeldItemSlot"); + public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x18, "SetCreativeSlot"); + public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x1B, 0x19, "UpdateSign"); + public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x1C, 0x1A, "ArmAnimation"); + public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x1D, 0x1B, "Spectate"); + public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x1E, 0x1C, "UseItem"); + public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x1F, 0x1D, "BlockPlace"); private final static Client INSTANCE = new Client(); diff --git a/modules/API/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java b/modules/API/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java index 2048983e..e2d30292 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java +++ b/modules/API/src/main/java/com/comphenix/protocol/events/ListeningWhitelist.java @@ -238,12 +238,7 @@ public class ListeningWhitelist { if (this == EMPTY_WHITELIST) return "EMPTY_WHITELIST"; else - return Objects.toStringHelper(this). - add("priority", priority). - add("packets", types). - add("gamephase", gamePhase). - add("options", options). - toString(); + return "ListeningWhitelist[priority=" + priority + ", packets=" + types + ", gamephase=" + gamePhase + ", options=" + options + "]"; } /** 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 7cf089c1..94ba7dd0 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 @@ -74,6 +74,7 @@ import com.comphenix.protocol.wrappers.BukkitConverters; import com.comphenix.protocol.wrappers.ChunkCoordIntPair; import com.comphenix.protocol.wrappers.ChunkPosition; import com.comphenix.protocol.wrappers.EnumWrappers; +import com.comphenix.protocol.wrappers.EnumWrappers.ChatType; import com.comphenix.protocol.wrappers.EnumWrappers.ChatVisibility; import com.comphenix.protocol.wrappers.EnumWrappers.ClientCommand; import com.comphenix.protocol.wrappers.EnumWrappers.CombatEventType; @@ -955,6 +956,15 @@ public class PacketContainer implements Serializable { return structureModifier.withType( EnumWrappers.getDirectionClass(), EnumWrappers.getDirectionConverter()); } + + /** + * Retrieve a read/write structure for the ChatType enum in 1.12. + * @return A modifier for ChatType enum fields. + */ + public StructureModifier getChatTypes() { + return structureModifier.withType( + EnumWrappers.getChatTypeClass(), EnumWrappers.getChatTypeConverter()); + } /** * Retrieve a read/write structure for an enum. This allows for the use of diff --git a/modules/API/src/main/java/com/comphenix/protocol/events/ScheduledPacket.java b/modules/API/src/main/java/com/comphenix/protocol/events/ScheduledPacket.java index 25085526..cb4ddf94 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/events/ScheduledPacket.java +++ b/modules/API/src/main/java/com/comphenix/protocol/events/ScheduledPacket.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import com.comphenix.protocol.PacketStream; import com.comphenix.protocol.PacketType.Sender; import com.comphenix.protocol.ProtocolLibrary; -import com.google.common.base.Objects; import com.google.common.base.Preconditions; /** @@ -138,10 +137,6 @@ public class ScheduledPacket { @Override public String toString() { - return Objects.toStringHelper(this) - .add("packet", packet) - .add("target", target) - .add("filtered", filtered) - .toString(); + return "ScheduledPacket[packet=" + packet + ", target=" + target + ", filtered=" + filtered + "]"; } } diff --git a/modules/API/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java b/modules/API/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java index 2fd75f61..0baa8cb8 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java +++ b/modules/API/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java @@ -139,7 +139,6 @@ class SerializedOfflinePlayer implements OfflinePlayer, Serializable { return banned; } - @Override public void setBanned(boolean banned) { this.banned = banned; } diff --git a/modules/API/src/main/java/com/comphenix/protocol/injector/netty/NettyByteBufAdapter.java b/modules/API/src/main/java/com/comphenix/protocol/injector/netty/NettyByteBufAdapter.java index fbfa6932..7df96bcf 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/injector/netty/NettyByteBufAdapter.java +++ b/modules/API/src/main/java/com/comphenix/protocol/injector/netty/NettyByteBufAdapter.java @@ -28,6 +28,7 @@ import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.channels.Channels; +import java.nio.channels.FileChannel; import java.nio.channels.GatheringByteChannel; import java.nio.channels.ScatteringByteChannel; import java.nio.channels.WritableByteChannel; @@ -214,7 +215,7 @@ public class NettyByteBufAdapter extends AbstractByteBuf { @Override public ByteBufAllocator alloc() { - return null; + return ByteBufAllocator.DEFAULT; } @Override @@ -389,4 +390,48 @@ public class NettyByteBufAdapter extends AbstractByteBuf { public ByteBuf retain() { return this; } + + protected int _getIntLE(int arg0) { + return 0; + } + + protected long _getLongLE(int arg0) { + return 0; + } + + protected short _getShortLE(int arg0) { + return 0; + } + + protected int _getUnsignedMediumLE(int arg0) { + return 0; + } + + protected void _setIntLE(int arg0, int arg1) { + } + + protected void _setLongLE(int arg0, long arg1) { + } + + protected void _setMediumLE(int arg0, int arg1) { + } + + protected void _setShortLE(int arg0, int arg1) { + } + + public int getBytes(int arg0, FileChannel arg1, long arg2, int arg3) throws IOException { + return 0; + } + + public int setBytes(int arg0, FileChannel arg1, long arg2, int arg3) throws IOException { + return 0; + } + + public ByteBuf touch() { + return null; + } + + public ByteBuf touch(Object arg0) { + return null; + } } diff --git a/modules/API/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java b/modules/API/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java index 53528714..bc4872c4 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java +++ b/modules/API/src/main/java/com/comphenix/protocol/reflect/MethodInfo.java @@ -17,7 +17,6 @@ import com.google.common.collect.Lists; * * @author Kristian */ -@SuppressWarnings("unused") // Java 8 compat public abstract class MethodInfo implements GenericDeclaration, Member { /** * Wraps a method as a MethodInfo object. diff --git a/modules/API/src/main/java/com/comphenix/protocol/utility/Constants.java b/modules/API/src/main/java/com/comphenix/protocol/utility/Constants.java index bba78148..f057ea40 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/utility/Constants.java +++ b/modules/API/src/main/java/com/comphenix/protocol/utility/Constants.java @@ -21,7 +21,7 @@ package com.comphenix.protocol.utility; */ public final class Constants { - public static final String PACKAGE_VERSION = "v1_11_R1"; + public static final String PACKAGE_VERSION = "v1_12_R1"; public static final String NMS = "net.minecraft.server." + PACKAGE_VERSION; public static final String OBC = "org.bukkit.craftbukkit." + PACKAGE_VERSION; } diff --git a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java index da26572a..f2f0c46f 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java +++ b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftProtocolVersion.java @@ -44,6 +44,7 @@ public class MinecraftProtocolVersion { map.put(new MinecraftVersion(1, 10, 0), 210); map.put(new MinecraftVersion(1, 11, 0), 315); map.put(new MinecraftVersion(1, 11, 1), 316); + // 1.12 will be >= 330 return map; } diff --git a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java index be11c0e6..abb78bf6 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java +++ b/modules/API/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java @@ -44,6 +44,11 @@ public class MinecraftVersion implements Comparable, Serializa */ private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-\\.]+)\\s*\\)"); + /** + * Version 1.12 - the world of color update. + */ + public static final MinecraftVersion COLOR_UPDATE = new MinecraftVersion("1.12"); + /** * Version 1.11 - the exploration update. */ 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 21bc69d1..1a128fea 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 @@ -218,7 +218,9 @@ public abstract class EnumWrappers { END_ROD("endRod", 43, false), DAMAGE_INDICATOR("damageIndicator", 44, true), SWEEP_ATTACK("sweepAttack", 45, true), - FALLING_DUST("fallingdust", 46, true); + FALLING_DUST("fallingdust", 46, false, 1), + TOTEM("totem", 47, false), + SPIT("spit", 48, true); private static final Map BY_NAME; private static final Map BY_ID; @@ -323,12 +325,28 @@ public abstract class EnumWrappers { } public enum Direction { - DOWN(), - UP(), - NORTH(), - SOUTH(), - WEST(), - EAST(); + DOWN, + UP, + NORTH, + SOUTH, + WEST, + EAST; + } + + public enum ChatType { + CHAT(0), + SYSTEM(1), + GAME_INFO(2); + + private byte id; + + ChatType(int id) { + this.id = (byte) id; + } + + public byte getId() { + return id; + } } private static Class PROTOCOL_CLASS = null; @@ -350,6 +368,7 @@ public abstract class EnumWrappers { private static Class ITEM_SLOT_CLASS = null; private static Class HAND_CLASS = null; private static Class DIRECTION_CLASS = null; + private static Class CHAT_TYPE_CLASS = null; private static boolean INITIALIZED = false; private static Map, EquivalentConverter> FROM_NATIVE = Maps.newHashMap(); @@ -386,6 +405,7 @@ public abstract class EnumWrappers { 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); + CHAT_TYPE_CLASS = getEnum(PacketType.Play.Server.CHAT.getPacketClass(), 0); associate(PROTOCOL_CLASS, Protocol.class, getClientCommandConverter()); associate(CLIENT_COMMAND_CLASS, ClientCommand.class, getClientCommandConverter()); @@ -406,6 +426,7 @@ public abstract class EnumWrappers { associate(ITEM_SLOT_CLASS, ItemSlot.class, getItemSlotConverter()); associate(HAND_CLASS, Hand.class, getHandConverter()); associate(DIRECTION_CLASS, Direction.class, getDirectionConverter()); + associate(CHAT_TYPE_CLASS, ChatType.class, getChatTypeConverter()); INITIALIZED = true; } @@ -533,6 +554,11 @@ public abstract class EnumWrappers { initialize(); return DIRECTION_CLASS; } + + public static Class getChatTypeClass() { + initialize(); + return CHAT_TYPE_CLASS; + } // Get the converters public static EquivalentConverter getProtocolConverter() { @@ -610,6 +636,10 @@ public abstract class EnumWrappers { public static EquivalentConverter getDirectionConverter() { return new EnumConverter(Direction.class); } + + public static EquivalentConverter getChatTypeConverter() { + return new EnumConverter(ChatType.class); + } /** * Retrieve a generic enum converter for use with StructureModifiers. diff --git a/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java b/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java index ab5a8a7a..e71b3b50 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java +++ b/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedAttribute.java @@ -195,16 +195,16 @@ public class WrappedAttribute extends AbstractWrapper { if (obj instanceof WrappedAttribute) { WrappedAttribute other = (WrappedAttribute) obj; - return getBaseValue() == other.getBaseValue() && - Objects.equal(getAttributeKey(), other.getAttributeKey()) && - Sets.symmetricDifference( - getModifiers(), - other.getModifiers() - ).isEmpty(); + if (getBaseValue() == other.getBaseValue() && + Objects.equal(getAttributeKey(), other.getAttributeKey())) { + return getModifiers().stream() + .filter((elem) -> !other.getModifiers().contains(elem)) + .count() == 0; + } } return false; } - + @Override public int hashCode() { if (attributeModifiers == null) @@ -251,12 +251,7 @@ public class WrappedAttribute extends AbstractWrapper { @Override public String toString() { - return Objects.toStringHelper("WrappedAttribute"). - add("key", getAttributeKey()). - add("baseValue", getBaseValue()). - add("finalValue", getFinalValue()). - add("modifiers", getModifiers()). - toString(); + return "WrappedAttribute[key=" + getAttributeKey() + ", base=" + getBaseValue() + ", final=" + getFinalValue() + ", modifiers=" + getModifiers() + "]"; } /** diff --git a/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java b/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java index c3ebd98a..e7450869 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java +++ b/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedSignedProperty.java @@ -147,10 +147,6 @@ public class WrappedSignedProperty extends AbstractWrapper { @Override public String toString() { - return Objects.toStringHelper(this) - .add("name", getName()) - .add("value", getValue()) - .add("signature", getSignature()) - .toString(); + return "WrappedSignedProperty[name=" + getName() + ", value=" + getValue() + ", signature=" + getSignature() + "]"; } } diff --git a/modules/ProtocolLib/pom.xml b/modules/ProtocolLib/pom.xml index bcc5dccb..45c51ab0 100644 --- a/modules/ProtocolLib/pom.xml +++ b/modules/ProtocolLib/pom.xml @@ -3,7 +3,7 @@ 4.0.0 ProtocolLib ProtocolLib - 4.2.2-SNAPSHOT + 4.3.0-SNAPSHOT Provides read/write access to the Minecraft protocol. http://www.spigotmc.org/resources/protocollib.1997/ @@ -74,8 +74,8 @@ maven-compiler-plugin 3.5.1 - 1.7 - 1.7 + 1.8 + 1.8 @@ -241,13 +241,13 @@ org.spigotmc spigot-api - 1.11.2-R0.1-SNAPSHOT + ${spigotVersion} provided org.spigotmc spigot - 1.11.2-R0.1-SNAPSHOT + ${spigotVersion} provided diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java index 5d268bbc..8b66efb9 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelInjector.java @@ -16,19 +16,6 @@ */ package com.comphenix.protocol.injector.netty; -import io.netty.buffer.ByteBuf; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.ChannelPromise; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.codec.ByteToMessageDecoder; -import io.netty.handler.codec.MessageToByteEncoder; -import io.netty.util.concurrent.GenericFutureListener; -import io.netty.util.internal.TypeParameterMatcher; - import java.lang.reflect.InvocationTargetException; import java.net.Socket; import java.net.SocketAddress; @@ -55,7 +42,6 @@ import com.comphenix.protocol.events.ConnectionSide; import com.comphenix.protocol.events.NetworkMarker; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.injector.NetworkProcessor; -import com.comphenix.protocol.injector.netty.WirePacket; import com.comphenix.protocol.injector.server.SocketInjector; import com.comphenix.protocol.reflect.FuzzyReflection; import com.comphenix.protocol.reflect.VolatileField; @@ -70,6 +56,19 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.google.common.base.Preconditions; import com.google.common.collect.MapMaker; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.ChannelPromise; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.codec.ByteToMessageDecoder; +import io.netty.handler.codec.MessageToByteEncoder; +import io.netty.util.concurrent.GenericFutureListener; +import io.netty.util.internal.TypeParameterMatcher; + /** * Represents a channel injector. * @author Kristian diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelProxy.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelProxy.java index d52418f8..bb8453f5 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelProxy.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/ChannelProxy.java @@ -20,6 +20,7 @@ import io.netty.buffer.ByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelConfig; import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelId; import io.netty.channel.ChannelMetadata; import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelProgressivePromise; @@ -331,4 +332,20 @@ public abstract class ChannelProxy implements Channel { public int compareTo(Channel o) { return delegate.compareTo(o); } + + public long bytesBeforeUnwritable() { + return delegate.bytesBeforeUnwritable(); + } + + public long bytesBeforeWritable() { + return delegate.bytesBeforeWritable(); + } + + public ChannelId id() { + return delegate.id(); + } + + public boolean hasAttr(AttributeKey key) { + return delegate.hasAttr(key); + } } diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/EventLoopProxy.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/EventLoopProxy.java index 75e0d175..fe1aa7bf 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/EventLoopProxy.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/EventLoopProxy.java @@ -256,4 +256,8 @@ abstract class EventLoopProxy implements EventLoop { public List shutdownNow() { return getDelegate().shutdownNow(); } + + public ChannelFuture register(ChannelPromise promise) { + return getDelegate().register(promise); + } } diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/PipelineProxy.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/PipelineProxy.java index e49288e9..4dbbc48f 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/PipelineProxy.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/netty/PipelineProxy.java @@ -21,6 +21,7 @@ import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPipeline; +import io.netty.channel.ChannelProgressivePromise; import io.netty.channel.ChannelPromise; import io.netty.util.concurrent.EventExecutorGroup; @@ -368,4 +369,24 @@ public class PipelineProxy implements ChannelPipeline { public ChannelFuture writeAndFlush(Object arg0) { return pipeline.writeAndFlush(arg0); } + + public ChannelFuture newFailedFuture(Throwable ex) { + return pipeline.newFailedFuture(ex); + } + + public ChannelProgressivePromise newProgressivePromise() { + return pipeline.newProgressivePromise(); + } + + public ChannelPromise newPromise() { + return pipeline.newPromise(); + } + + public ChannelFuture newSucceededFuture() { + return pipeline.newSucceededFuture(); + } + + public ChannelPromise voidPromise() { + return pipeline.voidPromise(); + } } diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java index 7c626c5e..57f0c7cb 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/BukkitInitialization.java @@ -5,13 +5,13 @@ import static org.mockito.Mockito.when; import java.util.logging.Logger; -import net.minecraft.server.v1_11_R1.DispenserRegistry; +import net.minecraft.server.v1_12_R1.DispenserRegistry; import org.bukkit.Bukkit; import org.bukkit.Server; -import org.bukkit.craftbukkit.v1_11_R1.CraftServer; -import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftItemFactory; -import org.bukkit.craftbukkit.v1_11_R1.util.Versioning; +import org.bukkit.craftbukkit.v1_12_R1.CraftServer; +import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemFactory; +import org.bukkit.craftbukkit.v1_12_R1.util.Versioning; import com.comphenix.protocol.utility.Constants; import com.comphenix.protocol.utility.MinecraftReflection; @@ -52,8 +52,6 @@ public class BukkitInitialization { // Inject this fake server Bukkit.setServer(mockedServer); - - } } diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/PacketTypeTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/PacketTypeTest.java index 284143dd..3f188c8d 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/PacketTypeTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/PacketTypeTest.java @@ -22,7 +22,7 @@ import static org.junit.Assert.assertFalse; import java.util.Map; import java.util.Map.Entry; -import net.minecraft.server.v1_11_R1.PacketLoginInStart; +import net.minecraft.server.v1_12_R1.PacketLoginInStart; import org.junit.BeforeClass; import org.junit.Test; 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 1e387e5b..23c50a34 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 @@ -29,15 +29,15 @@ import java.util.List; import java.util.Objects; import java.util.UUID; -import net.minecraft.server.v1_11_R1.AttributeModifier; -import net.minecraft.server.v1_11_R1.DataWatcher; -import net.minecraft.server.v1_11_R1.Entity; -import net.minecraft.server.v1_11_R1.EntityLightning; -import net.minecraft.server.v1_11_R1.MobEffect; -import net.minecraft.server.v1_11_R1.MobEffectList; -import net.minecraft.server.v1_11_R1.PacketPlayOutBoss; -import net.minecraft.server.v1_11_R1.PacketPlayOutUpdateAttributes; -import net.minecraft.server.v1_11_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot; +import net.minecraft.server.v1_12_R1.AttributeModifier; +import net.minecraft.server.v1_12_R1.DataWatcher; +import net.minecraft.server.v1_12_R1.Entity; +import net.minecraft.server.v1_12_R1.EntityLightning; +import net.minecraft.server.v1_12_R1.MobEffect; +import net.minecraft.server.v1_12_R1.MobEffectList; +import net.minecraft.server.v1_12_R1.PacketPlayOutBoss; +import net.minecraft.server.v1_12_R1.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_12_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot; import org.apache.commons.lang.SerializationUtils; import org.apache.commons.lang3.builder.EqualsBuilder; diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/injector/WirePacketTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/injector/WirePacketTest.java index 4cf9bed0..0ca8fafb 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/injector/WirePacketTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/injector/WirePacketTest.java @@ -13,6 +13,7 @@ import com.comphenix.protocol.BukkitInitialization; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.injector.netty.WirePacket; +import com.comphenix.protocol.wrappers.EnumWrappers.ChatType; import io.netty.buffer.ByteBuf; @@ -29,6 +30,8 @@ public class WirePacketTest { @Test public void testPackets() { PacketContainer packet = new PacketContainer(PacketType.Play.Server.CHAT); + packet.getChatTypes().write(0, ChatType.CHAT); + WirePacket wire = WirePacket.fromPacket(packet); WirePacket handle = WirePacket.fromPacket(packet.getHandle()); assertEquals(wire, handle); diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/reflect/cloning/AggregateClonerTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/reflect/cloning/AggregateClonerTest.java index 023ae549..3c036f4c 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/reflect/cloning/AggregateClonerTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/reflect/cloning/AggregateClonerTest.java @@ -1,13 +1,13 @@ package com.comphenix.protocol.reflect.cloning; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; import java.util.Arrays; import java.util.List; -import net.minecraft.server.v1_11_R1.ItemStack; -import net.minecraft.server.v1_11_R1.NonNullList; +import net.minecraft.server.v1_12_R1.ItemStack; +import net.minecraft.server.v1_12_R1.NonNullList; import org.junit.BeforeClass; import org.junit.Test; diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java index 9aeef5b8..b8b1b418 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java @@ -5,18 +5,18 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import net.minecraft.server.v1_11_R1.ChatComponentText; -import net.minecraft.server.v1_11_R1.ChunkCoordIntPair; -import net.minecraft.server.v1_11_R1.DataWatcher; -import net.minecraft.server.v1_11_R1.IBlockData; -import net.minecraft.server.v1_11_R1.IChatBaseComponent; -import net.minecraft.server.v1_11_R1.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_11_R1.NBTCompressedStreamTools; -import net.minecraft.server.v1_11_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot; -import net.minecraft.server.v1_11_R1.PlayerConnection; -import net.minecraft.server.v1_11_R1.ServerPing; -import net.minecraft.server.v1_11_R1.ServerPing.ServerData; -import net.minecraft.server.v1_11_R1.ServerPing.ServerPingPlayerSample; +import net.minecraft.server.v1_12_R1.ChatComponentText; +import net.minecraft.server.v1_12_R1.ChunkCoordIntPair; +import net.minecraft.server.v1_12_R1.DataWatcher; +import net.minecraft.server.v1_12_R1.IBlockData; +import net.minecraft.server.v1_12_R1.IChatBaseComponent; +import net.minecraft.server.v1_12_R1.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_12_R1.NBTCompressedStreamTools; +import net.minecraft.server.v1_12_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot; +import net.minecraft.server.v1_12_R1.PlayerConnection; +import net.minecraft.server.v1_12_R1.ServerPing; +import net.minecraft.server.v1_12_R1.ServerPing.ServerData; +import net.minecraft.server.v1_12_R1.ServerPing.ServerPingPlayerSample; import org.bukkit.Material; import org.bukkit.block.Block; diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java index 03938de8..81983956 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/utility/StreamSerializerTest.java @@ -8,7 +8,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.minecraft.server.v1_11_R1.IntHashMap; +import net.minecraft.server.v1_12_R1.IntHashMap; import org.bukkit.ChatColor; import org.bukkit.DyeColor; diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java index 1e9ec3ff..d7561716 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/ChunkCoordIntPairTest.java @@ -16,15 +16,15 @@ public class ChunkCoordIntPairTest { @Test public void test() { - net.minecraft.server.v1_11_R1.ChunkCoordIntPair pair = new net.minecraft.server.v1_11_R1.ChunkCoordIntPair(1, 2); + net.minecraft.server.v1_12_R1.ChunkCoordIntPair pair = new net.minecraft.server.v1_12_R1.ChunkCoordIntPair(1, 2); ChunkCoordIntPair specific = ChunkCoordIntPair.getConverter().getSpecific(pair); assertEquals(1, specific.getChunkX()); assertEquals(2, specific.getChunkZ()); - net.minecraft.server.v1_11_R1.ChunkCoordIntPair roundtrip = - (net.minecraft.server.v1_11_R1.ChunkCoordIntPair) ChunkCoordIntPair.getConverter(). - getGeneric(net.minecraft.server.v1_11_R1.ChunkCoordIntPair.class, specific); + net.minecraft.server.v1_12_R1.ChunkCoordIntPair roundtrip = + (net.minecraft.server.v1_12_R1.ChunkCoordIntPair) ChunkCoordIntPair.getConverter(). + getGeneric(net.minecraft.server.v1_12_R1.ChunkCoordIntPair.class, specific); assertEquals(1, roundtrip.x); assertEquals(2, roundtrip.z); diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java index 9b1b530d..af9e27fb 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/EnumWrappersTest.java @@ -2,12 +2,12 @@ package com.comphenix.protocol.wrappers; import static org.junit.Assert.assertEquals; -import net.minecraft.server.v1_11_R1.EntityHuman.EnumChatVisibility; -import net.minecraft.server.v1_11_R1.EnumDifficulty; -import net.minecraft.server.v1_11_R1.EnumGamemode; -import net.minecraft.server.v1_11_R1.EnumProtocol; -import net.minecraft.server.v1_11_R1.PacketPlayInClientCommand.EnumClientCommand; -import net.minecraft.server.v1_11_R1.PacketPlayInUseEntity.EnumEntityUseAction; +import net.minecraft.server.v1_12_R1.EntityHuman.EnumChatVisibility; +import net.minecraft.server.v1_12_R1.EnumDifficulty; +import net.minecraft.server.v1_12_R1.EnumGamemode; +import net.minecraft.server.v1_12_R1.EnumProtocol; +import net.minecraft.server.v1_12_R1.PacketPlayInClientCommand.EnumClientCommand; +import net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.EnumEntityUseAction; import org.junit.BeforeClass; import org.junit.Test; diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java index cc694c29..39fb72cc 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedAttributeTest.java @@ -6,9 +6,9 @@ import static org.junit.Assert.assertTrue; import java.util.List; -import net.minecraft.server.v1_11_R1.AttributeModifier; -import net.minecraft.server.v1_11_R1.PacketPlayOutUpdateAttributes; -import net.minecraft.server.v1_11_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot; +import net.minecraft.server.v1_12_R1.AttributeModifier; +import net.minecraft.server.v1_12_R1.PacketPlayOutUpdateAttributes; +import net.minecraft.server.v1_12_R1.PacketPlayOutUpdateAttributes.AttributeSnapshot; import org.junit.Before; import org.junit.BeforeClass; diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java index 551e3613..7c142e25 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedDataWatcherTest.java @@ -23,9 +23,9 @@ import static org.junit.Assert.assertTrue; import java.util.UUID; -import net.minecraft.server.v1_11_R1.EntityLightning; +import net.minecraft.server.v1_12_R1.EntityLightning; -import org.bukkit.craftbukkit.v1_11_R1.entity.CraftLightningStrike; +import org.bukkit.craftbukkit.v1_12_R1.entity.CraftLightningStrike; import org.bukkit.entity.Entity; import org.junit.BeforeClass; import org.junit.Test; @@ -90,8 +90,8 @@ public class WrappedDataWatcherTest { @Test public void testSerializers() { - Serializer blockPos = Registry.get(net.minecraft.server.v1_11_R1.BlockPosition.class, false); - Serializer optionalBlockPos = Registry.get(net.minecraft.server.v1_11_R1.BlockPosition.class, true); + Serializer blockPos = Registry.get(net.minecraft.server.v1_12_R1.BlockPosition.class, false); + Serializer optionalBlockPos = Registry.get(net.minecraft.server.v1_12_R1.BlockPosition.class, true); assertNotSame(blockPos, optionalBlockPos); // assertNull(Registry.get(ItemStack.class, false)); diff --git a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java index b50ff318..233a03cb 100644 --- a/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java +++ b/modules/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/nbt/NbtFactoryTest.java @@ -26,8 +26,8 @@ import java.io.DataInputStream; import java.io.DataOutput; import java.io.DataOutputStream; -import net.minecraft.server.v1_11_R1.ItemStack; -import net.minecraft.server.v1_11_R1.Items; +import net.minecraft.server.v1_12_R1.ItemStack; +import net.minecraft.server.v1_12_R1.Items; import org.junit.BeforeClass; import org.junit.Test; diff --git a/pom.xml b/pom.xml index b2a647fa..54f58ff5 100644 --- a/pom.xml +++ b/pom.xml @@ -8,6 +8,7 @@ UTF-8 + 1.12-pre2-SNAPSHOT