mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
rename ChatPacket::username and uuid to sender and sender_uuid
This commit is contained in:
parent
09d515c8cd
commit
1fd0292590
4 changed files with 8 additions and 7 deletions
|
@ -103,14 +103,14 @@ impl ChatPacket {
|
|||
/// Get the username of the sender of the message. If it's not a
|
||||
/// player-sent chat message or the sender couldn't be determined, this
|
||||
/// will be None.
|
||||
pub fn username(&self) -> Option<String> {
|
||||
pub fn sender(&self) -> Option<String> {
|
||||
self.split_sender_and_content().0
|
||||
}
|
||||
|
||||
/// Get the UUID of the sender of the message. If it's not a
|
||||
/// player-sent chat message, this will be None (this is sometimes the case
|
||||
/// when a server uses a plugin to modify chat messages).
|
||||
pub fn uuid(&self) -> Option<Uuid> {
|
||||
pub fn sender_uuid(&self) -> Option<Uuid> {
|
||||
match self {
|
||||
ChatPacket::System(_) => None,
|
||||
ChatPacket::Player(m) => Some(m.sender),
|
||||
|
|
|
@ -26,7 +26,7 @@ struct State {
|
|||
|
||||
async fn handle(mut bot: Client, event: Event, state: State) -> anyhow::Result<()> {
|
||||
if let Event::Chat(m) = event {
|
||||
if m.username() == Some(bot.profile.name.clone()) {
|
||||
if m.sender() == Some(bot.profile.name.clone()) {
|
||||
return Ok(());
|
||||
};
|
||||
if m.content() != "go" {
|
||||
|
|
|
@ -24,14 +24,14 @@ impl CommandSource {
|
|||
pub fn reply(&self, message: &str) {
|
||||
if self.chat.is_whisper() {
|
||||
self.bot
|
||||
.chat(&format!("/w {} {}", self.chat.username().unwrap(), message));
|
||||
.chat(&format!("/w {} {}", self.chat.sender().unwrap(), message));
|
||||
} else {
|
||||
self.bot.chat(message);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn entity(&mut self) -> Option<Entity> {
|
||||
let username = self.chat.username()?;
|
||||
let username = self.chat.sender()?;
|
||||
self.bot.entity_by::<With<Player>, &GameProfileComponent>(
|
||||
|profile: &&GameProfileComponent| profile.name == username,
|
||||
)
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use azalea::pathfinder;
|
||||
use azalea::prelude::*;
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Default, Clone, Component)]
|
||||
struct State {
|
||||
|
@ -23,7 +24,7 @@ async fn main() {
|
|||
async fn handle(bot: Client, event: Event, state: State) -> anyhow::Result<()> {
|
||||
match event {
|
||||
Event::Chat(m) => {
|
||||
if m.username() == Some(bot.profile.name) {
|
||||
if m.sender() == Some(bot.profile.name) {
|
||||
return Ok(());
|
||||
};
|
||||
if m.content() == "go" {
|
||||
|
|
Loading…
Add table
Reference in a new issue