bool SendRawMapCore(Level prev, Level level) { bool success = true; try { if (level.blocks == null) { throw new InvalidOperationException("Tried to join unloaded level"); } useCheckpointSpawn = false; lastCheckpointIndex = -1; AFKCooldown = DateTime.UtcNow.AddSeconds(2); ZoneIn = null; SendMapMotd(); AllowBuild = level.BuildAccess.CheckAllowed(this); int volume = level.blocks.Length; if (Supports(CpeExt.FastMap)) { Send(Packet.LevelInitaliseExt(volume)); } else { Send(Packet.LevelInitalise()); } if (hasBlockDefs) { if (prev != null && prev != level) { RemoveOldLevelCustomBlocks(prev); } BlockDefinition.SendLevelCustomBlocks(this); if (Supports(CpeExt.InventoryOrder)) { BlockDefinition.SendLevelInventoryOrder(this); } } using (LevelChunkStream dst = new LevelChunkStream(this)) using (Stream stream = LevelChunkStream.CompressMapHeader(this, volume, dst)) { if (level.MightHaveCustomBlocks()) { LevelChunkStream.CompressMap(this, stream, dst); } else { LevelChunkStream.CompressMapSimple(this, stream, dst); } } // Force players to read the MOTD (clamped to 3 seconds at most) if (level.Config.LoadDelay > 0) { System.Threading.Thread.Sleep(level.Config.LoadDelay); } byte[] buffer = Packet.LevelFinalise(level.Width, level.Height, level.Length); Send(buffer); Loading = false; OnSentMapEvent.Call(this, prev, level); } catch (Exception ex) { success = false; PlayerActions.ChangeMap(this, Server.mainLevel); Message("&WThere was an error sending the map, you have been sent to the main level."); Logger.LogError(ex); } finally { Server.DoGC(); } return(success); }