Compare commits
No commits in common. "f8c9dab689855aa103f5aaa3b0f4aee8cb6234c7" and "a0fda6f285e636bcceec3ed2dfedff6759702d57" have entirely different histories.
f8c9dab689
...
a0fda6f285
@ -5,10 +5,7 @@ use crate::{
|
|||||||
lua::{self, direction::Direction, player::Player, vec3::Vec3},
|
lua::{self, direction::Direction, player::Player, vec3::Vec3},
|
||||||
particle,
|
particle,
|
||||||
};
|
};
|
||||||
use azalea::{
|
use azalea::{prelude::*, protocol::packets::game::ClientboundGamePacket};
|
||||||
brigadier::exceptions::BuiltInExceptions::DispatcherUnknownCommand, prelude::*,
|
|
||||||
protocol::packets::game::ClientboundGamePacket,
|
|
||||||
};
|
|
||||||
use hyper::{server::conn::http1, service::service_fn};
|
use hyper::{server::conn::http1, service::service_fn};
|
||||||
use hyper_util::rt::TokioIo;
|
use hyper_util::rt::TokioIo;
|
||||||
use log::{debug, error, info, trace};
|
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();
|
let ansi_text = text.to_ansi();
|
||||||
info!("{ansi_text}");
|
info!("{ansi_text}");
|
||||||
|
|
||||||
let mut is_encrypted = false;
|
|
||||||
if let Some(ref sender) = sender {
|
if let Some(ref sender) = sender {
|
||||||
let ncr_options = globals.get::<Table>("NcrOptions").ok();
|
let mut ncr_options = None;
|
||||||
if let Some(ref options) = ncr_options
|
if let Ok(options) = globals.get::<Table>("NcrOptions")
|
||||||
&& let Ok(decrypt) = globals.get::<Function>("ncr_decrypt")
|
&& let Ok(decrypt) = globals.get::<Function>("ncr_decrypt")
|
||||||
&& let Some(plaintext) = decrypt
|
&& let Some(plaintext) = decrypt
|
||||||
.call::<String>((options.clone(), content.clone()))
|
.call::<String>((options.clone(), content.clone()))
|
||||||
@ -43,17 +39,13 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
.as_deref()
|
.as_deref()
|
||||||
.and_then(|s| trim_header(s).ok())
|
.and_then(|s| trim_header(s).ok())
|
||||||
{
|
{
|
||||||
is_encrypted = true;
|
ncr_options = Some(options);
|
||||||
plaintext.clone_into(&mut content);
|
plaintext.clone_into(&mut content);
|
||||||
info!("decrypted message from {sender}: {content}");
|
info!("decrypted message from {sender}: {content}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_whisper
|
if is_whisper && globals.get::<Vec<String>>("Owners")?.contains(sender) {
|
||||||
&& globals
|
if let Err(error) = state.commands.execute(
|
||||||
.get::<Vec<String>>("Owners")
|
|
||||||
.unwrap_or_default()
|
|
||||||
.contains(sender)
|
|
||||||
&& let Err(error) = state.commands.execute(
|
|
||||||
content.clone(),
|
content.clone(),
|
||||||
CommandSource {
|
CommandSource {
|
||||||
client: client.clone(),
|
client: client.clone(),
|
||||||
@ -62,9 +54,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
ncr_options: ncr_options.clone(),
|
ncr_options: ncr_options.clone(),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
)
|
) {
|
||||||
&& error.type_ != DispatcherUnknownCommand
|
|
||||||
{
|
|
||||||
CommandSource {
|
CommandSource {
|
||||||
client,
|
client,
|
||||||
message,
|
message,
|
||||||
@ -74,6 +64,7 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
.reply(&format!("{error:?}"));
|
.reply(&format!("{error:?}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let table = state.lua.create_table()?;
|
let table = state.lua.create_table()?;
|
||||||
table.set("text", text.to_string())?;
|
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("content", content)?;
|
||||||
table.set("uuid", uuid)?;
|
table.set("uuid", uuid)?;
|
||||||
table.set("is_whisper", is_whisper)?;
|
table.set("is_whisper", is_whisper)?;
|
||||||
table.set("is_encrypted", is_encrypted)?;
|
|
||||||
call_listeners(&state, "chat", table).await;
|
call_listeners(&state, "chat", table).await;
|
||||||
}
|
}
|
||||||
Event::Death(packet) => {
|
Event::Death(packet) => {
|
||||||
|
@ -51,11 +51,7 @@ pub fn find_blocks(
|
|||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_all_entities(
|
pub async fn find_all_entities(lua: Lua, client: UserDataRef<Client>, (): ()) -> Result<Vec<Table>> {
|
||||||
lua: Lua,
|
|
||||||
client: UserDataRef<Client>,
|
|
||||||
(): (),
|
|
||||||
) -> Result<Vec<Table>> {
|
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::new();
|
||||||
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
||||||
get_entities!(client)
|
get_entities!(client)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user