1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
use ;
use Context;
// use mcvm_core::auth_crate::mc::ClientId;
use JavaInstallation;
// use mcvm_core::io::java::install::JavaInstallationKind;
// use mcvm_core::io::java::JavaMajorVersion;
// use mcvm_core::launch::{
// launch_process, LaunchConfiguration, LaunchProcessParameters, LaunchProcessProperties,
// };
// use mcvm_core::user::UserManager;
// use mcvm_mods::paper;
// use mcvm_shared::modifications::Proxy;
// use mcvm_shared::output::{MCVMOutput, MessageContents, MessageLevel};
// use mcvm_shared::translate;
// use reqwest::Client;
// use crate::data::config::plugin::PluginManager;
// use crate::io::paths::Paths;
// use super::{update::manager::UpdateManager, Profile};
// impl Profile {
// /// Create the profile's proxy, if it has one
// pub async fn create_proxy(
// &mut self,
// manager: &mut UpdateManager,
// paths: &Paths,
// client: &Client,
// o: &mut impl MCVMOutput,
// ) -> anyhow::Result<()> {
// o.start_process();
// o.display(
// MessageContents::StartProcess(translate!(o, StartUpdatingProxy)),
// MessageLevel::Important,
// );
// // Create the proxy dir
// self.get_and_create_proxy_dir(paths).await?;
// match self.modifications.proxy {
// Proxy::Velocity => {
// let (jar_path, main_class) = paper::install_velocity(&paths.core, client)
// .await
// .context("Failed to install Velocity")?;
// let java = manager
// .core
// .get_mut()
// .get_java_installation(JavaMajorVersion::new(17), JavaInstallationKind::Auto, o)
// .await
// .context("Failed to install Java for proxy")?;
// self.proxy_props.fill(ProxyProperties {
// jar_path,
// main_class,
// java,
// });
// }
// _ => {}
// }
// o.display(
// MessageContents::Success(translate!(o, FinishUpdatingProxy)),
// MessageLevel::Important,
// );
// o.end_process();
// Ok(())
// }
// /// Launch the profile's proxy, if it has one, returning the child process
// pub async fn launch_proxy(
// &mut self,
// client: &Client,
// paths: &Paths,
// plugins: &PluginManager,
// o: &mut impl MCVMOutput,
// ) -> anyhow::Result<ProxyHandle> {
// // Check for updates first
// let mut manager = UpdateManager::new(false, true);
// manager
// .fulfill_requirements(
// &UserManager::new(ClientId::new(String::new())),
// plugins,
// paths,
// client,
// o,
// )
// .await
// .context("Failed to fulfill update manager")?;
// self.create_proxy(&mut manager, paths, client, o)
// .await
// .context("Failed to check for proxy updates")?;
// o.display(
// MessageContents::Simple(translate!(o, Launch)),
// MessageLevel::Important,
// );
// let child = match self.modifications.proxy {
// Proxy::None => None,
// _ => {
// let dir = self.get_and_create_proxy_dir(paths).await?;
// let props = self.proxy_props.get();
// let jvm_path = props.java.get_jvm_path();
// let proc_props = LaunchProcessProperties {
// jvm_args: vec!["-jar".into(), props.jar_path.to_string_lossy().into()],
// ..Default::default()
// };
// let params = LaunchProcessParameters {
// cwd: &dir,
// command: jvm_path.as_os_str(),
// main_class: Some(&props.main_class),
// launch_config: &LaunchConfiguration::default(),
// props: proc_props,
// };
// let child =
// launch_process(params).context("Failed to launch Velocity child process")?;
// Some(child)
// }
// };
// let handle = ProxyHandle { child };
// Ok(handle)
// }
// /// Gets the directory for this profile's proxy and creates it
// async fn get_and_create_proxy_dir(&self, paths: &Paths) -> anyhow::Result<PathBuf> {
// let path = paths.proxy.join(self.id.to_string());
// tokio::fs::create_dir_all(&path)
// .await
// .context("Failed to create profile proxy dir")?;
// Ok(path)
// }
// }
/// Properties for a proxy
// TODO: Remove this
/// A handle to a running proxy