1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

move some stuff to the azalea_client::chat mod

This commit is contained in:
Ubuntu 2022-11-17 17:42:30 +00:00
parent 0d004b72ac
commit 00bfcde391
2 changed files with 23 additions and 23 deletions

View file

@ -1,13 +1,32 @@
use std::time::{SystemTime, UNIX_EPOCH};
//! Implementations of chat-related features.
use crate::Client;
use azalea_chat::Component;
use azalea_crypto::MessageSignature;
use azalea_protocol::packets::game::{
clientbound_player_chat_packet::LastSeenMessagesUpdate,
clientbound_player_chat_packet::{ClientboundPlayerChatPacket, LastSeenMessagesUpdate},
clientbound_system_chat_packet::ClientboundSystemChatPacket,
serverbound_chat_command_packet::ServerboundChatCommandPacket,
serverbound_chat_packet::ServerboundChatPacket,
};
use std::time::{SystemTime, UNIX_EPOCH};
use crate::Client;
/// A chat packet, either a system message or a chat message.
#[derive(Debug, Clone)]
pub enum ChatPacket {
System(ClientboundSystemChatPacket),
Player(Box<ClientboundPlayerChatPacket>),
}
impl ChatPacket {
/// Get the message shown in chat for this packet.
pub fn message(&self) -> Component {
match self {
ChatPacket::System(p) => p.content.clone(),
ChatPacket::Player(p) => p.message(false),
}
}
}
impl Client {
/// Sends chat message to the server. This only sends the chat packet and

View file

@ -1,13 +1,11 @@
pub use crate::chat::ChatPacket;
use crate::{movement::WalkDirection, plugins::Plugins, Account, Player};
use azalea_auth::game_profile::GameProfile;
use azalea_chat::Component;
use azalea_core::{ChunkPos, ResourceLocation, Vec3};
use azalea_protocol::{
connect::{Connection, ConnectionError, ReadConnection, WriteConnection},
packets::{
game::{
clientbound_player_chat_packet::ClientboundPlayerChatPacket,
clientbound_system_chat_packet::ClientboundSystemChatPacket,
serverbound_accept_teleportation_packet::ServerboundAcceptTeleportationPacket,
serverbound_client_information_packet::ServerboundClientInformationPacket,
serverbound_custom_payload_packet::ServerboundCustomPayloadPacket,
@ -63,23 +61,6 @@ pub enum Event {
Packet(Box<ClientboundGamePacket>),
}
/// A chat packet, either a system message or a chat message.
#[derive(Debug, Clone)]
pub enum ChatPacket {
System(ClientboundSystemChatPacket),
Player(Box<ClientboundPlayerChatPacket>),
}
impl ChatPacket {
/// Get the message shown in chat for this packet.
pub fn message(&self) -> Component {
match self {
ChatPacket::System(p) => p.content.clone(),
ChatPacket::Player(p) => p.message(false),
}
}
}
/// A player that you control that is currently in a Minecraft server.
#[derive(Clone)]
pub struct Client {