From 3b989df40d7b47f4ec089cca7bd3753d57fe090e Mon Sep 17 00:00:00 2001 From: TOwInOK <60252419+TOwInOK@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:26:43 +0700 Subject: [PATCH] &mut Core to &Core --- config.lock | 8 ++++---- config.toml | 2 +- src/controller/mod.rs | 2 +- src/downloader/mod.rs | 20 ++++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/config.lock b/config.lock index 59397fd..2c8fb6e 100644 --- a/config.lock +++ b/config.lock @@ -4,6 +4,10 @@ version = "1.20.4" build = "2165" path = "core/purpur.jar" +[plugins.simple-voice-chat] +version = "WvPmSPnl" +path = "plugins/simple-voice-chat.jar" + [plugins.itemswapper] version = "UKVc6pCj" path = "plugins/itemswapper.jar" @@ -11,7 +15,3 @@ path = "plugins/itemswapper.jar" [plugins.chunky] version = "iwsbfPGg" path = "plugins/chunky.jar" - -[plugins.simple-voice-chat] -version = "WvPmSPnl" -path = "plugins/simple-voice-chat.jar" diff --git a/config.toml b/config.toml index f27cb5c..1a67c31 100644 --- a/config.toml +++ b/config.toml @@ -29,4 +29,4 @@ key = "SUPEREKLy" path_to_core = "core" # path_to_mods = "" path_to_plugins = "plugins" -path_to_configs = "config.lock" +path_to_lock = "config.lock" diff --git a/src/controller/mod.rs b/src/controller/mod.rs index 2d74eed..17525af 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -20,7 +20,7 @@ impl Controller { async fn new() -> Self { // Load Config file let path = - "/Users/dmitryfefilov/Documents/Rust/MinecraftAddonController/config.toml".to_string(); + "config.toml".to_string(); let config = Config::load_config(path).await.unwrap_or_else(|e| { log::error!("message: {}", e); log::warn!("Происходит загрузка стандартного конфига"); diff --git a/src/downloader/mod.rs b/src/downloader/mod.rs index 337295b..1b65562 100644 --- a/src/downloader/mod.rs +++ b/src/downloader/mod.rs @@ -1,7 +1,7 @@ pub mod hash; mod models; -use crate::config::core::Provider; +use crate::config::core::{Core, Provider}; use crate::config::plugins::{Plugin, Sources}; use crate::config::Config; use crate::downloader::models::cores::folia::Folia; @@ -44,25 +44,25 @@ impl<'config, 'lock> Downloader<'config, 'lock> { /////Core section ///Check core and add it into list for download. - async fn get_core_link(&self) -> Result<(String, ChooseHash, String), DownloadErrors> { + async fn get_core_link(core: &Core) -> Result<(String, ChooseHash, String), DownloadErrors> { info!("Start to match provider of core"); - match self.config.core.provider { - Provider::Vanilla => Vanilla::get_link(&self.config.core).await, - Provider::Paper => Paper::get_link(&self.config.core).await, - Provider::Folia => Folia::get_link(&self.config.core).await, - Provider::Purpur => Purpur::get_link(&self.config.core).await, + match core.provider { + Provider::Vanilla => Vanilla::get_link(core).await, + Provider::Paper => Paper::get_link(core).await, + Provider::Folia => Folia::get_link(core).await, + Provider::Purpur => Purpur::get_link(core).await, Provider::Fabric => todo!(), Provider::Forge => todo!(), Provider::NeoForge => todo!(), - Provider::Waterfall => Waterfall::get_link(&self.config.core).await, - Provider::Velocity => Velocity::get_link(&self.config.core).await, + Provider::Waterfall => Waterfall::get_link(core).await, + Provider::Velocity => Velocity::get_link(core).await, } } /// Make reqwest to check version and download core. async fn core_reqwest(&mut self) -> Result<(), DownloadErrors> { //Find version to download - let (link, hash, version) = self.get_core_link().await?; + let (link, hash, version) = Self::get_core_link(&self.config.core).await?; let core_name = self.config.core.provider.get_name().await; debug!("Find {} link: {}, hash: {}", core_name, &link, &hash); info!("Start to download {}!", core_name);