aboutsummaryrefslogtreecommitdiff
path: root/azalea
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-12-23 03:52:41 +0200
committermat <git@matdoes.dev>2025-12-22 17:52:56 -0800
commit83f720d9becd70f3c2333772f040b6092785a60e (patch)
tree28a4d1967fa2fbbf7ac10bb038f26dba69bebd08 /azalea
parent9097abb39bf1852676a50bac04575bcc6ec4150c (diff)
downloadazalea-drasl-83f720d9becd70f3c2333772f040b6092785a60e.tar.xz
move JoinOpts to a separate module
Diffstat (limited to 'azalea')
-rw-r--r--azalea/src/join_opts.rs107
-rw-r--r--azalea/src/lib.rs109
2 files changed, 109 insertions, 107 deletions
diff --git a/azalea/src/join_opts.rs b/azalea/src/join_opts.rs
new file mode 100644
index 00000000..d7283674
--- /dev/null
+++ b/azalea/src/join_opts.rs
@@ -0,0 +1,107 @@
+use std::net::SocketAddr;
+
+use azalea_protocol::{address::ServerAddr, connect::Proxy};
+
+/// Optional settings when adding an account to a swarm or client.
+#[derive(Clone, Debug, Default)]
+#[non_exhaustive]
+pub struct JoinOpts {
+ /// The SOCKS5 proxy that this bot will use for connecting to the Minecraft
+ /// server.
+ pub server_proxy: Option<Proxy>,
+ /// The SOCKS5 proxy that will be used when authenticating the bot's join
+ /// with Mojang.
+ ///
+ /// This should typically be either the same as [`Self::server_proxy`] or
+ /// `None`.
+ ///
+ /// This is useful to set if a server has `prevent-proxy-connections`
+ /// enabled.
+ pub sessionserver_proxy: Option<Proxy>,
+ /// Override the server address that this specific bot will send in the
+ /// handshake packet.
+ #[doc(alias = "custom_address")]
+ pub custom_server_addr: Option<ServerAddr>,
+ /// Override the IP and port that this specific bot will use to connect
+ /// to the server.
+ #[doc(alias = "custom_resolved_address")]
+ pub custom_socket_addr: Option<SocketAddr>,
+}
+
+impl JoinOpts {
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ pub fn update(&mut self, other: &Self) {
+ if let Some(proxy) = other.server_proxy.clone() {
+ self.server_proxy = Some(proxy);
+ }
+ if let Some(proxy) = other.sessionserver_proxy.clone() {
+ self.sessionserver_proxy = Some(proxy);
+ }
+ if let Some(custom_server_addr) = other.custom_server_addr.clone() {
+ self.custom_server_addr = Some(custom_server_addr);
+ }
+ if let Some(custom_socket_addr) = other.custom_socket_addr {
+ self.custom_socket_addr = Some(custom_socket_addr);
+ }
+ }
+
+ /// Configure the SOCKS5 proxy used for connecting to the server and for
+ /// authenticating with Mojang.
+ ///
+ /// To configure these separately, for example to only use the proxy for the
+ /// Minecraft server and not for authentication, you may use
+ /// [`Self::server_proxy`] and [`Self::sessionserver_proxy`] individually.
+ #[must_use]
+ pub fn proxy(self, proxy: Proxy) -> Self {
+ self.server_proxy(proxy.clone()).sessionserver_proxy(proxy)
+ }
+ /// Configure the SOCKS5 proxy that will be used for connecting to the
+ /// Minecraft server.
+ ///
+ /// To avoid errors on servers with the "prevent-proxy-connections" option
+ /// set, you should usually use [`Self::proxy`] instead.
+ ///
+ /// Also see [`Self::sessionserver_proxy`].
+ #[must_use]
+ pub fn server_proxy(mut self, proxy: Proxy) -> Self {
+ self.server_proxy = Some(proxy);
+ self
+ }
+ /// Configure the SOCKS5 proxy that this bot will use for authenticating the
+ /// server join with Mojang's API.
+ ///
+ /// Also see [`Self::proxy`] and [`Self::server_proxy`].
+ #[must_use]
+ pub fn sessionserver_proxy(mut self, proxy: Proxy) -> Self {
+ self.sessionserver_proxy = Some(proxy);
+ self
+ }
+
+ /// Set the custom address that this bot will send in the handshake packet.
+ #[must_use]
+ pub fn custom_server_addr(mut self, server_addr: ServerAddr) -> Self {
+ self.custom_server_addr = Some(server_addr);
+ self
+ }
+ /// Set the custom resolved address that this bot will use to connect to the
+ /// server.
+ #[must_use]
+ pub fn custom_socket_addr(mut self, socket_addr: SocketAddr) -> Self {
+ self.custom_socket_addr = Some(socket_addr);
+ self
+ }
+
+ #[doc(hidden)]
+ #[deprecated = "renamed to `custom_server_addr`."]
+ pub fn custom_address(self, server_addr: ServerAddr) -> Self {
+ self.custom_server_addr(server_addr)
+ }
+ #[doc(hidden)]
+ #[deprecated = "renamed to `custom_socket_addr`."]
+ pub fn custom_resolved_address(self, socket_addr: SocketAddr) -> Self {
+ self.custom_socket_addr(socket_addr)
+ }
+}
diff --git a/azalea/src/lib.rs b/azalea/src/lib.rs
index b10b7fc8..0b656896 100644
--- a/azalea/src/lib.rs
+++ b/azalea/src/lib.rs
@@ -7,13 +7,12 @@ pub mod auto_tool;
pub mod bot;
mod builder;
pub mod container;
+mod join_opts;
pub mod nearest_entity;
pub mod pathfinder;
pub mod prelude;
pub mod swarm;
-use std::net::SocketAddr;
-
pub use azalea_auth as auth;
pub use azalea_block as block;
#[doc(hidden)]
@@ -37,7 +36,6 @@ pub use azalea_core::position::{BlockPos, Vec3};
pub use azalea_entity as entity;
pub use azalea_physics as physics;
pub use azalea_protocol as protocol;
-use azalea_protocol::{address::ServerAddr, connect::Proxy};
pub use azalea_registry as registry;
#[doc(hidden)]
#[deprecated(note = "renamed to `Identifier`.")]
@@ -49,6 +47,7 @@ pub use bevy_ecs as ecs;
use bevy_ecs::component::Component;
pub use builder::ClientBuilder;
use futures::future::BoxFuture;
+pub use join_opts::JoinOpts;
pub type BoxHandleFn<S, R> =
Box<dyn Fn(Client, azalea_client::Event, S) -> BoxFuture<'static, R> + Send>;
@@ -63,107 +62,3 @@ pub type HandleFn<S, Fut> = fn(Client, azalea_client::Event, S) -> Fut;
/// [`SwarmBuilder`]: swarm::SwarmBuilder
#[derive(Clone, Component, Default)]
pub struct NoState;
-
-/// Optional settings when adding an account to a swarm or client.
-#[derive(Clone, Debug, Default)]
-#[non_exhaustive]
-pub struct JoinOpts {
- /// The SOCKS5 proxy that this bot will use for connecting to the Minecraft
- /// server.
- pub server_proxy: Option<Proxy>,
- /// The SOCKS5 proxy that will be used when authenticating the bot's join
- /// with Mojang.
- ///
- /// This should typically be either the same as [`Self::server_proxy`] or
- /// `None`.
- ///
- /// This is useful to set if a server has `prevent-proxy-connections`
- /// enabled.
- pub sessionserver_proxy: Option<Proxy>,
- /// Override the server address that this specific bot will send in the
- /// handshake packet.
- #[doc(alias = "custom_address")]
- pub custom_server_addr: Option<ServerAddr>,
- /// Override the IP and port that this specific bot will use to connect
- /// to the server.
- #[doc(alias = "custom_resolved_address")]
- pub custom_socket_addr: Option<SocketAddr>,
-}
-
-impl JoinOpts {
- pub fn new() -> Self {
- Self::default()
- }
-
- pub fn update(&mut self, other: &Self) {
- if let Some(proxy) = other.server_proxy.clone() {
- self.server_proxy = Some(proxy);
- }
- if let Some(proxy) = other.sessionserver_proxy.clone() {
- self.sessionserver_proxy = Some(proxy);
- }
- if let Some(custom_server_addr) = other.custom_server_addr.clone() {
- self.custom_server_addr = Some(custom_server_addr);
- }
- if let Some(custom_socket_addr) = other.custom_socket_addr {
- self.custom_socket_addr = Some(custom_socket_addr);
- }
- }
-
- /// Configure the SOCKS5 proxy used for connecting to the server and for
- /// authenticating with Mojang.
- ///
- /// To configure these separately, for example to only use the proxy for the
- /// Minecraft server and not for authentication, you may use
- /// [`Self::server_proxy`] and [`Self::sessionserver_proxy`] individually.
- #[must_use]
- pub fn proxy(self, proxy: Proxy) -> Self {
- self.server_proxy(proxy.clone()).sessionserver_proxy(proxy)
- }
- /// Configure the SOCKS5 proxy that will be used for connecting to the
- /// Minecraft server.
- ///
- /// To avoid errors on servers with the "prevent-proxy-connections" option
- /// set, you should usually use [`Self::proxy`] instead.
- ///
- /// Also see [`Self::sessionserver_proxy`].
- #[must_use]
- pub fn server_proxy(mut self, proxy: Proxy) -> Self {
- self.server_proxy = Some(proxy);
- self
- }
- /// Configure the SOCKS5 proxy that this bot will use for authenticating the
- /// server join with Mojang's API.
- ///
- /// Also see [`Self::proxy`] and [`Self::server_proxy`].
- #[must_use]
- pub fn sessionserver_proxy(mut self, proxy: Proxy) -> Self {
- self.sessionserver_proxy = Some(proxy);
- self
- }
-
- /// Set the custom address that this bot will send in the handshake packet.
- #[must_use]
- pub fn custom_server_addr(mut self, server_addr: ServerAddr) -> Self {
- self.custom_server_addr = Some(server_addr);
- self
- }
- /// Set the custom resolved address that this bot will use to connect to the
- /// server.
- #[must_use]
- pub fn custom_socket_addr(mut self, socket_addr: SocketAddr) -> Self {
- self.custom_socket_addr = Some(socket_addr);
- self
- }
-
- #[doc(hidden)]
- #[deprecated = "renamed to `custom_server_addr`."]
- pub fn custom_address(self, server_addr: ServerAddr) -> Self {
- self.custom_server_addr(server_addr)
- }
- #[doc(hidden)]
- #[deprecated = "renamed to `custom_socket_addr`."]
- pub fn custom_resolved_address(self, socket_addr: SocketAddr) -> Self {
- self.custom_socket_addr(socket_addr)
- }
-}