aboutsummaryrefslogtreecommitdiff
path: root/azalea-client/src/chat.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-client/src/chat.rs')
-rwxr-xr-xazalea-client/src/chat.rs50
1 files changed, 25 insertions, 25 deletions
diff --git a/azalea-client/src/chat.rs b/azalea-client/src/chat.rs
index 80c52baf..de0b8a7d 100755
--- a/azalea-client/src/chat.rs
+++ b/azalea-client/src/chat.rs
@@ -6,12 +6,15 @@ use std::{
};
use azalea_chat::FormattedText;
-use azalea_protocol::packets::game::{
- clientbound_disguised_chat_packet::ClientboundDisguisedChatPacket,
- clientbound_player_chat_packet::ClientboundPlayerChatPacket,
- clientbound_system_chat_packet::ClientboundSystemChatPacket,
- serverbound_chat_command_packet::ServerboundChatCommandPacket,
- serverbound_chat_packet::{LastSeenMessagesUpdate, ServerboundChatPacket},
+use azalea_protocol::packets::{
+ game::{
+ c_disguised_chat::ClientboundDisguisedChat,
+ c_player_chat::ClientboundPlayerChat,
+ c_system_chat::ClientboundSystemChat,
+ s_chat::{LastSeenMessagesUpdate, ServerboundChat},
+ s_chat_command::ServerboundChatCommand,
+ },
+ Packet,
};
use bevy_app::{App, Plugin, Update};
use bevy_ecs::{
@@ -30,9 +33,9 @@ use crate::{
/// A chat packet, either a system message or a chat message.
#[derive(Debug, Clone, PartialEq)]
pub enum ChatPacket {
- System(Arc<ClientboundSystemChatPacket>),
- Player(Arc<ClientboundPlayerChatPacket>),
- Disguised(Arc<ClientboundDisguisedChatPacket>),
+ System(Arc<ClientboundSystemChat>),
+ Player(Arc<ClientboundPlayerChat>),
+ Disguised(Arc<ClientboundDisguisedChat>),
}
macro_rules! regex {
@@ -111,10 +114,10 @@ impl ChatPacket {
self.split_sender_and_content().1
}
- /// Create a new ChatPacket from a string. This is meant to be used as a
+ /// Create a new Chat from a string. This is meant to be used as a
/// convenience function for testing.
pub fn new(message: &str) -> Self {
- ChatPacket::System(Arc::new(ClientboundSystemChatPacket {
+ ChatPacket::System(Arc::new(ClientboundSystemChat {
content: FormattedText::from(message),
overlay: false,
}))
@@ -141,7 +144,7 @@ impl Client {
self.ecs.lock().send_event(SendChatKindEvent {
entity: self.entity,
content: message.to_string(),
- kind: ChatPacketKind::Message,
+ kind: ChatKind::Message,
});
self.run_schedule_sender.send(()).unwrap();
}
@@ -152,7 +155,7 @@ impl Client {
self.ecs.lock().send_event(SendChatKindEvent {
entity: self.entity,
content: command.to_string(),
- kind: ChatPacketKind::Command,
+ kind: ChatKind::Command,
});
self.run_schedule_sender.send(()).unwrap();
}
@@ -215,13 +218,13 @@ pub fn handle_send_chat_event(
send_chat_kind_events.send(SendChatKindEvent {
entity: event.entity,
content: event.content[1..].to_string(),
- kind: ChatPacketKind::Command,
+ kind: ChatKind::Command,
});
} else {
send_chat_kind_events.send(SendChatKindEvent {
entity: event.entity,
content: event.content.clone(),
- kind: ChatPacketKind::Message,
+ kind: ChatKind::Message,
});
}
}
@@ -240,11 +243,11 @@ pub fn handle_send_chat_event(
pub struct SendChatKindEvent {
pub entity: Entity,
pub content: String,
- pub kind: ChatPacketKind,
+ pub kind: ChatKind,
}
/// A kind of chat packet, either a chat message or a command.
-pub enum ChatPacketKind {
+pub enum ChatKind {
Message,
Command,
}
@@ -261,7 +264,7 @@ pub fn handle_send_chat_kind_event(
.take(256)
.collect::<String>();
let packet = match event.kind {
- ChatPacketKind::Message => ServerboundChatPacket {
+ ChatKind::Message => ServerboundChat {
message: content,
timestamp: SystemTime::now()
.duration_since(UNIX_EPOCH)
@@ -273,17 +276,14 @@ pub fn handle_send_chat_kind_event(
signature: None,
last_seen_messages: LastSeenMessagesUpdate::default(),
}
- .get(),
- ChatPacketKind::Command => {
+ .into_variant(),
+ ChatKind::Command => {
// TODO: chat signing
- ServerboundChatCommandPacket { command: content }.get()
+ ServerboundChatCommand { command: content }.into_variant()
}
};
- send_packet_events.send(SendPacketEvent {
- entity: event.entity,
- packet,
- });
+ send_packet_events.send(SendPacketEvent::new(event.entity, packet));
}
}