Compare commits
2 Commits
e81fab7bf8
...
6f5dc4bcff
Author | SHA1 | Date | |
---|---|---|---|
6f5dc4bcff | |||
ca1162e99a |
@ -6,7 +6,7 @@ use crate::{
|
||||
particle,
|
||||
replay::recorder::Recorder,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use anyhow::{Context, Result};
|
||||
use azalea::{
|
||||
brigadier::exceptions::BuiltInExceptions::DispatcherUnknownCommand, prelude::*,
|
||||
protocol::packets::game::ClientboundGamePacket,
|
||||
@ -20,7 +20,7 @@ use std::net::SocketAddr;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow::Result<()> {
|
||||
pub async fn handle_event(client: Client, event: Event, state: State) -> Result<()> {
|
||||
match event {
|
||||
Event::AddPlayer(player_info) => {
|
||||
call_listeners(&state, "add_player", Player::from(player_info)).await;
|
||||
@ -178,12 +178,11 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
||||
debug!("received initialize event");
|
||||
|
||||
let globals = state.lua.globals();
|
||||
let lua_ecs = client.ecs.clone();
|
||||
let ecs = client.ecs.clone();
|
||||
globals.set(
|
||||
"finish_replay_recording",
|
||||
state.lua.create_function_mut(move |_, (): ()| {
|
||||
lua_ecs
|
||||
.lock()
|
||||
ecs.lock()
|
||||
.remove_resource::<Recorder>()
|
||||
.context("recording not active")
|
||||
.map_err(Error::external)?
|
||||
|
@ -22,12 +22,12 @@ pub struct RecordPlugin {
|
||||
impl Plugin for RecordPlugin {
|
||||
fn build(&self, app: &mut bevy_app::App) {
|
||||
if let Some(recorder) = self.recorder.lock().take() {
|
||||
app.insert_resource(recorder);
|
||||
}
|
||||
app.add_systems(First, record_login_packets.before(process_packet_events))
|
||||
app.insert_resource(recorder)
|
||||
.add_systems(First, record_login_packets.before(process_packet_events))
|
||||
.add_systems(First, record_configuration_packets)
|
||||
.add_systems(First, record_game_packets.before(send_packet_events));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn record_login_packets(
|
||||
|
@ -41,7 +41,7 @@ impl Recorder {
|
||||
}
|
||||
|
||||
pub fn finish(mut self) -> Result<()> {
|
||||
let elapsed = self.start.elapsed();
|
||||
let elapsed = self.start.elapsed().as_millis();
|
||||
|
||||
self.zip_writer
|
||||
.start_file("metaData.json", SimpleFileOptions::default())?;
|
||||
@ -49,8 +49,8 @@ impl Recorder {
|
||||
json!({
|
||||
"singleplayer": false,
|
||||
"serverName": self.server,
|
||||
"duration": elapsed.as_millis(),
|
||||
"date": (SystemTime::now().duration_since(UNIX_EPOCH)? - elapsed).as_millis(),
|
||||
"duration": elapsed,
|
||||
"date": SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() - elapsed,
|
||||
"mcversion": VERSION_NAME,
|
||||
"fileFormat": "MCPR",
|
||||
"fileFormatVersion": 14,
|
||||
|
Loading…
x
Reference in New Issue
Block a user