private void HandlePackage(IMcpeMessageHandler handler, Package message) { if (handler is Player) { var result = Server.PluginManager.PluginPacketHandler(message, true, (Player)handler); if (result != message) { message.PutPool(); } message = result; } if (message == null) { return; } else if (typeof(ConnectedPing) == message.GetType()) { HandleConnectedPing((ConnectedPing)message); } else if (typeof(ConnectionRequest) == message.GetType()) { HandleConnectionRequest((ConnectionRequest)message); } else if (typeof(NewIncomingConnection) == message.GetType()) { HandleNewIncomingConnection((NewIncomingConnection)message); } else if (typeof(DisconnectionNotification) == message.GetType()) { HandleDisconnectionNotification(); } else if (typeof(McpeClientToServerHandshake) == message.GetType()) { // Start encrypotion handler.HandleMcpeClientToServerHandshake((McpeClientToServerHandshake)message); } else if (typeof(McpeResourcePackClientResponse) == message.GetType()) { handler.HandleMcpeResourcePackClientResponse((McpeResourcePackClientResponse)message); } else if (typeof(McpeResourcePackChunkRequest) == message.GetType()) { handler.HandleMcpeResourcePackChunkRequest((McpeResourcePackChunkRequest)message); } else if (typeof(McpeUpdateBlock) == message.GetType()) { // DO NOT USE. Will dissapear from MCPE any release. // It is a bug that it leaks these messages. } else if (typeof(McpeRemoveBlock) == message.GetType()) { handler.HandleMcpeRemoveBlock((McpeRemoveBlock)message); } else if (typeof(McpeLevelSoundEvent) == message.GetType()) { handler.HandleMcpeLevelSoundEvent((McpeLevelSoundEvent)message); } else if (typeof(McpeAnimate) == message.GetType()) { handler.HandleMcpeAnimate((McpeAnimate)message); } else if (typeof(McpeEntityFall) == message.GetType()) { handler.HandleMcpeEntityFall((McpeEntityFall)message); } else if (typeof(McpeUseItem) == message.GetType()) { handler.HandleMcpeUseItem((McpeUseItem)message); } else if (typeof(McpeEntityEvent) == message.GetType()) { handler.HandleMcpeEntityEvent((McpeEntityEvent)message); } else if (typeof(McpeText) == message.GetType()) { handler.HandleMcpeText((McpeText)message); } else if (typeof(McpeRemoveEntity) == message.GetType()) { // Do nothing right now, but should clear out the entities and stuff // from this players internal structure. } else if (typeof(McpeLogin) == message.GetType()) { handler.HandleMcpeLogin((McpeLogin)message); } else if (typeof(McpeMovePlayer) == message.GetType()) { handler.HandleMcpeMovePlayer((McpeMovePlayer)message); } else if (typeof(McpeCommandStep) == message.GetType()) { handler.HandleMcpeCommandStep((McpeCommandStep)message); } else if (typeof(McpeInteract) == message.GetType()) { handler.HandleMcpeInteract((McpeInteract)message); } else if (typeof(McpeRespawn) == message.GetType()) { handler.HandleMcpeRespawn((McpeRespawn)message); } else if (typeof(McpeBlockEntityData) == message.GetType()) { handler.HandleMcpeBlockEntityData((McpeBlockEntityData)message); } else if (typeof(McpeAdventureSettings) == message.GetType()) { handler.HandleMcpeAdventureSettings((McpeAdventureSettings)message); } else if (typeof(McpePlayerAction) == message.GetType()) { handler.HandleMcpePlayerAction((McpePlayerAction)message); } else if (typeof(McpeDropItem) == message.GetType()) { handler.HandleMcpeDropItem((McpeDropItem)message); } else if (typeof(McpeContainerSetSlot) == message.GetType()) { handler.HandleMcpeContainerSetSlot((McpeContainerSetSlot)message); } else if (typeof(McpeContainerClose) == message.GetType()) { handler.HandleMcpeContainerClose((McpeContainerClose)message); } else if (typeof(McpeMobEquipment) == message.GetType()) { handler.HandleMcpeMobEquipment((McpeMobEquipment)message); } else if (typeof(McpeMobArmorEquipment) == message.GetType()) { handler.HandleMcpeMobArmorEquipment((McpeMobArmorEquipment)message); } else if (typeof(McpeCraftingEvent) == message.GetType()) { handler.HandleMcpeCraftingEvent((McpeCraftingEvent)message); } else if (typeof(McpeRequestChunkRadius) == message.GetType()) { handler.HandleMcpeRequestChunkRadius((McpeRequestChunkRadius)message); } else if (typeof(McpeMapInfoRequest) == message.GetType()) { handler.HandleMcpeMapInfoRequest((McpeMapInfoRequest)message); } else if (typeof(McpeItemFrameDropItem) == message.GetType()) { handler.HandleMcpeItemFrameDropItem((McpeItemFrameDropItem)message); } else if (typeof(McpePlayerInput) == message.GetType()) { handler.HandleMcpePlayerInput((McpePlayerInput)message); } else if (typeof(McpeBlockPickRequest) == message.GetType()) { handler.HandleMcpeBlockPickRequest((McpeBlockPickRequest)message); } else if (typeof(McpeCommandBlockUpdate) == message.GetType()) { handler.HandleMcpeCommandBlockUpdate((McpeCommandBlockUpdate)message); } else { Log.Error($"Unhandled package: {message.GetType().Name} 0x{message.Id:X2} for user: {Username}, IP {EndPoint.Address}"); if (Log.IsDebugEnabled) { Log.Warn($"Unknown package 0x{message.Id:X2}\n{Package.HexDump(message.Bytes)}"); } return; } if (message.Timer.IsRunning) { long elapsedMilliseconds = message.Timer.ElapsedMilliseconds; if (elapsedMilliseconds > 1000) { Log.WarnFormat("Package (0x{1:x2}) handling too long {0}ms for {2}", elapsedMilliseconds, message.Id, Username); } } else { Log.WarnFormat("Package (0x{0:x2}) timer not started for {1}.", message.Id, Username); } }