1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

fix stuff from merge

This commit is contained in:
mat 2022-11-13 00:42:03 -06:00
parent 9ffe57b9a5
commit 6aad8e20ed
4 changed files with 23 additions and 3 deletions

1
Cargo.lock generated
View file

@ -120,6 +120,7 @@ dependencies = [
"azalea-protocol",
"azalea-world",
"env_logger",
"futures",
"num-traits",
"parking_lot",
"priority-queue",

View file

@ -58,6 +58,18 @@ impl<'a> TryFrom<&'a str> for ServerAddress {
}
}
impl From<SocketAddr> for ServerAddress {
/// Convert an existing SocketAddr into a ServerAddress. This just converts
/// the ip to a string and passes along the port. The resolver will realize
/// it's already an IP address and not do any DNS requests.
fn from(addr: SocketAddr) -> Self {
ServerAddress {
host: addr.ip().to_string(),
port: addr.port(),
}
}
}
#[cfg(test)]
mod tests {
use std::io::Cursor;

View file

@ -17,6 +17,7 @@ azalea-core = {version = "0.3.0", path = "../azalea-core"}
azalea-physics = {version = "0.3.0", path = "../azalea-physics"}
azalea-protocol = {version = "0.3.0", path = "../azalea-protocol"}
azalea-world = {version = "0.3.0", path = "../azalea-world"}
futures = "0.3.25"
num-traits = "0.2.15"
parking_lot = {version = "^0.12.1", features = ["deadlock_detection"]}
priority-queue = "1.3.0"

View file

@ -1,4 +1,4 @@
use crate::{bot, HandleFn};
use crate::{bot, pathfinder, HandleFn};
use azalea_client::{Account, Client, Plugin, Plugins};
use azalea_protocol::ServerAddress;
use std::{future::Future, sync::Arc};
@ -95,6 +95,7 @@ pub async fn start<
let mut plugins = options.plugins;
plugins.add(bot::Plugin::default());
plugins.add(pathfinder::Plugin::default());
bot.plugins = Arc::new(plugins);
let state = options.state;
@ -105,12 +106,17 @@ pub async fn start<
tokio::spawn(plugin.handle(event.clone(), bot.clone()));
}
let bot_plugin = bot.plugins.get::<bot::Plugin>().unwrap().clone();
tokio::spawn(bot::Plugin::handle(
Box::new(bot_plugin),
Box::new(bot.plugins.get::<bot::Plugin>().unwrap().clone()),
event.clone(),
bot.clone(),
));
tokio::spawn(pathfinder::Plugin::handle(
Box::new(bot.plugins.get::<pathfinder::Plugin>().unwrap().clone()),
event.clone(),
bot.clone(),
));
tokio::spawn((options.handle)(bot.clone(), event.clone(), state.clone()));
}