-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::sync::Arc; | ||
|
||
use anyhow::Result; | ||
use cliclack::{input, intro}; | ||
use tokio::sync::RwLock; | ||
|
||
use crate::api::{app::App, models::{network::Network, server::Server}}; | ||
|
||
impl App { | ||
pub async fn init_server(&mut self) -> Result<()> { | ||
Check warning on line 10 in src/api/app/actions/init/mod.rs GitHub Actions / clippymethods `init_server` and `init_network` are never used
|
||
intro("initializing server")?; | ||
|
||
let name: String = input("Name of the server?") | ||
.interact()?; | ||
|
||
let mut server = Server { | ||
Check warning on line 16 in src/api/app/actions/init/mod.rs GitHub Actions / clippyvariable does not need to be mutable
|
||
name, | ||
port: None, | ||
sources: vec![], | ||
}; | ||
|
||
self.server = Some(Arc::new(RwLock::new(server))); | ||
|
||
Ok(()) | ||
} | ||
Check warning on line 25 in src/api/app/actions/init/mod.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
|
||
pub async fn init_network(&mut self) -> Result<()> { | ||
intro("initializing network")?; | ||
|
||
let name: String = input("Name of the network?") | ||
.interact()?; | ||
|
||
let mut nw = Network { | ||
Check warning on line 33 in src/api/app/actions/init/mod.rs GitHub Actions / clippyvariable does not need to be mutable
|
||
name, | ||
}; | ||
|
||
self.network = Some(Arc::new(RwLock::new(nw))); | ||
|
||
Ok(()) | ||
} | ||
Check warning on line 40 in src/api/app/actions/init/mod.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mod build; | ||
mod init; | ||
|
||
pub use build::*; | ||
pub use init::*; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub struct Network { | ||
|
||
pub name: String, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)] | ||
pub enum ServerFlavor { | ||
Vanilla, | ||
Modded, | ||
Patched, | ||
Proxy, | ||
} | ||
|
||
impl ServerFlavor { | ||
pub fn supports_datapacks(&self) -> bool { | ||
Check warning on line 12 in src/api/models/server/server_flavor.rs GitHub Actions / clippythis argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
Check warning on line 12 in src/api/models/server/server_flavor.rs GitHub Actions / clippymethods `supports_datapacks`, `supports_mods`, and `supports_plugins` are never used
|
||
match self { | ||
ServerFlavor::Proxy => false, | ||
_ => true, | ||
} | ||
Check failure on line 16 in src/api/models/server/server_flavor.rs GitHub Actions / clippymatch expression looks like `matches!` macro
|
||
} | ||
|
||
pub fn supports_mods(&self) -> bool { | ||
Check warning on line 19 in src/api/models/server/server_flavor.rs GitHub Actions / clippythis argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
|
||
match self { | ||
ServerFlavor::Modded => true, | ||
_ => false, | ||
} | ||
Check failure on line 23 in src/api/models/server/server_flavor.rs GitHub Actions / clippymatch expression looks like `matches!` macro
|
||
} | ||
|
||
pub fn supports_plugins(&self) -> bool { | ||
Check warning on line 26 in src/api/models/server/server_flavor.rs GitHub Actions / clippythis argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
|
||
match self { | ||
ServerFlavor::Vanilla => false, | ||
ServerFlavor::Modded => false, | ||
Check warning on line 29 in src/api/models/server/server_flavor.rs GitHub Actions / clippythis match arm has an identical body to another arm
|
||
ServerFlavor::Patched => true, | ||
Check warning on line 30 in src/api/models/server/server_flavor.rs GitHub Actions / clippythis match arm has an identical body to another arm
|
||
ServerFlavor::Proxy => true, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use crate::api::utils::serde::*; | ||
Check warning on line 2 in src/api/models/server/server_type.rs GitHub Actions / clippyusage of wildcard import
|
||
|
||
#[derive(Debug, Default, Serialize, Deserialize, Clone, PartialEq)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum BuildToolsFlavor { | ||
#[default] | ||
Spigot, | ||
CraftBukkit, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] | ||
#[serde(tag = "type", rename_all = "lowercase")] | ||
pub enum ServerType { | ||
Vanilla { | ||
mc_version: String, | ||
}, | ||
|
||
PaperMC { | ||
project: String, | ||
#[serde(default = "str_latest")] | ||
build: String, | ||
}, | ||
|
||
Purpur { | ||
#[serde(default = "str_latest")] | ||
build: String, | ||
}, | ||
|
||
Fabric { | ||
#[serde(default = "str_latest")] | ||
loader: String, | ||
|
||
#[serde(default = "str_latest")] | ||
installer: String, | ||
}, | ||
|
||
Quilt { | ||
#[serde(default = "str_latest")] | ||
loader: String, | ||
|
||
#[serde(default = "str_latest")] | ||
installer: String, | ||
}, | ||
|
||
NeoForge { | ||
#[serde(default = "str_latest")] | ||
loader: String, | ||
}, | ||
|
||
Forge { | ||
#[serde(default = "str_latest")] | ||
loader: String, | ||
}, | ||
|
||
BuildTools { | ||
#[serde(default = "BuildToolsFlavor::default")] | ||
software: BuildToolsFlavor, | ||
#[serde(skip_serializing_if = "Vec::is_empty")] | ||
#[serde(default = "Vec::new")] | ||
args: Vec<String>, | ||
}, | ||
|
||
Paper {}, | ||
Velocity {}, | ||
Waterfall {}, | ||
BungeeCord {}, | ||
|
||
Downloadable { | ||
//#[serde(flatten)] | ||
//inner: Downloadable, | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod hashing; | ||
pub mod accessor; | ||
pub mod serde; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn str_latest() -> String { | ||
"latest".to_owned() | ||
} |