Compare commits
No commits in common. "571581767ec6f8a4c6b25619a99d267c658cde0f" and "a957aaeaec9625822086786bcacdf48b3ce0c981" have entirely different histories.
571581767e
...
a957aaeaec
@ -7,12 +7,11 @@ pub mod logging;
|
|||||||
pub mod nochatreports;
|
pub mod nochatreports;
|
||||||
pub mod player;
|
pub mod player;
|
||||||
pub mod system;
|
pub mod system;
|
||||||
pub mod thread;
|
|
||||||
pub mod vec3;
|
pub mod vec3;
|
||||||
|
|
||||||
use crate::{ListenerMap, build_info::built};
|
use crate::{ListenerMap, build_info::built};
|
||||||
use mlua::{Lua, Table};
|
use mlua::{Lua, Table};
|
||||||
use std::io;
|
use std::{io, time::Duration};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -34,12 +33,19 @@ pub fn register_globals(
|
|||||||
globals.set("GIT_COMMIT_HASH", built::GIT_COMMIT_HASH)?;
|
globals.set("GIT_COMMIT_HASH", built::GIT_COMMIT_HASH)?;
|
||||||
globals.set("GIT_COMMIT_HASH_SHORT", built::GIT_COMMIT_HASH_SHORT)?;
|
globals.set("GIT_COMMIT_HASH_SHORT", built::GIT_COMMIT_HASH_SHORT)?;
|
||||||
|
|
||||||
|
globals.set(
|
||||||
|
"sleep",
|
||||||
|
lua.create_async_function(async |_, duration: u64| {
|
||||||
|
tokio::time::sleep(Duration::from_millis(duration)).await;
|
||||||
|
Ok(())
|
||||||
|
})?,
|
||||||
|
)?;
|
||||||
|
|
||||||
block::register_globals(lua, globals)?;
|
block::register_globals(lua, globals)?;
|
||||||
events::register_globals(lua, globals, event_listeners)?;
|
events::register_globals(lua, globals, event_listeners)?;
|
||||||
logging::register_globals(lua, globals)?;
|
logging::register_globals(lua, globals)?;
|
||||||
nochatreports::register_globals(lua, globals)?;
|
nochatreports::register_globals(lua, globals)?;
|
||||||
system::register_globals(lua, globals)?;
|
system::register_globals(lua, globals)
|
||||||
thread::register_globals(lua, globals)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reload(lua: &Lua, sender: Option<String>) -> Result<(), Error> {
|
pub fn reload(lua: &Lua, sender: Option<String>) -> Result<(), Error> {
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
use mlua::{Error, Function, Lua, Result, Table};
|
|
||||||
use std::time::Duration;
|
|
||||||
use tokio::time::{sleep, timeout};
|
|
||||||
|
|
||||||
pub fn register_globals(lua: &Lua, globals: &Table) -> Result<()> {
|
|
||||||
globals.set(
|
|
||||||
"sleep",
|
|
||||||
lua.create_async_function(async |_, duration: u64| {
|
|
||||||
sleep(Duration::from_millis(duration)).await;
|
|
||||||
Ok(())
|
|
||||||
})?,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
globals.set(
|
|
||||||
"timeout",
|
|
||||||
lua.create_async_function(async |_, (duration, function): (u64, Function)| {
|
|
||||||
timeout(
|
|
||||||
Duration::from_millis(duration),
|
|
||||||
function.call_async::<()>(()),
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(Error::external)
|
|
||||||
})?,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
16
src/main.rs
16
src/main.rs
@ -14,7 +14,6 @@ use arguments::Arguments;
|
|||||||
use azalea::{
|
use azalea::{
|
||||||
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
||||||
};
|
};
|
||||||
use azalea_hax::HaxPlugin;
|
|
||||||
use bevy_app::PluginGroup;
|
use bevy_app::PluginGroup;
|
||||||
use bevy_log::{
|
use bevy_log::{
|
||||||
LogPlugin,
|
LogPlugin,
|
||||||
@ -114,14 +113,8 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
};
|
};
|
||||||
let account = if username.contains('@') {
|
|
||||||
Account::microsoft(&username).await?
|
|
||||||
} else {
|
|
||||||
Account::offline(&username)
|
|
||||||
};
|
|
||||||
let Err(error) = ClientBuilder::new_without_plugins()
|
let Err(error) = ClientBuilder::new_without_plugins()
|
||||||
.add_plugins(DefaultBotPlugins)
|
.add_plugins(DefaultBotPlugins)
|
||||||
.add_plugins(HaxPlugin)
|
|
||||||
.add_plugins(default_plugins)
|
.add_plugins(default_plugins)
|
||||||
.add_plugins(record_plugin)
|
.add_plugins(record_plugin)
|
||||||
.set_handler(events::handle_event)
|
.set_handler(events::handle_event)
|
||||||
@ -130,7 +123,14 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
event_listeners,
|
event_listeners,
|
||||||
commands: Arc::new(commands),
|
commands: Arc::new(commands),
|
||||||
})
|
})
|
||||||
.start(account, server)
|
.start(
|
||||||
|
if username.contains('@') {
|
||||||
|
Account::microsoft(&username).await?
|
||||||
|
} else {
|
||||||
|
Account::offline(&username)
|
||||||
|
},
|
||||||
|
server,
|
||||||
|
)
|
||||||
.await;
|
.await;
|
||||||
eprintln!("{error}");
|
eprintln!("{error}");
|
||||||
|
|
||||||
|
@ -68,12 +68,11 @@ impl Recorder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
|
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
|
||||||
self.zip_writer.write_all(
|
let mut data = Vec::with_capacity(raw_packet.len() + 8);
|
||||||
&TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes(),
|
data.extend(TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes());
|
||||||
)?;
|
data.extend(TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes());
|
||||||
self.zip_writer
|
data.extend(raw_packet);
|
||||||
.write_all(&TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes())?;
|
self.zip_writer.write_all(&data)?;
|
||||||
self.zip_writer.write_all(raw_packet)?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user