예제 #1
0
        public void Initialize(McResourcePack resourcePack)
        {
            if (resourcePack.SoundDefinitions == null)
            {
                return;
            }

            foreach (var sound in resourcePack.SoundDefinitions)
            {
                foreach (var element in sound.Value.Sounds)
                {
                    string path        = StoragePath;
                    string elementPath = null;

                    if (element.SoundClass != null)
                    {
                        elementPath = $"minecraft/sounds/{element.SoundClass.Name}.ogg";
                        path        = Path.Combine(path, elementPath);
                    }
                    else if (element.Path != null)
                    {
                        elementPath = $"minecraft/sounds/{element.Path}.ogg";
                        path        = Path.Combine(path, elementPath);
                    }

                    if (!StorageSystem.Exists(path) && elementPath != null)
                    {
                        if (!StorageSystem.TryCreateDirectory(Path.GetDirectoryName(path)))
                        {
                        }

                        try
                        {
                            /*	using (var stream = resourcePack.GetStream(elementPath))
                             *      {
                             *              var data = stream.ReadToEnd();
                             *
                             *              if (StorageSystem.TryWriteBytes(path, data.ToArray()))
                             *              {
                             *                      Log.Info($"Saved {elementPath}...");
                             *              }
                             *      }*/
                        }
                        catch (FileNotFoundException)
                        {
                            Log.Warn($"File not found: {elementPath}");
                        }
                    }
                }
            }
        }