Compare commits

..

No commits in common. "f8c9dab689855aa103f5aaa3b0f4aee8cb6234c7" and "a0fda6f285e636bcceec3ed2dfedff6759702d57" have entirely different histories.

2 changed files with 15 additions and 29 deletions

View File

@ -5,10 +5,7 @@ use crate::{
lua::{self, direction::Direction, player::Player, vec3::Vec3},
particle,
};
use azalea::{
brigadier::exceptions::BuiltInExceptions::DispatcherUnknownCommand, prelude::*,
protocol::packets::game::ClientboundGamePacket,
};
use azalea::{prelude::*, protocol::packets::game::ClientboundGamePacket};
use hyper::{server::conn::http1, service::service_fn};
use hyper_util::rt::TokioIo;
use log::{debug, error, info, trace};
@ -32,10 +29,9 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
let ansi_text = text.to_ansi();
info!("{ansi_text}");
let mut is_encrypted = false;
if let Some(ref sender) = sender {
let ncr_options = globals.get::<Table>("NcrOptions").ok();
if let Some(ref options) = ncr_options
let mut ncr_options = None;
if let Ok(options) = globals.get::<Table>("NcrOptions")
&& let Ok(decrypt) = globals.get::<Function>("ncr_decrypt")
&& let Some(plaintext) = decrypt
.call::<String>((options.clone(), content.clone()))
@ -43,17 +39,13 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
.as_deref()
.and_then(|s| trim_header(s).ok())
{
is_encrypted = true;
ncr_options = Some(options);
plaintext.clone_into(&mut content);
info!("decrypted message from {sender}: {content}");
}
if is_whisper
&& globals
.get::<Vec<String>>("Owners")
.unwrap_or_default()
.contains(sender)
&& let Err(error) = state.commands.execute(
if is_whisper && globals.get::<Vec<String>>("Owners")?.contains(sender) {
if let Err(error) = state.commands.execute(
content.clone(),
CommandSource {
client: client.clone(),
@ -62,9 +54,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
ncr_options: ncr_options.clone(),
}
.into(),
)
&& error.type_ != DispatcherUnknownCommand
{
) {
CommandSource {
client,
message,
@ -74,6 +64,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
.reply(&format!("{error:?}"));
}
}
}
let table = state.lua.create_table()?;
table.set("text", text.to_string())?;
@ -82,7 +73,6 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
table.set("content", content)?;
table.set("uuid", uuid)?;
table.set("is_whisper", is_whisper)?;
table.set("is_encrypted", is_encrypted)?;
call_listeners(&state, "chat", table).await;
}
Event::Death(packet) => {

View File

@ -51,11 +51,7 @@ pub fn find_blocks(
.collect())
}
pub async fn find_all_entities(
lua: Lua,
client: UserDataRef<Client>,
(): (),
) -> Result<Vec<Table>> {
pub async fn find_all_entities(lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<Vec<Table>> {
let mut matched = Vec::new();
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
get_entities!(client)