Ejemplo n.º 1
0
            void Upload(Player p, string modelName, string url)
            {
                var bytes = HttpUtil.DownloadData(url, p);

                if (bytes != null)
                {
                    string json = System.Text.Encoding.UTF8.GetString(bytes);

                    // try parsing now so that we throw and don't save the invalid file
                    // and notify the user of the error
                    if (!BlockBench.IsValid(json, p, modelName))
                    {
                        return;
                    }

                    // override filename because file might not exist yet
                    var storedModel = new StoredCustomModel(modelName, true);
                    storedModel.WriteBBFile(json);

                    if (!storedModel.Exists())
                    {
                        // create a default ccmodel file if doesn't exist
                        storedModel.WriteToFile();
                    }

                    CheckUpdateAll(storedModel);
                    p.Message(
                        "%TCustom Model %S{0} %Tupdated!",
                        modelName
                        );
                }
            }