Skip to content

Commit ce16a08

Browse files
committed
2.1.0 - Velocity support
1 parent a0e4ef6 commit ce16a08

File tree

6 files changed

+58
-44
lines changed

6 files changed

+58
-44
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mcsast"
33
authors = ["MagicTeaMC <maoyue@maoyue.tw>"]
44
description = "Minecraft server auto setup tool, simplified!"
5-
version = "2.0.0"
5+
version = "2.1.0"
66
edition = "2021"
77
license = "GPL-3.0"
88

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MCSAST v2
22
[![Discord](https://img.shields.io/discord/891325967203729472?color=5865F2&label=discord&style=for-the-badge)](https://discord.gg/uQ4UXANnP2)
33

4-
Setup a new Paper / Purpur / Folia server quickly and easily.
4+
Setup a new Paper / Purpur / Folia / Velocity server quickly and easily.
55
## Usage
66
Install via Cargo
77
```
@@ -12,9 +12,10 @@ Run with command
1212
mcsast
1313
```
1414
Give information to us with terminal:
15-
<img width="970" alt="image" src="https://github.com/user-attachments/assets/6c42d27c-d4fe-4bad-bb36-ce5d6b3debad">
15+
<img width="1378" alt="圖片" src="https://github.com/user-attachments/assets/a4cdfe71-de7b-4aab-9fb7-cfd1052a7edb" />
1616

17-
If you want it to setup automantic, here is a command
17+
If you want it to setup automantic, here is a command
18+
Note: Use `--mc-version=3.4.0-SNAPSHOT --eula=false` if you are installing Velocity
1819
```
1920
mcsast --software=paper --mc-version=1.21.1 --eula=true -y
2021
```

src/eula.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ pub fn add_eula() -> Result<(), Box<dyn std::error::Error>> {
55

66
file.write_all("eula=true".as_bytes())?;
77
Ok(())
8-
}
8+
}

src/main.rs

+46-36
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum Software {
3636
Paper,
3737
Folia,
3838
Purpur,
39+
Velocity,
3940
}
4041

4142
fn inquired<T>(binding: Result<T, inquire::InquireError>) -> T {
@@ -54,6 +55,7 @@ impl Software {
5455
"paper" => Self::Paper,
5556
"folia" => Self::Folia,
5657
"purpur" => Self::Purpur,
58+
"velocity" => Self::Velocity,
5759
_ => panic!("Invalid software name: {}", name),
5860
}
5961
}
@@ -63,6 +65,7 @@ impl Software {
6365
Self::Paper => "paper",
6466
Self::Folia => "folia",
6567
Self::Purpur => "purpur",
68+
Self::Velocity => "velocity",
6669
}
6770
.to_string()
6871
}
@@ -71,26 +74,11 @@ impl Software {
7174
fn main() -> Result<(), Box<dyn std::error::Error>> {
7275
let cli = CLI::parse();
7376

74-
println!(
75-
r#"
76-
░▒▓██████████████▓▒░ ░▒▓██████▓▒░ ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓███████▓▒░▒▓████████▓▒░
77-
░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░
78-
░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░
79-
░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓██████▓▒░░▒▓████████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░
80-
░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
81-
░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
82-
░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░ ░▒▓█▓▒░
83-
84-
{}
85-
"#,
86-
"By Maoyue (MagicTeaMC)".yellow()
87-
);
88-
8977
let software = {
9078
if cli.software.is_none() {
9179
let binding = Select::new(
92-
"💽 What server software are you using?",
93-
vec!["Paper", "Folia", "Purpur"],
80+
"💽 Which server software are you using?",
81+
vec!["Paper", "Folia", "Purpur", "Velocity"],
9482
)
9583
.prompt();
9684

@@ -100,7 +88,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
10088
}
10189
};
10290
let version = {
103-
if cli.mc_version.is_none() {
91+
if software.name() == "velocity" {
92+
"3.4.0-SNAPSHOT".to_string()
93+
} else if cli.mc_version.is_none() {
10494
let binding = Text::new("🪨 What version of Minecraft are you using?")
10595
.with_default("1.21.1")
10696
.prompt();
@@ -111,7 +101,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
111101
}
112102
};
113103
let eula = {
114-
if cli.eula.is_none() {
104+
if software.name() == "velocity" {
105+
false
106+
} else if cli.eula.is_none() {
115107
let binding = Confirm::new(
116108
format!(
117109
"📄 Do you agree to the {}?",
@@ -129,7 +121,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
129121
}
130122
};
131123

132-
println!(
124+
if software.name() != "velocity" {
125+
println!(
133126
"\n✨ I will setup {}, with Minecraft server version {}, {} Mojang's EULA in this directory {}{}{}.",
134127
software.name().bold().yellow(),
135128
version.bold().blue(),
@@ -149,25 +142,42 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
149142
.and_then(|name| name.to_str())
150143
.unwrap_or("<unknown>")
151144
}.dimmed(),
152-
")".dimmed()
153-
);
145+
")".dimmed()
146+
);
147+
} else {
148+
println!(
149+
"\n✨ I will setup {} in this directory {}{}{}.",
150+
software.name().bold().yellow(),
151+
"(".dimmed(),
152+
{
153+
let current_dir = std::env::current_dir().unwrap();
154+
current_dir
155+
.to_owned()
156+
.file_name()
157+
.and_then(|name| name.to_str())
158+
.unwrap_or("<unknown>")
159+
}
160+
.dimmed(),
161+
")".dimmed()
162+
);
163+
}
154164

155165
if !cli.yes {
156166
match Confirm::new("Proceed?").with_default(true).prompt() {
157167
Ok(result) => {
158168
if !result {
159169
println!(
160-
"\n🎏 You can pass `--software={} --mc-version={} --eula={}` to get everything up and running!\n",
161-
software.name().bold().yellow(),
162-
version.bold().blue(),
163-
{
164-
if eula {
165-
"true".bold().green()
166-
} else {
167-
"false".bold().red()
170+
"\n🎏 You can pass `--software={} --mc-version={} --eula={}` to get everything up and running!\n",
171+
software.name().bold().yellow(),
172+
version.bold().blue(),
173+
{
174+
if eula {
175+
"true".bold().green()
176+
} else {
177+
"false".bold().red()
178+
}
168179
}
169-
}
170-
);
180+
);
171181
println!("{}: aborted", "warning".yellow().bold());
172182
exit(-1);
173183
}
@@ -181,7 +191,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
181191

182192
println!();
183193

184-
if eula {
194+
if eula && software.name() != "velocity" {
185195
print!("(1/2) Adding EULA... ");
186196
match eula::add_eula() {
187197
Err(e) => {
@@ -195,7 +205,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
195205
print!(
196206
"{}Downloading {}... ",
197207
{
198-
if eula {
208+
if eula && software.name() != "velocity" {
199209
"(2/2) "
200210
} else {
201211
"(1/1) "
@@ -215,7 +225,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
215225
}
216226

217227
println!("\n{}", "Summary".bold().underline());
218-
if eula {
228+
if eula && software.name() != "velocity" {
219229
println!(" {} eula.txt", "+".green().bold());
220230
}
221231

@@ -228,4 +238,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
228238
);
229239

230240
Ok(())
231-
}
241+
}

src/softwares.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ pub fn get_other(software: String, version: String) -> Result<(), Box<dyn std::e
4747
let res = client
4848
.get(format!(
4949
"https://api.papermc.io/v2/projects/{}/versions/{}/builds/{}/downloads/{}",
50-
software.to_lowercase(), version, latest_build, jar_name
50+
software.to_lowercase(),
51+
version,
52+
latest_build,
53+
jar_name
5154
))
5255
.send();
5356
if let Ok(res) = res {
@@ -69,4 +72,4 @@ pub fn get(name: String, version: String) -> Result<(), Box<dyn std::error::Erro
6972
"purpur" => get_purpur(version),
7073
_ => get_other(name, version),
7174
}
72-
}
75+
}

0 commit comments

Comments
 (0)