Compare commits
4 Commits
a0fda6f285
...
f8c9dab689
Author | SHA1 | Date | |
---|---|---|---|
f8c9dab689 | |||
97961b0a49 | |||
74a810b956 | |||
137493320c |
@ -5,7 +5,10 @@ use crate::{
|
|||||||
lua::{self, direction::Direction, player::Player, vec3::Vec3},
|
lua::{self, direction::Direction, player::Player, vec3::Vec3},
|
||||||
particle,
|
particle,
|
||||||
};
|
};
|
||||||
use azalea::{prelude::*, protocol::packets::game::ClientboundGamePacket};
|
use azalea::{
|
||||||
|
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};
|
||||||
@ -29,9 +32,10 @@ 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 mut ncr_options = None;
|
let ncr_options = globals.get::<Table>("NcrOptions").ok();
|
||||||
if let Ok(options) = globals.get::<Table>("NcrOptions")
|
if let Some(ref options) = ncr_options
|
||||||
&& 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()))
|
||||||
@ -39,13 +43,17 @@ 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())
|
||||||
{
|
{
|
||||||
ncr_options = Some(options);
|
is_encrypted = true;
|
||||||
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 && globals.get::<Vec<String>>("Owners")?.contains(sender) {
|
if is_whisper
|
||||||
if let Err(error) = state.commands.execute(
|
&& globals
|
||||||
|
.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(),
|
||||||
@ -54,15 +62,16 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
ncr_options: ncr_options.clone(),
|
ncr_options: ncr_options.clone(),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
) {
|
)
|
||||||
CommandSource {
|
&& error.type_ != DispatcherUnknownCommand
|
||||||
client,
|
{
|
||||||
message,
|
CommandSource {
|
||||||
state: state.clone(),
|
client,
|
||||||
ncr_options,
|
message,
|
||||||
}
|
state: state.clone(),
|
||||||
.reply(&format!("{error:?}"));
|
ncr_options,
|
||||||
}
|
}
|
||||||
|
.reply(&format!("{error:?}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,6 +82,7 @@ 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,7 +51,11 @@ pub fn find_blocks(
|
|||||||
.collect())
|
.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();
|
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