From 07779883305ec4992e443a8c1fec227b9e0d0480 Mon Sep 17 00:00:00 2001 From: Georgii Korogodov Date: Sat, 25 Jun 2022 22:58:28 +0400 Subject: [PATCH] additional data for books --- NbtScrapper/NbtScrapper/MainForm.cs | 80 +++++++++++++++++----- NbtScrapper/NbtScrapper/NbtScrapper.csproj | 2 + 2 files changed, 63 insertions(+), 19 deletions(-) diff --git a/NbtScrapper/NbtScrapper/MainForm.cs b/NbtScrapper/NbtScrapper/MainForm.cs index 5787c63..e94f431 100644 --- a/NbtScrapper/NbtScrapper/MainForm.cs +++ b/NbtScrapper/NbtScrapper/MainForm.cs @@ -41,25 +41,37 @@ private void extractButton_Click(object sender, EventArgs e) extractButton.Enabled = false; var regionFiles = new List(); var playerFiles = new List(); - var regionPath = Path.Combine(inputPathTextBox.Text, "region"); - if (Directory.Exists(regionPath)) - { - regionFiles.AddRange(Directory.GetFiles(regionPath)); - } + var path = inputPathTextBox.Text; - var entitiesPath = Path.Combine(inputPathTextBox.Text, "entities"); - if (Directory.Exists(entitiesPath)) - { - regionFiles.AddRange(Directory.GetFiles(entitiesPath)); - } + RecursiveFolderSearch(path); - var playerDataPath = Path.Combine(inputPathTextBox.Text, "playerdata"); - if (Directory.Exists(playerDataPath)) + Task.Run(() => FindBooksAndSigns(regionFiles, playerFiles)); + + void RecursiveFolderSearch(string path) { - playerFiles.AddRange(Directory.GetFiles(playerDataPath)); - } + var regionPath = Path.Combine(path, "region"); + if (Directory.Exists(regionPath)) + { + regionFiles.AddRange(Directory.GetFiles(regionPath)); + } - Task.Run(() => FindBooksAndSigns(regionFiles, playerFiles)); + var entitiesPath = Path.Combine(path, "entities"); + if (Directory.Exists(entitiesPath)) + { + regionFiles.AddRange(Directory.GetFiles(entitiesPath)); + } + + var playerDataPath = Path.Combine(path, "playerdata"); + if (Directory.Exists(playerDataPath)) + { + playerFiles.AddRange(Directory.GetFiles(playerDataPath)); + } + + foreach (var dir in Directory.GetDirectories(path)) + { + RecursiveFolderSearch(dir); + } + } } private void FindBooksAndSigns(ICollection regionFiles, ICollection playerFiles) @@ -110,6 +122,7 @@ private void FindBooksAndSigns(ICollection regionFiles, ICollection regionFiles, ICollection action) { - var stack = new ConcurrentStack(); + var stack = new Stack(); stack.Push(rootTag); while (stack.TryPop(out var container)) { @@ -267,7 +310,6 @@ private void CyclicSearch(NbtContainerTag rootTag, Actionnet6.0-windows enable true + true + false enable