aboutsummaryrefslogtreecommitdiff
path: root/azalea-chat/src
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-chat/src')
-rwxr-xr-xazalea-chat/src/base_component.rs2
-rwxr-xr-xazalea-chat/src/component.rs5
-rwxr-xr-xazalea-chat/src/style.rs2
-rwxr-xr-xazalea-chat/src/text_component.rs2
-rwxr-xr-xazalea-chat/src/translatable_component.rs4
5 files changed, 8 insertions, 7 deletions
diff --git a/azalea-chat/src/base_component.rs b/azalea-chat/src/base_component.rs
index c2f3513d..e532de11 100755
--- a/azalea-chat/src/base_component.rs
+++ b/azalea-chat/src/base_component.rs
@@ -1,6 +1,6 @@
use crate::{style::Style, Component};
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
pub struct BaseComponent {
// implements mutablecomponent
pub siblings: Vec<Component>,
diff --git a/azalea-chat/src/component.rs b/azalea-chat/src/component.rs
index 882a521a..9362a66b 100755
--- a/azalea-chat/src/component.rs
+++ b/azalea-chat/src/component.rs
@@ -13,7 +13,7 @@ use std::{
};
/// A chat component, basically anything you can see in chat.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
pub enum Component {
Text(TextComponent),
Translatable(TranslatableComponent),
@@ -63,13 +63,14 @@ impl Component {
///
/// ```rust
/// use azalea_chat::Component;
+ /// use serde::de::Deserialize;
///
/// let component = Component::deserialize(&serde_json::json!({
/// "text": "Hello, world!",
/// "color": "red",
/// })).unwrap();
///
- /// println!("{}", component.to_ansi());
+ /// println!("{}", component.to_ansi(None));
/// ```
pub fn to_ansi(&self, default_style: Option<&Style>) -> String {
// default the default_style to white if it's not set
diff --git a/azalea-chat/src/style.rs b/azalea-chat/src/style.rs
index 1243d56f..cdf8f86f 100755
--- a/azalea-chat/src/style.rs
+++ b/azalea-chat/src/style.rs
@@ -274,7 +274,7 @@ impl TryFrom<ChatFormatting> for TextColor {
}
}
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct Style {
// these are options instead of just bools because None is different than false in this case
pub color: Option<TextColor>,
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs
index eea66bb7..0d88ca05 100755
--- a/azalea-chat/src/text_component.rs
+++ b/azalea-chat/src/text_component.rs
@@ -3,7 +3,7 @@ use std::fmt::Display;
use crate::{base_component::BaseComponent, style::ChatFormatting, Component};
/// A component that contains text that's the same in all locales.
-#[derive(Clone, Debug, Default)]
+#[derive(Clone, Debug, Default, PartialEq)]
pub struct TextComponent {
pub base: BaseComponent,
pub text: String,
diff --git a/azalea-chat/src/translatable_component.rs b/azalea-chat/src/translatable_component.rs
index d187adda..28725c44 100755
--- a/azalea-chat/src/translatable_component.rs
+++ b/azalea-chat/src/translatable_component.rs
@@ -4,14 +4,14 @@ use crate::{
base_component::BaseComponent, style::Style, text_component::TextComponent, Component,
};
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
pub enum StringOrComponent {
String(String),
Component(Component),
}
/// A message whose content depends on the client's language.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq)]
pub struct TranslatableComponent {
pub base: BaseComponent,
pub key: String,