@@ -36,6 +36,7 @@ enum Software {
36
36
Paper ,
37
37
Folia ,
38
38
Purpur ,
39
+ Velocity ,
39
40
}
40
41
41
42
fn inquired < T > ( binding : Result < T , inquire:: InquireError > ) -> T {
@@ -54,6 +55,7 @@ impl Software {
54
55
"paper" => Self :: Paper ,
55
56
"folia" => Self :: Folia ,
56
57
"purpur" => Self :: Purpur ,
58
+ "velocity" => Self :: Velocity ,
57
59
_ => panic ! ( "Invalid software name: {}" , name) ,
58
60
}
59
61
}
@@ -63,6 +65,7 @@ impl Software {
63
65
Self :: Paper => "paper" ,
64
66
Self :: Folia => "folia" ,
65
67
Self :: Purpur => "purpur" ,
68
+ Self :: Velocity => "velocity" ,
66
69
}
67
70
. to_string ( )
68
71
}
@@ -71,26 +74,11 @@ impl Software {
71
74
fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
72
75
let cli = CLI :: parse ( ) ;
73
76
74
- println ! (
75
- r#"
76
- ░▒▓██████████████▓▒░ ░▒▓██████▓▒░ ░▒▓███████▓▒░░▒▓██████▓▒░ ░▒▓███████▓▒░▒▓████████▓▒░
77
- ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░
78
- ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░
79
- ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓██████▓▒░░▒▓████████▓▒░░▒▓██████▓▒░ ░▒▓█▓▒░
80
- ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
81
- ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░
82
- ░▒▓█▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░ ░▒▓█▓▒░
83
-
84
- {}
85
- "# ,
86
- "By Maoyue (MagicTeaMC)" . yellow( )
87
- ) ;
88
-
89
77
let software = {
90
78
if cli. software . is_none ( ) {
91
79
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" ] ,
94
82
)
95
83
. prompt ( ) ;
96
84
@@ -100,7 +88,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
100
88
}
101
89
} ;
102
90
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 ( ) {
104
94
let binding = Text :: new ( "🪨 What version of Minecraft are you using?" )
105
95
. with_default ( "1.21.1" )
106
96
. prompt ( ) ;
@@ -111,7 +101,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
111
101
}
112
102
} ;
113
103
let eula = {
114
- if cli. eula . is_none ( ) {
104
+ if software. name ( ) == "velocity" {
105
+ false
106
+ } else if cli. eula . is_none ( ) {
115
107
let binding = Confirm :: new (
116
108
format ! (
117
109
"📄 Do you agree to the {}?" ,
@@ -129,7 +121,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
129
121
}
130
122
} ;
131
123
132
- println ! (
124
+ if software. name ( ) != "velocity" {
125
+ println ! (
133
126
"\n ✨ I will setup {}, with Minecraft server version {}, {} Mojang's EULA in this directory {}{}{}." ,
134
127
software. name( ) . bold( ) . yellow( ) ,
135
128
version. bold( ) . blue( ) ,
@@ -149,25 +142,42 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
149
142
. and_then( |name| name. to_str( ) )
150
143
. unwrap_or( "<unknown>" )
151
144
} . 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
+ }
154
164
155
165
if !cli. yes {
156
166
match Confirm :: new ( "Proceed?" ) . with_default ( true ) . prompt ( ) {
157
167
Ok ( result) => {
158
168
if !result {
159
169
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
+ }
168
179
}
169
- }
170
- ) ;
180
+ ) ;
171
181
println ! ( "{}: aborted" , "warning" . yellow( ) . bold( ) ) ;
172
182
exit ( -1 ) ;
173
183
}
@@ -181,7 +191,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
181
191
182
192
println ! ( ) ;
183
193
184
- if eula {
194
+ if eula && software . name ( ) != "velocity" {
185
195
print ! ( "(1/2) Adding EULA... " ) ;
186
196
match eula:: add_eula ( ) {
187
197
Err ( e) => {
@@ -195,7 +205,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
195
205
print ! (
196
206
"{}Downloading {}... " ,
197
207
{
198
- if eula {
208
+ if eula && software . name ( ) != "velocity" {
199
209
"(2/2) "
200
210
} else {
201
211
"(1/1) "
@@ -215,7 +225,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
215
225
}
216
226
217
227
println ! ( "\n {}" , "Summary" . bold( ) . underline( ) ) ;
218
- if eula {
228
+ if eula && software . name ( ) != "velocity" {
219
229
println ! ( " {} eula.txt" , "+" . green( ) . bold( ) ) ;
220
230
}
221
231
@@ -228,4 +238,4 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
228
238
) ;
229
239
230
240
Ok ( ( ) )
231
- }
241
+ }
0 commit comments