Better ensure packet types are correct, deprecate legacy IDs
Dieser Commit ist enthalten in:
Ursprung
123abdff30
Commit
ea7900d64f
@ -37,7 +37,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an unknown legacy packet ID.
|
* Represents an unknown packet ID.
|
||||||
*/
|
*/
|
||||||
public static final int UNKNOWN_PACKET = -1;
|
public static final int UNKNOWN_PACKET = -1;
|
||||||
|
|
||||||
@ -106,85 +106,85 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
public static class Server extends ObjectEnum<PacketType> {
|
public static class Server extends ObjectEnum<PacketType> {
|
||||||
private final static Sender SENDER = Sender.SERVER;
|
private final static Sender SENDER = Sender.SERVER;
|
||||||
|
|
||||||
public static final PacketType SPAWN_ENTITY = new PacketType(PROTOCOL, SENDER, 0x00, 0x00, "SpawnEntity");
|
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, 0x01, "SpawnEntityExperienceOrb");
|
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, 0x02, "SpawnEntityWeather");
|
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, 0x03, "SpawnEntityLiving");
|
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, 0x04, "SpawnEntityPainting");
|
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, 0x05, "NamedEntitySpawn");
|
public static final PacketType NAMED_ENTITY_SPAWN = new PacketType(PROTOCOL, SENDER, 0x05, 0x0C, "NamedEntitySpawn");
|
||||||
public static final PacketType ANIMATION = new PacketType(PROTOCOL, SENDER, 0x06, 0x06, "Animation");
|
public static final PacketType ANIMATION = new PacketType(PROTOCOL, SENDER, 0x06, 0x0B, "Animation");
|
||||||
public static final PacketType STATISTIC = new PacketType(PROTOCOL, SENDER, 0x07, 0x07, "Statistic");
|
public static final PacketType STATISTIC = new PacketType(PROTOCOL, SENDER, 0x07, 0x37, "Statistic");
|
||||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x08, 0x08, "Advancements");
|
public static final PacketType BLOCK_BREAK_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x08, 0x25, "BlockBreakAnimation");
|
||||||
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, 0x09, 0x35, "TileEntityData");
|
||||||
public static final PacketType TILE_ENTITY_DATA = new PacketType(PROTOCOL, SENDER, 0x0A, 0x09, "TileEntityData");
|
public static final PacketType BLOCK_ACTION = new PacketType(PROTOCOL, SENDER, 0x0A, 0x24, "BlockAction");
|
||||||
public static final PacketType BLOCK_ACTION = new PacketType(PROTOCOL, SENDER, 0x0B, 0x0A, "BlockAction");
|
public static final PacketType BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x0B, 0x23, "BlockChange");
|
||||||
public static final PacketType BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x0C, 0x0B, "BlockChange");
|
public static final PacketType BOSS = new PacketType(PROTOCOL, SENDER, 0x0C, 0xFF, "Boss");
|
||||||
public static final PacketType BOSS = new PacketType(PROTOCOL, SENDER, 0x0D, 0x0C, "Boss");
|
public static final PacketType SERVER_DIFFICULTY = new PacketType(PROTOCOL, SENDER, 0x0D, 0x41, "ServerDifficulty");
|
||||||
public static final PacketType SERVER_DIFFICULTY = new PacketType(PROTOCOL, SENDER, 0x0E, 0x0D, "ServerDifficulty");
|
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0E, 0x3A, "TabComplete");
|
||||||
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x0F, 0x0E, "TabComplete");
|
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x0F, 0x02, "Chat");
|
||||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x10, 0x0F, "Chat");
|
public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x10, 0x22, "MultiBlockChange");
|
||||||
public static final PacketType MULTI_BLOCK_CHANGE = new PacketType(PROTOCOL, SENDER, 0x11, 0x10, "MultiBlockChange");
|
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x11, 0x32, "Transaction");
|
||||||
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x12, 0x11, "Transaction");
|
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x12, 0x2E, "CloseWindow");
|
||||||
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x13, 0x12, "CloseWindow");
|
public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x13, 0x2D, "OpenWindow");
|
||||||
public static final PacketType OPEN_WINDOW = new PacketType(PROTOCOL, SENDER, 0x14, 0x13, "OpenWindow");
|
public static final PacketType WINDOW_ITEMS = new PacketType(PROTOCOL, SENDER, 0x14, 0x30, "WindowItems");
|
||||||
public static final PacketType WINDOW_ITEMS = new PacketType(PROTOCOL, SENDER, 0x15, 0x14, "WindowItems");
|
public static final PacketType WINDOW_DATA = new PacketType(PROTOCOL, SENDER, 0x15, 0x31, "WindowData");
|
||||||
public static final PacketType WINDOW_DATA = new PacketType(PROTOCOL, SENDER, 0x16, 0x15, "WindowData");
|
public static final PacketType SET_SLOT = new PacketType(PROTOCOL, SENDER, 0x16, 0x2F, "SetSlot");
|
||||||
public static final PacketType SET_SLOT = new PacketType(PROTOCOL, SENDER, 0x17, 0x16, "SetSlot");
|
public static final PacketType SET_COOLDOWN = new PacketType(PROTOCOL, SENDER, 0x17, 0xFC, "SetCooldown");
|
||||||
public static final PacketType SET_COOLDOWN = new PacketType(PROTOCOL, SENDER, 0x18, 0x17, "SetCooldown");
|
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x18, 0x3F, "CustomPayload");
|
||||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x19, 0x18, "CustomPayload");
|
public static final PacketType CUSTOM_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x19, 0xFD, "CustomSoundEffect");
|
||||||
public static final PacketType CUSTOM_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x19, "CustomSoundEffect");
|
public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x40, "KickDisconnect");
|
||||||
public static final PacketType KICK_DISCONNECT = new PacketType(PROTOCOL, SENDER, 0x1B, 0x1A, "KickDisconnect");
|
public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1B, 0x1A, "EntityStatus");
|
||||||
public static final PacketType ENTITY_STATUS = new PacketType(PROTOCOL, SENDER, 0x1C, 0x1B, "EntityStatus");
|
public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x1C, 0x27, "Explosion");
|
||||||
public static final PacketType EXPLOSION = new PacketType(PROTOCOL, SENDER, 0x1D, 0x1C, "Explosion");
|
public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x1D, 0xFA, "UnloadChunk");
|
||||||
public static final PacketType UNLOAD_CHUNK = new PacketType(PROTOCOL, SENDER, 0x1E, 0x1D, "UnloadChunk");
|
public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x1E, 0x2B, "GameStateChange");
|
||||||
public static final PacketType GAME_STATE_CHANGE = new PacketType(PROTOCOL, SENDER, 0x1F, 0x1E, "GameStateChange");
|
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x1F, 0x00, "KeepAlive");
|
||||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x20, 0x1F, "KeepAlive");
|
public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x20, 0x21, "MapChunk");
|
||||||
public static final PacketType MAP_CHUNK = new PacketType(PROTOCOL, SENDER, 0x21, 0x20, "MapChunk");
|
public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x21, 0x28, "WorldEvent");
|
||||||
public static final PacketType WORLD_EVENT = new PacketType(PROTOCOL, SENDER, 0x22, 0x21, "WorldEvent");
|
public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x22, 0x2A, "WorldParticles");
|
||||||
public static final PacketType WORLD_PARTICLES = new PacketType(PROTOCOL, SENDER, 0x23, 0x22, "WorldParticles");
|
public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x23, 0x01, "Login");
|
||||||
public static final PacketType LOGIN = new PacketType(PROTOCOL, SENDER, 0x24, 0x23, "Login");
|
public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x24, 0x34, "Map");
|
||||||
public static final PacketType MAP = new PacketType(PROTOCOL, SENDER, 0x25, 0x24, "Map");
|
public static final PacketType ENTITY = new PacketType(PROTOCOL, SENDER, 0x25, 0x14, "Entity");
|
||||||
public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x26, 0x25, "RelEntityMove");
|
public static final PacketType REL_ENTITY_MOVE = new PacketType(PROTOCOL, SENDER, 0x26, 0x15, "RelEntityMove");
|
||||||
public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x27, 0x26, "RelEntityMoveLook");
|
public static final PacketType REL_ENTITY_MOVE_LOOK = new PacketType(PROTOCOL, SENDER, 0x27, 0x17, "RelEntityMoveLook");
|
||||||
public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x28, 0x27, "EntityLook");
|
public static final PacketType ENTITY_LOOK = new PacketType(PROTOCOL, SENDER, 0x28, 0x16, "EntityLook");
|
||||||
public static final PacketType ENTITY = new PacketType(PROTOCOL, SENDER, 0x29, 0x28, "Entity");
|
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x29, 0xFE, "VehicleMove");
|
||||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x2A, 0x29, "VehicleMove");
|
public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x2A, 0x36, "OpenSignEditor");
|
||||||
public static final PacketType OPEN_SIGN_EDITOR = new PacketType(PROTOCOL, SENDER, 0x2B, 0x2A, "OpenSignEditor");
|
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x2B, 0x39, "Abilities");
|
||||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x2C, 0x2B, "Abilities");
|
public static final PacketType COMBAT_EVENT = new PacketType(PROTOCOL, SENDER, 0x2C, 0x42, "CombatEvent");
|
||||||
public static final PacketType COMBAT_EVENT = new PacketType(PROTOCOL, SENDER, 0x2D, 0x2C, "CombatEvent");
|
public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x2D, 0x38, "PlayerInfo");
|
||||||
public static final PacketType PLAYER_INFO = new PacketType(PROTOCOL, SENDER, 0x2E, 0x2D, "PlayerInfo");
|
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x2E, 0x08, "Position");
|
||||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x2F, 0x2E, "Position");
|
public static final PacketType BED = new PacketType(PROTOCOL, SENDER, 0x2F, 0x0A, "Bed");
|
||||||
public static final PacketType BED = new PacketType(PROTOCOL, SENDER, 0x30, 0x2F, "Bed");
|
public static final PacketType RECIPES = new PacketType(PROTOCOL, SENDER, 0x30, -1, "Recipes");
|
||||||
public static final PacketType RECIPES = new PacketType(PROTOCOL, SENDER, 0x31, 0x31, "Recipes");
|
public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x31, 0x13, "EntityDestroy");
|
||||||
public static final PacketType ENTITY_DESTROY = new PacketType(PROTOCOL, SENDER, 0x32, 0x30, "EntityDestroy");
|
public static final PacketType REMOVE_ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x32, 0x1E, "RemoveEntityEffect");
|
||||||
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, 0x33, 0x48, "ResourcePackSend");
|
||||||
public static final PacketType RESOURCE_PACK_SEND = new PacketType(PROTOCOL, SENDER, 0x34, 0x32, "ResourcePackSend");
|
public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x34, 0x07, "Respawn");
|
||||||
public static final PacketType RESPAWN = new PacketType(PROTOCOL, SENDER, 0x35, 0x33, "Respawn");
|
public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x35, 0x19, "EntityHeadRotation");
|
||||||
public static final PacketType ENTITY_HEAD_ROTATION = new PacketType(PROTOCOL, SENDER, 0x36, 0x34, "EntityHeadRotation");
|
public static final PacketType SELECT_ADVANCEMENT_TAB = new PacketType(PROTOCOL, SENDER, 0x36, -1, "SelectAdvancementTab");
|
||||||
public static final PacketType SELECT_ADVANCEMENT_TAB = new PacketType(PROTOCOL, SENDER, 0x37, -1, "SelectAdvancementTab");
|
public static final PacketType WORLD_BORDER = new PacketType(PROTOCOL, SENDER, 0x37, 0x44, "WorldBorder");
|
||||||
public static final PacketType WORLD_BORDER = new PacketType(PROTOCOL, SENDER, 0x38, 0x35, "WorldBorder");
|
public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x38, 0x43, "Camera");
|
||||||
public static final PacketType CAMERA = new PacketType(PROTOCOL, SENDER, 0x39, 0x36, "Camera");
|
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x39, 0x09, "HeldItemSlot");
|
||||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x3A, 0x37, "HeldItemSlot");
|
public static final PacketType SCOREBOARD_DISPLAY_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x3A, 0x3D, "ScoreboardDisplayObjective");
|
||||||
public static final PacketType SCOREBOARD_DISPLAY_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x3B, 0x38, "ScoreboardDisplayObjective");
|
public static final PacketType ENTITY_METADATA = new PacketType(PROTOCOL, SENDER, 0x3B, 0x1C, "EntityMetadata");
|
||||||
public static final PacketType ENTITY_METADATA = new PacketType(PROTOCOL, SENDER, 0x3C, 0x39, "EntityMetadata");
|
public static final PacketType ATTACH_ENTITY = new PacketType(PROTOCOL, SENDER, 0x3C, 0x1B, "AttachEntity");
|
||||||
public static final PacketType ATTACH_ENTITY = new PacketType(PROTOCOL, SENDER, 0x3D, 0x3A, "AttachEntity");
|
public static final PacketType ENTITY_VELOCITY = new PacketType(PROTOCOL, SENDER, 0x3D, 0x12, "EntityVelocity");
|
||||||
public static final PacketType ENTITY_VELOCITY = new PacketType(PROTOCOL, SENDER, 0x3E, 0x3B, "EntityVelocity");
|
public static final PacketType ENTITY_EQUIPMENT = new PacketType(PROTOCOL, SENDER, 0x3E, 0x04, "EntityEquipment");
|
||||||
public static final PacketType ENTITY_EQUIPMENT = new PacketType(PROTOCOL, SENDER, 0x3F, 0x3C, "EntityEquipment");
|
public static final PacketType EXPERIENCE = new PacketType(PROTOCOL, SENDER, 0x3F, 0x1F, "Experience");
|
||||||
public static final PacketType EXPERIENCE = new PacketType(PROTOCOL, SENDER, 0x40, 0x3D, "Experience");
|
public static final PacketType UPDATE_HEALTH = new PacketType(PROTOCOL, SENDER, 0x40, 0x06, "UpdateHealth");
|
||||||
public static final PacketType UPDATE_HEALTH = new PacketType(PROTOCOL, SENDER, 0x41, 0x3E, "UpdateHealth");
|
public static final PacketType SCOREBOARD_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x41, 0x3B, "ScoreboardObjective");
|
||||||
public static final PacketType SCOREBOARD_OBJECTIVE = new PacketType(PROTOCOL, SENDER, 0x42, 0x3F, "ScoreboardObjective");
|
public static final PacketType MOUNT = new PacketType(PROTOCOL, SENDER, 0x42, 0xFB, "Mount");
|
||||||
public static final PacketType MOUNT = new PacketType(PROTOCOL, SENDER, 0x43, 0x40, "Mount");
|
public static final PacketType SCOREBOARD_TEAM = new PacketType(PROTOCOL, SENDER, 0x43, 0x3E, "ScoreboardTeam");
|
||||||
public static final PacketType SCOREBOARD_TEAM = new PacketType(PROTOCOL, SENDER, 0x44, 0x41, "ScoreboardTeam");
|
public static final PacketType SCOREBOARD_SCORE = new PacketType(PROTOCOL, SENDER, 0x44, 0x3C, "ScoreboardScore");
|
||||||
public static final PacketType SCOREBOARD_SCORE = new PacketType(PROTOCOL, SENDER, 0x45, 0x42, "ScoreboardScore");
|
public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x45, 0x05, "SpawnPosition");
|
||||||
public static final PacketType SPAWN_POSITION = new PacketType(PROTOCOL, SENDER, 0x46, 0x43, "SpawnPosition");
|
public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x46, 0x03, "UpdateTime");
|
||||||
public static final PacketType UPDATE_TIME = new PacketType(PROTOCOL, SENDER, 0x47, 0x44, "UpdateTime");
|
public static final PacketType TITLE = new PacketType(PROTOCOL, SENDER, 0x47, 0x45, "Title");
|
||||||
public static final PacketType TITLE = new PacketType(PROTOCOL, SENDER, 0x48, 0x45, "Title");
|
public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x48, 0x29, "NamedSoundEffect");
|
||||||
public static final PacketType NAMED_SOUND_EFFECT = new PacketType(PROTOCOL, SENDER, 0x49, 0x46, "NamedSoundEffect");
|
public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x49, 0x47, "PlayerListHeaderFooter");
|
||||||
public static final PacketType PLAYER_LIST_HEADER_FOOTER = new PacketType(PROTOCOL, SENDER, 0x4A, 0x47, "PlayerListHeaderFooter");
|
public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x4A, 0x0D, "Collect");
|
||||||
public static final PacketType COLLECT = new PacketType(PROTOCOL, SENDER, 0x4B, 0x48, "Collect");
|
public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x4B, 0x18, "EntityTeleport");
|
||||||
public static final PacketType ENTITY_TELEPORT = new PacketType(PROTOCOL, SENDER, 0x4C, 0x49, "EntityTeleport");
|
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x4C, -1, "Advancements");
|
||||||
public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x4D, 0x4A, "UpdateAttributes");
|
public static final PacketType UPDATE_ATTRIBUTES = new PacketType(PROTOCOL, SENDER, 0x4D, 0x20, "UpdateAttributes");
|
||||||
public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4E, 0x4B, "EntityEffect");
|
public static final PacketType ENTITY_EFFECT = new PacketType(PROTOCOL, SENDER, 0x4E, 0x1D, "EntityEffect");
|
||||||
|
|
||||||
// ---- Removed in 1.9
|
// ---- Removed in 1.9
|
||||||
|
|
||||||
@ -261,39 +261,39 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
public static class Client extends ObjectEnum<PacketType> {
|
public static class Client extends ObjectEnum<PacketType> {
|
||||||
private final static Sender SENDER = Sender.CLIENT;
|
private final static Sender SENDER = Sender.CLIENT;
|
||||||
|
|
||||||
public static final PacketType TELEPORT_ACCEPT = new PacketType(PROTOCOL, SENDER, 0x00, 0x00, "TeleportAccept");
|
public static final PacketType TELEPORT_ACCEPT = new PacketType(PROTOCOL, SENDER, 0x00, 0xF9, "TeleportAccept");
|
||||||
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x01, 0x01, "AutoRecipe");
|
public static final PacketType AUTO_RECIPE = new PacketType(PROTOCOL, SENDER, 0x01, -1, "AutoRecipe");
|
||||||
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x02, 0x01, "TabComplete");
|
public static final PacketType TAB_COMPLETE = new PacketType(PROTOCOL, SENDER, 0x02, 0x14, "TabComplete");
|
||||||
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x03, 0x02, "Chat");
|
public static final PacketType CHAT = new PacketType(PROTOCOL, SENDER, 0x03, 0x01, "Chat");
|
||||||
public static final PacketType CLIENT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x04, 0x03, "ClientCommand");
|
public static final PacketType CLIENT_COMMAND = new PacketType(PROTOCOL, SENDER, 0x04, 0x16, "ClientCommand");
|
||||||
public static final PacketType SETTINGS = new PacketType(PROTOCOL, SENDER, 0x05, 0x04, "Settings");
|
public static final PacketType SETTINGS = new PacketType(PROTOCOL, SENDER, 0x05, 0x15, "Settings");
|
||||||
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x06, 0x05, "Transaction");
|
public static final PacketType TRANSACTION = new PacketType(PROTOCOL, SENDER, 0x06, 0x0F, "Transaction");
|
||||||
public static final PacketType ENCHANT_ITEM = new PacketType(PROTOCOL, SENDER, 0x07, 0x06, "EnchantItem");
|
public static final PacketType ENCHANT_ITEM = new PacketType(PROTOCOL, SENDER, 0x07, 0x11, "EnchantItem");
|
||||||
public static final PacketType WINDOW_CLICK = new PacketType(PROTOCOL, SENDER, 0x08, 0x07, "WindowClick");
|
public static final PacketType WINDOW_CLICK = new PacketType(PROTOCOL, SENDER, 0x08, 0x0E, "WindowClick");
|
||||||
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x09, 0x08, "CloseWindow");
|
public static final PacketType CLOSE_WINDOW = new PacketType(PROTOCOL, SENDER, 0x09, 0x0D, "CloseWindow");
|
||||||
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x0A, 0x09, "CustomPayload");
|
public static final PacketType CUSTOM_PAYLOAD = new PacketType(PROTOCOL, SENDER, 0x0A, 0x17, "CustomPayload");
|
||||||
public static final PacketType USE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x0B, 0x0A, "UseEntity");
|
public static final PacketType USE_ENTITY = new PacketType(PROTOCOL, SENDER, 0x0B, 0x02, "UseEntity");
|
||||||
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x0C, 0x0B, "KeepAlive");
|
public static final PacketType KEEP_ALIVE = new PacketType(PROTOCOL, SENDER, 0x0C, 0x00, "KeepAlive");
|
||||||
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x0D, 0x0C, "Position");
|
public static final PacketType FLYING = new PacketType(PROTOCOL, SENDER, 0x0D, 0x03, "Flying");
|
||||||
public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x0E, 0x0D, "PositionLook");
|
public static final PacketType POSITION = new PacketType(PROTOCOL, SENDER, 0x0E, 0x04, "Position");
|
||||||
public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x0F, 0x0E, "Look");
|
public static final PacketType POSITION_LOOK = new PacketType(PROTOCOL, SENDER, 0x0F, 0x06, "PositionLook");
|
||||||
public static final PacketType FLYING = new PacketType(PROTOCOL, SENDER, 0x10, 0x0F, "Flying");
|
public static final PacketType LOOK = new PacketType(PROTOCOL, SENDER, 0x10, 0x05, "Look");
|
||||||
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x11, 0x10, "VehicleMove");
|
public static final PacketType VEHICLE_MOVE = new PacketType(PROTOCOL, SENDER, 0x11, 0xF8, "VehicleMove");
|
||||||
public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x12, 0x11, "BoatMove");
|
public static final PacketType BOAT_MOVE = new PacketType(PROTOCOL, SENDER, 0x12, 0xF7, "BoatMove");
|
||||||
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x13, 0x12, "Abilities");
|
public static final PacketType ABILITIES = new PacketType(PROTOCOL, SENDER, 0x13, 0x13, "Abilities");
|
||||||
public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x14, 0x13, "BlockDig");
|
public static final PacketType BLOCK_DIG = new PacketType(PROTOCOL, SENDER, 0x14, 0x07, "BlockDig");
|
||||||
public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x15, 0x14, "EntityAction");
|
public static final PacketType ENTITY_ACTION = new PacketType(PROTOCOL, SENDER, 0x15, 0x0B, "EntityAction");
|
||||||
public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x16, 0x15, "SteerVehicle");
|
public static final PacketType STEER_VEHICLE = new PacketType(PROTOCOL, SENDER, 0x16, 0x0C, "SteerVehicle");
|
||||||
public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x17, 0x17, "RecipeDisplayed");
|
public static final PacketType RECIPE_DISPLAYED = new PacketType(PROTOCOL, SENDER, 0x17, -1, "RecipeDisplayed");
|
||||||
public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x18, 0x16, "ResourcePackStatus");
|
public static final PacketType RESOURCE_PACK_STATUS = new PacketType(PROTOCOL, SENDER, 0x18, 0x19, "ResourcePackStatus");
|
||||||
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x19, -1, "Advancements");
|
public static final PacketType ADVANCEMENTS = new PacketType(PROTOCOL, SENDER, 0x19, -1, "Advancements");
|
||||||
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x17, "HeldItemSlot");
|
public static final PacketType HELD_ITEM_SLOT = new PacketType(PROTOCOL, SENDER, 0x1A, 0x09, "HeldItemSlot");
|
||||||
public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x1B, 0x18, "SetCreativeSlot");
|
public static final PacketType SET_CREATIVE_SLOT = new PacketType(PROTOCOL, SENDER, 0x1B, 0x10, "SetCreativeSlot");
|
||||||
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x1C, 0x19, "UpdateSign");
|
public static final PacketType UPDATE_SIGN = new PacketType(PROTOCOL, SENDER, 0x1C, 0x12, "UpdateSign");
|
||||||
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x1D, 0x1A, "ArmAnimation");
|
public static final PacketType ARM_ANIMATION = new PacketType(PROTOCOL, SENDER, 0x1D, 0x0A, "ArmAnimation");
|
||||||
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x1E, 0x1B, "Spectate");
|
public static final PacketType SPECTATE = new PacketType(PROTOCOL, SENDER, 0x1E, 0x18, "Spectate");
|
||||||
public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x1F, 0x1C, "UseItem");
|
public static final PacketType USE_ITEM = new PacketType(PROTOCOL, SENDER, 0x1F, 0xF6, "UseItem");
|
||||||
public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x20, 0x1D, "BlockPlace");
|
public static final PacketType BLOCK_PLACE = new PacketType(PROTOCOL, SENDER, 0x20, 0x08, "BlockPlace");
|
||||||
|
|
||||||
private final static Client INSTANCE = new Client();
|
private final static Client INSTANCE = new Client();
|
||||||
|
|
||||||
@ -650,7 +650,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* @param packetId - the legacy packet ID.
|
* @param packetId - the legacy packet ID.
|
||||||
* @return The corresponding packet type.
|
* @return The corresponding packet type.
|
||||||
* @throws IllegalArgumentException If the legacy packet could not be found.
|
* @throws IllegalArgumentException If the legacy packet could not be found.
|
||||||
|
* @deprecated Legacy IDs haven't functioned properly for some time
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static PacketType findLegacy(int packetId) {
|
public static PacketType findLegacy(int packetId) {
|
||||||
PacketType type = getLookup().getFromLegacy(packetId);
|
PacketType type = getLookup().getFromLegacy(packetId);
|
||||||
|
|
||||||
@ -665,7 +667,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* @param preference - the preferred sender, or NULL for any arbitrary sender.
|
* @param preference - the preferred sender, or NULL for any arbitrary sender.
|
||||||
* @return The corresponding packet type.
|
* @return The corresponding packet type.
|
||||||
* @throws IllegalArgumentException If the legacy packet could not be found.
|
* @throws IllegalArgumentException If the legacy packet could not be found.
|
||||||
|
* @deprecated Legacy IDs haven't functioned properly for some time
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static PacketType findLegacy(int packetId, Sender preference) {
|
public static PacketType findLegacy(int packetId, Sender preference) {
|
||||||
if (preference == null)
|
if (preference == null)
|
||||||
return findLegacy(packetId);
|
return findLegacy(packetId);
|
||||||
@ -680,7 +684,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* Determine if the given legacy packet exists.
|
* Determine if the given legacy packet exists.
|
||||||
* @param packetId - the legacy packet ID.
|
* @param packetId - the legacy packet ID.
|
||||||
* @return TRUE if it does, FALSE otherwise.
|
* @return TRUE if it does, FALSE otherwise.
|
||||||
|
* @deprecated Legacy IDs haven't functioned properly for some time
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static boolean hasLegacy(int packetId) {
|
public static boolean hasLegacy(int packetId) {
|
||||||
return getLookup().getFromLegacy(packetId) != null;
|
return getLookup().getFromLegacy(packetId) != null;
|
||||||
}
|
}
|
||||||
@ -688,18 +694,19 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
/**
|
/**
|
||||||
* Retrieve a packet type from a protocol, sender and packet ID.
|
* Retrieve a packet type from a protocol, sender and packet ID.
|
||||||
* <p>
|
* <p>
|
||||||
* It is usually better to access the packet types statically, like so:
|
* It is almost always better to access the packet types statically, like so:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link PacketType.Play.Server#SPAWN_ENTITY}
|
* <li>{@link PacketType.Play.Server#SPAWN_ENTITY}
|
||||||
* </ul>
|
* </ul>
|
||||||
|
* However there are some valid uses for packet IDs. Please note that IDs
|
||||||
|
* change almost every Minecraft version.
|
||||||
|
*
|
||||||
* @param protocol - the current protocol.
|
* @param protocol - the current protocol.
|
||||||
* @param sender - the sender.
|
* @param sender - the sender.
|
||||||
* @param packetId - the packet ID.
|
* @param packetId - the packet ID.
|
||||||
* @return The corresponding packet type.
|
* @return The corresponding packet type.
|
||||||
* @throws IllegalArgumentException If the current packet could not be found.
|
* @throws IllegalArgumentException If the current packet could not be found.
|
||||||
* @deprecated IDs are no longer reliable
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public static PacketType findCurrent(Protocol protocol, Sender sender, int packetId) {
|
public static PacketType findCurrent(Protocol protocol, Sender sender, int packetId) {
|
||||||
PacketType type = getLookup().getFromCurrent(protocol, sender, packetId);
|
PacketType type = getLookup().getFromCurrent(protocol, sender, packetId);
|
||||||
|
|
||||||
@ -721,7 +728,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String format(Protocol protocol, Sender sender, String name) {
|
private static String format(Protocol protocol, Sender sender, String name) {
|
||||||
if (name.contains("Packet"))
|
if (name.contains("Packet"))
|
||||||
return name;
|
return name;
|
||||||
|
|
||||||
@ -734,9 +741,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* @param sender - the sender.
|
* @param sender - the sender.
|
||||||
* @param packetId - the packet ID.
|
* @param packetId - the packet ID.
|
||||||
* @return TRUE if it exists, FALSE otherwise.
|
* @return TRUE if it exists, FALSE otherwise.
|
||||||
* @deprecated IDs are no longer reliable
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public static boolean hasCurrent(Protocol protocol, Sender sender, int packetId) {
|
public static boolean hasCurrent(Protocol protocol, Sender sender, int packetId) {
|
||||||
return getLookup().getFromCurrent(protocol, sender, packetId) != null;
|
return getLookup().getFromCurrent(protocol, sender, packetId) != null;
|
||||||
}
|
}
|
||||||
@ -749,7 +754,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* @param sender - the sender of the packet, or NULL if unknown.
|
* @param sender - the sender of the packet, or NULL if unknown.
|
||||||
* @return The packet type.
|
* @return The packet type.
|
||||||
* @throws IllegalArgumentException If the sender is NULL and the packet doesn't exist.
|
* @throws IllegalArgumentException If the sender is NULL and the packet doesn't exist.
|
||||||
|
* @deprecated Legacy IDs haven't functioned properly for some time
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static PacketType fromLegacy(int id, Sender sender) {
|
public static PacketType fromLegacy(int id, Sender sender) {
|
||||||
PacketType type = getLookup().getFromLegacy(id, sender);
|
PacketType type = getLookup().getFromLegacy(id, sender);
|
||||||
|
|
||||||
@ -1018,11 +1025,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* <p>
|
* <p>
|
||||||
* This is only unique within a specific protocol and target.
|
* This is only unique within a specific protocol and target.
|
||||||
* <p>
|
* <p>
|
||||||
* It is only unknown if the packet was removed in Minecraft 1.7.2.
|
* It is unknown if the packet was removed at any point.
|
||||||
* @return The current ID, or {@link #UNKNOWN_PACKET} if unknown.
|
* @return The current ID, or {@link #UNKNOWN_PACKET} if unknown.
|
||||||
* @deprecated IDs are subject to change
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public int getCurrentId() {
|
public int getCurrentId() {
|
||||||
return currentId;
|
return currentId;
|
||||||
}
|
}
|
||||||
@ -1064,7 +1069,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
* <p>
|
* <p>
|
||||||
* This ID is globally unique.
|
* This ID is globally unique.
|
||||||
* @return The legacy ID, or {@link #UNKNOWN_PACKET} if unknown.
|
* @return The legacy ID, or {@link #UNKNOWN_PACKET} if unknown.
|
||||||
|
* @deprecated Legacy IDs haven't functioned properly for some time
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public int getLegacyId() {
|
public int getLegacyId() {
|
||||||
return legacyId;
|
return legacyId;
|
||||||
}
|
}
|
||||||
@ -1110,7 +1117,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(protocol, sender, currentId, legacyId);
|
return Objects.hashCode(protocol, sender, currentId, deprecated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1120,10 +1127,10 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
|
|
||||||
if (obj instanceof PacketType) {
|
if (obj instanceof PacketType) {
|
||||||
PacketType other = (PacketType) obj;
|
PacketType other = (PacketType) obj;
|
||||||
return protocol == other.protocol &&
|
return deprecated == other.deprecated &&
|
||||||
|
protocol == other.protocol &&
|
||||||
sender == other.sender &&
|
sender == other.sender &&
|
||||||
currentId == other.currentId &&
|
currentId == other.currentId;
|
||||||
legacyId == other.legacyId;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1134,7 +1141,7 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
compare(protocol, other.getProtocol()).
|
compare(protocol, other.getProtocol()).
|
||||||
compare(sender, other.getSender()).
|
compare(sender, other.getSender()).
|
||||||
compare(currentId, other.getCurrentId()).
|
compare(currentId, other.getCurrentId()).
|
||||||
compare(legacyId, other.getLegacyId()).
|
compareTrueFirst(deprecated, other.isDeprecated()).
|
||||||
result();
|
result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1143,9 +1150,9 @@ public class PacketType implements Serializable, Cloneable, Comparable<PacketTyp
|
|||||||
Class<?> clazz = getPacketClass();
|
Class<?> clazz = getPacketClass();
|
||||||
|
|
||||||
if (clazz == null)
|
if (clazz == null)
|
||||||
return name() + "[" + protocol + ", " + sender + ", " + currentId + ", legacy: " + legacyId + ", classNames: " + Arrays.toString(classNames) + " (unregistered)]";
|
return name() + "[" + protocol + ", " + sender + ", " + currentId + ", classNames: " + Arrays.toString(classNames) + " (unregistered)]";
|
||||||
else
|
else
|
||||||
return clazz.getSimpleName() + "[" + currentId + ", legacy: " + legacyId + "]";
|
return name() + "[class=" + clazz.getSimpleName() + ", id=" + currentId + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -67,9 +67,11 @@ public class StructureCache {
|
|||||||
// TODO: Optimize DefaultInstances
|
// TODO: Optimize DefaultInstances
|
||||||
Object result = DefaultInstances.DEFAULT.create(clazz);
|
Object result = DefaultInstances.DEFAULT.create(clazz);
|
||||||
|
|
||||||
if (result != null) {
|
if (result == null) {
|
||||||
return result;
|
throw new IllegalArgumentException("Failed to create packet for type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Cannot find associated packet class: " + type);
|
throw new IllegalArgumentException("Cannot find associated packet class: " + type);
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,37 @@
|
|||||||
/**
|
/**
|
||||||
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
||||||
* Copyright (C) 2016 dmulloy2
|
* Copyright (C) 2016 dmulloy2
|
||||||
*
|
* <p>
|
||||||
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
* This program is free software; you can redistribute it and/or modify it under the terms of the
|
||||||
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
* GNU General Public License as published by the Free Software Foundation; either version 2 of
|
||||||
* the License, or (at your option) any later version.
|
* the License, or (at your option) any later version.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
* See the GNU General Public License for more details.
|
* See the GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License along with this program;
|
* You should have received a copy of the GNU General Public License along with this program;
|
||||||
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
* 02111-1307 USA
|
* 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
package com.comphenix.protocol;
|
package com.comphenix.protocol;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import java.lang.reflect.Field;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType.Protocol;
|
||||||
|
import com.comphenix.protocol.PacketType.Sender;
|
||||||
|
|
||||||
|
import net.minecraft.server.v1_12_R1.EnumProtocol;
|
||||||
|
import net.minecraft.server.v1_12_R1.EnumProtocolDirection;
|
||||||
import net.minecraft.server.v1_12_R1.PacketLoginInStart;
|
import net.minecraft.server.v1_12_R1.PacketLoginInStart;
|
||||||
|
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType.Protocol;
|
import static org.junit.Assert.*;
|
||||||
import com.comphenix.protocol.PacketType.Sender;
|
|
||||||
import com.comphenix.protocol.injector.netty.NettyProtocolRegistry;
|
|
||||||
import com.comphenix.protocol.injector.netty.ProtocolRegistry;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dmulloy2
|
* @author dmulloy2
|
||||||
@ -54,22 +55,31 @@ public class PacketTypeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ensureAllExist() {
|
@SuppressWarnings("unchecked")
|
||||||
boolean missing = false;
|
public void ensureTypesAreCorrect() throws Exception {
|
||||||
ProtocolRegistry registry = new NettyProtocolRegistry();
|
boolean fail = false;
|
||||||
Map<PacketType, Class<?>> lookup = registry.getPacketTypeLookup();
|
|
||||||
for (Entry<PacketType, Class<?>> entry : lookup.entrySet()) {
|
|
||||||
PacketType type = entry.getKey();
|
|
||||||
Class<?> clazz = entry.getValue();
|
|
||||||
|
|
||||||
if (type.isDynamic()) {
|
EnumProtocol[] protocols = EnumProtocol.values();
|
||||||
System.err.println("Packet " + clazz + " does not have a corresponding PacketType!");
|
for (EnumProtocol protocol : protocols) {
|
||||||
missing = true;
|
Field field = EnumProtocol.class.getDeclaredField("h");
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
Map<EnumProtocolDirection, Map<Integer, Class<?>>> map = (Map<EnumProtocolDirection, Map<Integer, Class<?>>>) field.get(protocol);
|
||||||
|
for (Entry<EnumProtocolDirection, Map<Integer, Class<?>>> entry : map.entrySet()) {
|
||||||
|
Map<Integer, Class<?>> treeMap = new TreeMap<>(entry.getValue());
|
||||||
|
for (Entry<Integer, Class<?>> entry1 : treeMap.entrySet()) {
|
||||||
|
try {
|
||||||
|
PacketType type = PacketType.fromClass(entry1.getValue());
|
||||||
|
if (type.getCurrentId() != entry1.getKey())
|
||||||
|
throw new IllegalStateException("Packet ID for " + type + " is incorrect. Expected " + entry1.getKey() + ", but got " + type.getCurrentId());
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
fail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//assertFalse("Packet " + clazz + " does not have a corresponding PacketType!", type.isDynamic());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assertFalse("There are packets that aren\'t accounted for!", missing);
|
assertTrue("Packet type(s) were incorrect!", !fail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ public class PacketContainerTest {
|
|||||||
|
|
||||||
private static final List<PacketType> BLACKLISTED = Util.asList(
|
private static final List<PacketType> BLACKLISTED = Util.asList(
|
||||||
PacketType.Play.Client.CUSTOM_PAYLOAD, PacketType.Play.Server.CUSTOM_PAYLOAD,
|
PacketType.Play.Client.CUSTOM_PAYLOAD, PacketType.Play.Server.CUSTOM_PAYLOAD,
|
||||||
PacketType.Play.Server.SET_COOLDOWN
|
PacketType.Play.Server.SET_COOLDOWN, PacketType.Play.Server.REL_ENTITY_MOVE_LOOK
|
||||||
);
|
);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -544,9 +544,9 @@ public class PacketContainerTest {
|
|||||||
try {
|
try {
|
||||||
PacketContainer constructed = new PacketContainer(type);
|
PacketContainer constructed = new PacketContainer(type);
|
||||||
|
|
||||||
if (!registered) {
|
// if (!registered) {
|
||||||
fail("Expected IllegalArgumentException(Packet " + type + " not registered");
|
// fail("Expected IllegalArgumentException(Packet " + type + " not registered)");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Initialize default values
|
// Initialize default values
|
||||||
constructed.getModifier().writeDefaults();
|
constructed.getModifier().writeDefaults();
|
||||||
@ -585,17 +585,12 @@ public class PacketContainerTest {
|
|||||||
// Something is very wrong
|
// Something is very wrong
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
} catch (Throwable ex) {
|
||||||
throw new RuntimeException("Failed to serialize packet " + type, e);
|
throw new RuntimeException("Failed to serialize packet " + type, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPacketType() {
|
|
||||||
assertEquals(PacketType.Legacy.Server.SET_CREATIVE_SLOT, PacketType.findLegacy(107, Sender.SERVER));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert to objects that support equals()
|
// Convert to objects that support equals()
|
||||||
private void testEquality(Object a, Object b) {
|
private void testEquality(Object a, Object b) {
|
||||||
if (a != null && b != null) {
|
if (a != null && b != null) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren