-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod build; | ||
mod init; | ||
mod markdown; | ||
mod script; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use anyhow::Result; | ||
|
||
use crate::api::{app::App, models::server::Server, utils::script::Shell}; | ||
|
||
impl App { | ||
pub fn get_server_execution_arguments(&self) -> Vec<String> { | ||
Check warning on line 6 in src/api/app/actions/script/mod.rs GitHub Actions / clippymethods `get_server_execution_arguments`, `get_script_lines_for`, and `action_generate_script` are never used
|
||
todo!() | ||
} | ||
|
||
pub fn get_script_lines_for(&self, shell: Shell, server: &Server) -> Vec<String> { | ||
let mut lines = vec![]; | ||
|
||
if shell == Shell::Bat { | ||
lines.push(format!("title {}", server.name)); | ||
} | ||
|
||
lines.extend(server.launcher.prelaunch.clone()); | ||
|
||
todo!(); | ||
|
||
lines.extend(server.launcher.postlaunch.clone()); | ||
Check warning on line 21 in src/api/app/actions/script/mod.rs GitHub Actions / clippyunreachable statement
|
||
|
||
lines | ||
} | ||
|
||
pub async fn action_generate_script(&self) -> Result<()> { | ||
todo!() | ||
} | ||
Check warning on line 28 in src/api/app/actions/script/mod.rs GitHub Actions / clippyunused `async` for function with no await statements
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ pub mod sources; | |
pub mod step; | ||
pub mod tools; | ||
pub mod utils; | ||
pub mod ws; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
mod addon; | ||
Check failure on line 1 in src/api/models/addon/mod.rs GitHub Actions / clippymodule has the same name as its containing module
|
||
mod addon_metadata; | ||
mod addon_target; | ||
mod addon_type; | ||
mod holders; | ||
|
||
pub use addon::*; | ||
pub use addon_metadata::*; | ||
pub use addon_target::*; | ||
pub use addon_type::*; | ||
pub use holders::*; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use std::{borrow::ToOwned, collections::HashMap, env}; | ||
|
||
use crate::api::utils::serde::*; | ||
Check warning on line 4 in src/api/models/launcher/mod.rs GitHub Actions / clippyusage of wildcard import
|
||
|
||
mod preset_flags; | ||
pub use preset_flags::*; | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] | ||
#[serde(default)] | ||
pub struct ServerLauncher { | ||
pub eula_args: bool, | ||
|
||
#[serde(skip_serializing_if = "is_default")] | ||
pub nogui: bool, | ||
#[serde(skip_serializing_if = "is_default")] | ||
pub preset_flags: PresetFlags, | ||
#[serde(skip_serializing_if = "is_default")] | ||
pub disable: bool, | ||
#[serde(skip_serializing_if = "is_default")] | ||
pub jvm_args: String, | ||
#[serde(skip_serializing_if = "is_default")] | ||
pub game_args: String, | ||
#[serde(skip_serializing_if = "is_default")] | ||
pub memory: String, | ||
#[serde(skip_serializing_if = "is_default")] | ||
pub properties: HashMap<String, String>, | ||
|
||
#[serde(skip_serializing_if = "Vec::is_empty")] | ||
pub prelaunch: Vec<String>, | ||
#[serde(skip_serializing_if = "Vec::is_empty")] | ||
pub postlaunch: Vec<String>, | ||
|
||
pub java_version: Option<String>, | ||
} | ||
|
||
impl ServerLauncher { | ||
pub fn get_args(&self, exec: &str) -> Vec<String> { | ||
Check warning on line 38 in src/api/models/launcher/mod.rs GitHub Actions / clippymethod `get_args` is never used
|
||
let mut args = self | ||
.jvm_args | ||
.split_whitespace() | ||
.map(ToOwned::to_owned) | ||
.collect::<Vec<_>>(); | ||
|
||
if env::var("MC_MEMORY").is_ok() || !self.memory.is_empty() { | ||
let m = env::var("MC_MEMORY").unwrap_or(self.memory.clone()); | ||
args.extend([format!("-Xms{m}"), format!("-Xmx{m}")]); | ||
} | ||
|
||
args.append(&mut self.preset_flags.get_flags()); | ||
|
||
if self.eula_args { | ||
args.push(String::from("-Dcom.mojang.eula.agree=true")); | ||
} | ||
|
||
for (key, value) in &self.properties { | ||
args.push(format!( | ||
"-D{}={}", | ||
key, | ||
if value.contains(char::is_whitespace) { | ||
format!("\"{value}\"") | ||
} else { | ||
value.clone() | ||
} | ||
)); | ||
} | ||
|
||
args.extend(exec.split_whitespace().map(ToOwned::to_owned)); | ||
|
||
if self.nogui && !matches!(self.preset_flags, PresetFlags::Proxy) { | ||
args.push(String::from("--nogui")); | ||
} | ||
|
||
args.extend(self.game_args.split_whitespace().map(ToOwned::to_owned)); | ||
|
||
args | ||
} | ||
} | ||
|
||
impl Default for ServerLauncher { | ||
fn default() -> Self { | ||
Self { | ||
preset_flags: PresetFlags::None, | ||
nogui: true, | ||
jvm_args: String::new(), | ||
game_args: String::new(), | ||
disable: false, | ||
eula_args: true, | ||
memory: String::new(), | ||
properties: HashMap::default(), | ||
prelaunch: vec![], | ||
postlaunch: vec![], | ||
java_version: None, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Default)] | ||
#[serde(rename_all = "lowercase")] | ||
pub enum PresetFlags { | ||
Aikars, | ||
Proxy, | ||
#[default] | ||
None, | ||
} | ||
|
||
impl PresetFlags { | ||
pub fn get_flags(&self) -> Vec<String> { | ||
Check warning on line 13 in src/api/models/launcher/preset_flags.rs GitHub Actions / clippymethod `get_flags` is never used
|
||
match self { | ||
Self::Aikars => include_str!("../../../../res/aikars_flags"), | ||
Self::Proxy => include_str!("../../../../res/proxy_flags"), | ||
Self::None => "", | ||
} | ||
.split(char::is_whitespace) | ||
.map(ToOwned::to_owned) | ||
.collect() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod addon_metadata; | ||
|
||
pub use addon_metadata::*; | ||
|
||
pub enum MetadataBlock { | ||
Addons(Vec<AddonMetadata>), | ||
} |