Remove lifetime from TextComponent
This commit is contained in:
parent
6f7433ee68
commit
f772d971f6
@ -5,19 +5,19 @@ use serde::{Deserialize, Serialize};
|
|||||||
/// Action to take on click of the text.
|
/// Action to take on click of the text.
|
||||||
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Eq, Hash)]
|
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize, Eq, Hash)]
|
||||||
#[serde(tag = "action", content = "value", rename_all = "snake_case")]
|
#[serde(tag = "action", content = "value", rename_all = "snake_case")]
|
||||||
pub enum ClickEvent<'a> {
|
pub enum ClickEvent {
|
||||||
/// Opens a URL
|
/// Opens a URL
|
||||||
OpenUrl(Cow<'a, str>),
|
OpenUrl(Cow<'static, str>),
|
||||||
/// Opens a File
|
/// Opens a File
|
||||||
OpenFile(Cow<'a, str>),
|
OpenFile(Cow<'static, str>),
|
||||||
/// Works in signs, but only on the root text component
|
/// Works in signs, but only on the root text component
|
||||||
RunCommand(Cow<'a, str>),
|
RunCommand(Cow<'static, str>),
|
||||||
/// Replaces the contents of the chat box with the text, not necessarily a
|
/// Replaces the contents of the chat box with the text, not necessarily a
|
||||||
/// command.
|
/// command.
|
||||||
SuggestCommand(Cow<'a, str>),
|
SuggestCommand(Cow<'static, str>),
|
||||||
/// Only usable within written books. Changes the page of the book. Indexing
|
/// Only usable within written books. Changes the page of the book. Indexing
|
||||||
/// starts at 1.
|
/// starts at 1.
|
||||||
ChangePage(i32),
|
ChangePage(i32),
|
||||||
/// Copies the given text to system clipboard
|
/// Copies the given text to system clipboard
|
||||||
CopyToClipboard(Cow<'a, str>),
|
CopyToClipboard(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,17 +6,17 @@ use super::TextComponent;
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||||
#[serde(tag = "action", content = "contents", rename_all = "snake_case")]
|
#[serde(tag = "action", content = "contents", rename_all = "snake_case")]
|
||||||
pub enum HoverEvent<'a> {
|
pub enum HoverEvent {
|
||||||
/// Displays a tooltip with the given text.
|
/// Displays a tooltip with the given text.
|
||||||
ShowText(Cow<'a, str>),
|
ShowText(Cow<'static, str>),
|
||||||
/// Shows an item.
|
/// Shows an item.
|
||||||
ShowItem {
|
ShowItem {
|
||||||
/// Resource identifier of the item
|
/// Resource identifier of the item
|
||||||
id: Cow<'a, str>,
|
id: Cow<'static, str>,
|
||||||
/// Number of the items in the stack
|
/// Number of the items in the stack
|
||||||
count: Option<i32>,
|
count: Option<i32>,
|
||||||
/// NBT information about the item (sNBT format)
|
/// NBT information about the item (sNBT format)
|
||||||
tag: Cow<'a, str>,
|
tag: Cow<'static, str>,
|
||||||
},
|
},
|
||||||
/// Shows an entity.
|
/// Shows an entity.
|
||||||
ShowEntity {
|
ShowEntity {
|
||||||
@ -25,9 +25,9 @@ pub enum HoverEvent<'a> {
|
|||||||
/// Resource identifier of the entity
|
/// Resource identifier of the entity
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
kind: Option<Cow<'a, str>>,
|
kind: Option<Cow<'static, str>>,
|
||||||
/// Optional custom name for the entity
|
/// Optional custom name for the entity
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
name: Option<Box<TextComponent<'a>>>,
|
name: Option<Box<TextComponent>>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,37 +17,32 @@ pub mod style;
|
|||||||
/// Represents a Text component
|
/// Represents a Text component
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Hash)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct TextComponent<'a> {
|
pub struct TextComponent {
|
||||||
/// The actual text
|
/// The actual text
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub content: TextContent<'a>,
|
pub content: TextContent,
|
||||||
/// Style of the text. Bold, Italic, underline, Color...
|
/// Style of the text. Bold, Italic, underline, Color...
|
||||||
/// Also has `ClickEvent
|
/// Also has `ClickEvent
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub style: Style<'a>,
|
pub style: Style,
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
/// Extra text components
|
/// Extra text components
|
||||||
pub extra: Vec<TextComponent<'a>>,
|
pub extra: Vec<TextComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TextComponent<'a> {
|
impl TextComponent {
|
||||||
pub fn text(text: &'a str) -> Self {
|
pub fn text<P>(plain: P) -> Self
|
||||||
|
where
|
||||||
|
P: Into<Cow<'static, str>>,
|
||||||
|
{
|
||||||
Self {
|
Self {
|
||||||
content: TextContent::Text { text: text.into() },
|
content: TextContent::Text { text: plain.into() },
|
||||||
style: Style::default(),
|
style: Style::default(),
|
||||||
extra: vec![],
|
extra: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text_string(text: String) -> Self {
|
pub fn add_child(mut self, child: TextComponent) -> Self {
|
||||||
Self {
|
|
||||||
content: TextContent::Text { text: text.into() },
|
|
||||||
style: Style::default(),
|
|
||||||
extra: vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_child(mut self, child: TextComponent<'a>) -> Self {
|
|
||||||
self.extra.push(child);
|
self.extra.push(child);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -92,7 +87,7 @@ impl<'a> TextComponent<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl serde::Serialize for TextComponent<'_> {
|
impl serde::Serialize for TextComponent {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: serde::Serializer,
|
S: serde::Serializer,
|
||||||
@ -101,7 +96,7 @@ impl serde::Serialize for TextComponent<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TextComponent<'a> {
|
impl TextComponent {
|
||||||
pub fn color(mut self, color: Color) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.style.color = Some(color);
|
self.style.color = Some(color);
|
||||||
self
|
self
|
||||||
@ -154,13 +149,13 @@ impl<'a> TextComponent<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Allows for events to occur when the player clicks on text. Only work in chat.
|
/// Allows for events to occur when the player clicks on text. Only work in chat.
|
||||||
pub fn click_event(mut self, event: ClickEvent<'a>) -> Self {
|
pub fn click_event(mut self, event: ClickEvent) -> Self {
|
||||||
self.style.click_event = Some(event);
|
self.style.click_event = Some(event);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows for a tooltip to be displayed when the player hovers their mouse over text.
|
/// Allows for a tooltip to be displayed when the player hovers their mouse over text.
|
||||||
pub fn hover_event(mut self, event: HoverEvent<'a>) -> Self {
|
pub fn hover_event(mut self, event: HoverEvent) -> Self {
|
||||||
self.style.hover_event = Some(event);
|
self.style.hover_event = Some(event);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -184,14 +179,14 @@ impl<'a> TextComponent<'a> {
|
|||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct TempStruct<'a> {
|
struct TempStruct<'a> {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
text: &'a TextContent<'a>,
|
text: &'a TextContent,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
style: &'a Style<'a>,
|
style: &'a Style,
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
#[serde(rename = "extra")]
|
#[serde(rename = "extra")]
|
||||||
extra: Vec<TempStruct<'a>>,
|
extra: Vec<TempStruct<'a>>,
|
||||||
}
|
}
|
||||||
fn convert_extra<'a>(extra: &'a [TextComponent<'a>]) -> Vec<TempStruct<'a>> {
|
fn convert_extra(extra: &[TextComponent]) -> Vec<TempStruct<'_>> {
|
||||||
extra
|
extra
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| TempStruct {
|
.map(|x| TempStruct {
|
||||||
@ -218,22 +213,22 @@ impl<'a> TextComponent<'a> {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum TextContent<'a> {
|
pub enum TextContent {
|
||||||
/// Raw Text
|
/// Raw Text
|
||||||
Text { text: Cow<'a, str> },
|
Text { text: Cow<'static, str> },
|
||||||
/// Translated text
|
/// Translated text
|
||||||
Translate {
|
Translate {
|
||||||
translate: Cow<'a, str>,
|
translate: Cow<'static, str>,
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
with: Vec<TextComponent<'a>>,
|
with: Vec<TextComponent>,
|
||||||
},
|
},
|
||||||
/// Displays the name of one or more entities found by a selector.
|
/// Displays the name of one or more entities found by a selector.
|
||||||
EntityNames {
|
EntityNames {
|
||||||
selector: Cow<'a, str>,
|
selector: Cow<'static, str>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
separator: Option<Cow<'a, str>>,
|
separator: Option<Cow<'static, str>>,
|
||||||
},
|
},
|
||||||
/// A keybind identifier
|
/// A keybind identifier
|
||||||
/// https://minecraft.wiki/w/Controls#Configurable_controls
|
/// https://minecraft.wiki/w/Controls#Configurable_controls
|
||||||
Keybind { keybind: Cow<'a, str> },
|
Keybind { keybind: Cow<'static, str> },
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq, Hash)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Style<'a> {
|
pub struct Style {
|
||||||
/// Changes the color to render the content
|
/// Changes the color to render the content
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub color: Option<Color>,
|
pub color: Option<Color>,
|
||||||
@ -31,10 +31,10 @@ pub struct Style<'a> {
|
|||||||
pub insertion: Option<String>,
|
pub insertion: Option<String>,
|
||||||
/// Allows for events to occur when the player clicks on text. Only work in chat.
|
/// Allows for events to occur when the player clicks on text. Only work in chat.
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub click_event: Option<ClickEvent<'a>>,
|
pub click_event: Option<ClickEvent>,
|
||||||
/// Allows for a tooltip to be displayed when the player hovers their mouse over text.
|
/// Allows for a tooltip to be displayed when the player hovers their mouse over text.
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub hover_event: Option<HoverEvent<'a>>,
|
pub hover_event: Option<HoverEvent>,
|
||||||
/// Allows you to change the font of the text.
|
/// Allows you to change the font of the text.
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub font: Option<String>,
|
pub font: Option<String>,
|
||||||
@ -46,7 +46,7 @@ pub struct Style<'a> {
|
|||||||
pub shadow_color: Option<ARGBColor>,
|
pub shadow_color: Option<ARGBColor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Style<'a> {
|
impl Style {
|
||||||
pub fn color(mut self, color: Color) -> Self {
|
pub fn color(mut self, color: Color) -> Self {
|
||||||
self.color = Some(color);
|
self.color = Some(color);
|
||||||
self
|
self
|
||||||
@ -94,13 +94,13 @@ impl<'a> Style<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Allows for events to occur when the player clicks on text. Only work in chat.
|
/// Allows for events to occur when the player clicks on text. Only work in chat.
|
||||||
pub fn click_event(mut self, event: ClickEvent<'a>) -> Self {
|
pub fn click_event(mut self, event: ClickEvent) -> Self {
|
||||||
self.click_event = Some(event);
|
self.click_event = Some(event);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows for a tooltip to be displayed when the player hovers their mouse over text.
|
/// Allows for a tooltip to be displayed when the player hovers their mouse over text.
|
||||||
pub fn hover_event(mut self, event: HoverEvent<'a>) -> Self {
|
pub fn hover_event(mut self, event: HoverEvent) -> Self {
|
||||||
self.hover_event = Some(event);
|
self.hover_event = Some(event);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
@ -300,7 +300,7 @@ pub trait ByteBufMut {
|
|||||||
|
|
||||||
fn put_string_len(&mut self, val: &str, max_size: usize);
|
fn put_string_len(&mut self, val: &str, max_size: usize);
|
||||||
|
|
||||||
fn put_string_array(&mut self, array: &[String]);
|
fn put_string_array(&mut self, array: &[&str]);
|
||||||
|
|
||||||
fn put_bit_set(&mut self, set: &BitSet);
|
fn put_bit_set(&mut self, set: &BitSet);
|
||||||
|
|
||||||
@ -346,7 +346,7 @@ impl<T: BufMut> ByteBufMut for T {
|
|||||||
self.put(val.as_bytes());
|
self.put(val.as_bytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn put_string_array(&mut self, array: &[String]) {
|
fn put_string_array(&mut self, array: &[&str]) {
|
||||||
for string in array {
|
for string in array {
|
||||||
self.put_string(string)
|
self.put_string(string)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ pub struct CConfigAddResourcePack<'a> {
|
|||||||
url: &'a str,
|
url: &'a str,
|
||||||
hash: &'a str, // max 40
|
hash: &'a str, // max 40
|
||||||
forced: bool,
|
forced: bool,
|
||||||
prompt_message: Option<TextComponent<'a>>,
|
prompt_message: Option<TextComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CConfigAddResourcePack<'a> {
|
impl<'a> CConfigAddResourcePack<'a> {
|
||||||
@ -19,7 +19,7 @@ impl<'a> CConfigAddResourcePack<'a> {
|
|||||||
url: &'a str,
|
url: &'a str,
|
||||||
hash: &'a str,
|
hash: &'a str,
|
||||||
forced: bool,
|
forced: bool,
|
||||||
prompt_message: Option<TextComponent<'a>>,
|
prompt_message: Option<TextComponent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
uuid,
|
uuid,
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
use crate::VarInt;
|
use crate::VarInt;
|
||||||
use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
|
|
||||||
pub enum BosseventAction<'a> {
|
pub enum BosseventAction {
|
||||||
Add {
|
Add {
|
||||||
title: TextComponent<'a>,
|
title: TextComponent,
|
||||||
health: f32,
|
health: f32,
|
||||||
color: VarInt,
|
color: VarInt,
|
||||||
division: VarInt,
|
division: VarInt,
|
||||||
@ -11,7 +11,7 @@ pub enum BosseventAction<'a> {
|
|||||||
},
|
},
|
||||||
Remove,
|
Remove,
|
||||||
UpdateHealth(f32),
|
UpdateHealth(f32),
|
||||||
UpdateTile(TextComponent<'a>),
|
UpdateTile(TextComponent),
|
||||||
UpdateStyle {
|
UpdateStyle {
|
||||||
color: VarInt,
|
color: VarInt,
|
||||||
dividers: VarInt,
|
dividers: VarInt,
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use serde::Serialize;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:set_action_bar_text")]
|
#[client_packet("play:set_action_bar_text")]
|
||||||
pub struct CActionBar<'a> {
|
pub struct CActionBar<'a> {
|
||||||
action_bar: TextComponent<'a>,
|
action_bar: &'a TextComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CActionBar<'a> {
|
impl<'a> CActionBar<'a> {
|
||||||
pub fn new(action_bar: TextComponent<'a>) -> Self {
|
pub fn new(action_bar: &'a TextComponent) -> Self {
|
||||||
Self { action_bar }
|
Self { action_bar }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,19 +6,19 @@ use pumpkin_macros::client_packet;
|
|||||||
|
|
||||||
#[client_packet("play:boss_event")]
|
#[client_packet("play:boss_event")]
|
||||||
pub struct CBossEvent<'a> {
|
pub struct CBossEvent<'a> {
|
||||||
pub uuid: uuid::Uuid,
|
pub uuid: &'a uuid::Uuid,
|
||||||
pub action: BosseventAction<'a>,
|
pub action: BosseventAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CBossEvent<'a> {
|
impl<'a> CBossEvent<'a> {
|
||||||
pub fn new(uuid: uuid::Uuid, action: BosseventAction<'a>) -> Self {
|
pub fn new(uuid: &'a uuid::Uuid, action: BosseventAction) -> Self {
|
||||||
Self { uuid, action }
|
Self { uuid, action }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientPacket for CBossEvent<'_> {
|
impl ClientPacket for CBossEvent<'_> {
|
||||||
fn write(&self, bytebuf: &mut impl BufMut) {
|
fn write(&self, bytebuf: &mut impl BufMut) {
|
||||||
bytebuf.put_uuid(&self.uuid);
|
bytebuf.put_uuid(self.uuid);
|
||||||
let action = &self.action;
|
let action = &self.action;
|
||||||
match action {
|
match action {
|
||||||
BosseventAction::Add {
|
BosseventAction::Add {
|
||||||
|
|||||||
@ -8,11 +8,11 @@ use crate::VarInt;
|
|||||||
#[client_packet("play:player_combat_kill")]
|
#[client_packet("play:player_combat_kill")]
|
||||||
pub struct CCombatDeath<'a> {
|
pub struct CCombatDeath<'a> {
|
||||||
player_id: VarInt,
|
player_id: VarInt,
|
||||||
message: TextComponent<'a>,
|
message: &'a TextComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CCombatDeath<'a> {
|
impl<'a> CCombatDeath<'a> {
|
||||||
pub fn new(player_id: VarInt, message: TextComponent<'a>) -> Self {
|
pub fn new(player_id: VarInt, message: &'a TextComponent) -> Self {
|
||||||
Self { player_id, message }
|
Self { player_id, message }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,20 +5,15 @@ use pumpkin_macros::client_packet;
|
|||||||
use crate::{bytebuf::ByteBufMut, ClientPacket, VarInt};
|
use crate::{bytebuf::ByteBufMut, ClientPacket, VarInt};
|
||||||
|
|
||||||
#[client_packet("play:command_suggestions")]
|
#[client_packet("play:command_suggestions")]
|
||||||
pub struct CCommandSuggestions<'a> {
|
pub struct CCommandSuggestions {
|
||||||
id: VarInt,
|
id: VarInt,
|
||||||
start: VarInt,
|
start: VarInt,
|
||||||
length: VarInt,
|
length: VarInt,
|
||||||
matches: Vec<CommandSuggestion<'a>>,
|
matches: Vec<CommandSuggestion>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CCommandSuggestions<'a> {
|
impl CCommandSuggestions {
|
||||||
pub fn new(
|
pub fn new(id: VarInt, start: VarInt, length: VarInt, matches: Vec<CommandSuggestion>) -> Self {
|
||||||
id: VarInt,
|
|
||||||
start: VarInt,
|
|
||||||
length: VarInt,
|
|
||||||
matches: Vec<CommandSuggestion<'a>>,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
start,
|
start,
|
||||||
@ -28,7 +23,7 @@ impl<'a> CCommandSuggestions<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientPacket for CCommandSuggestions<'_> {
|
impl ClientPacket for CCommandSuggestions {
|
||||||
fn write(&self, bytebuf: &mut impl BufMut) {
|
fn write(&self, bytebuf: &mut impl BufMut) {
|
||||||
bytebuf.put_var_int(&self.id);
|
bytebuf.put_var_int(&self.id);
|
||||||
bytebuf.put_var_int(&self.start);
|
bytebuf.put_var_int(&self.start);
|
||||||
@ -45,13 +40,13 @@ impl ClientPacket for CCommandSuggestions<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Debug)]
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
||||||
pub struct CommandSuggestion<'a> {
|
pub struct CommandSuggestion {
|
||||||
pub suggestion: String,
|
pub suggestion: String,
|
||||||
pub tooltip: Option<TextComponent<'a>>,
|
pub tooltip: Option<TextComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CommandSuggestion<'a> {
|
impl CommandSuggestion {
|
||||||
pub fn new(suggestion: String, tooltip: Option<TextComponent<'a>>) -> Self {
|
pub fn new(suggestion: String, tooltip: Option<TextComponent>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
suggestion,
|
suggestion,
|
||||||
tooltip,
|
tooltip,
|
||||||
|
|||||||
@ -8,18 +8,18 @@ use crate::VarInt;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:disguised_chat")]
|
#[client_packet("play:disguised_chat")]
|
||||||
pub struct CDisguisedChatMessage<'a> {
|
pub struct CDisguisedChatMessage<'a> {
|
||||||
message: TextComponent<'a>,
|
message: &'a TextComponent,
|
||||||
chat_type: VarInt,
|
chat_type: VarInt,
|
||||||
sender_name: TextComponent<'a>,
|
sender_name: &'a TextComponent,
|
||||||
target_name: Option<TextComponent<'a>>,
|
target_name: Option<&'a TextComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CDisguisedChatMessage<'a> {
|
impl<'a> CDisguisedChatMessage<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
message: TextComponent<'a>,
|
message: &'a TextComponent,
|
||||||
chat_type: VarInt,
|
chat_type: VarInt,
|
||||||
sender_name: TextComponent<'a>,
|
sender_name: &'a TextComponent,
|
||||||
target_name: Option<TextComponent<'a>>,
|
target_name: Option<&'a TextComponent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
message,
|
message,
|
||||||
|
|||||||
@ -10,11 +10,11 @@ use crate::VarInt;
|
|||||||
pub struct COpenScreen<'a> {
|
pub struct COpenScreen<'a> {
|
||||||
window_id: VarInt,
|
window_id: VarInt,
|
||||||
window_type: VarInt,
|
window_type: VarInt,
|
||||||
window_title: TextComponent<'a>,
|
window_title: &'a TextComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> COpenScreen<'a> {
|
impl<'a> COpenScreen<'a> {
|
||||||
pub fn new(window_id: VarInt, window_type: VarInt, window_title: TextComponent<'a>) -> Self {
|
pub fn new(window_id: VarInt, window_type: VarInt, window_title: &'a TextComponent) -> Self {
|
||||||
Self {
|
Self {
|
||||||
window_id,
|
window_id,
|
||||||
window_type,
|
window_type,
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use serde::Serialize;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:disconnect")]
|
#[client_packet("play:disconnect")]
|
||||||
pub struct CPlayDisconnect<'a> {
|
pub struct CPlayDisconnect<'a> {
|
||||||
reason: &'a TextComponent<'a>,
|
reason: &'a TextComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CPlayDisconnect<'a> {
|
impl<'a> CPlayDisconnect<'a> {
|
||||||
pub fn new(reason: &'a TextComponent<'a>) -> Self {
|
pub fn new(reason: &'a TextComponent) -> Self {
|
||||||
Self { reason }
|
Self { reason }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,11 +17,11 @@ pub struct CPlayerChatMessage<'a> {
|
|||||||
salt: i64,
|
salt: i64,
|
||||||
previous_messages_count: VarInt,
|
previous_messages_count: VarInt,
|
||||||
previous_messages: &'a [PreviousMessage<'a>], // max 20
|
previous_messages: &'a [PreviousMessage<'a>], // max 20
|
||||||
unsigned_content: Option<TextComponent<'a>>,
|
unsigned_content: Option<TextComponent>,
|
||||||
filter_type: FilterType,
|
filter_type: FilterType,
|
||||||
chat_type: VarInt,
|
chat_type: VarInt,
|
||||||
sender_name: TextComponent<'a>,
|
sender_name: TextComponent,
|
||||||
target_name: Option<TextComponent<'a>>,
|
target_name: Option<TextComponent>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CPlayerChatMessage<'a> {
|
impl<'a> CPlayerChatMessage<'a> {
|
||||||
@ -34,11 +34,11 @@ impl<'a> CPlayerChatMessage<'a> {
|
|||||||
timestamp: i64,
|
timestamp: i64,
|
||||||
salt: i64,
|
salt: i64,
|
||||||
previous_messages: &'a [PreviousMessage<'a>],
|
previous_messages: &'a [PreviousMessage<'a>],
|
||||||
unsigned_content: Option<TextComponent<'a>>,
|
unsigned_content: Option<TextComponent>,
|
||||||
filter_type: FilterType,
|
filter_type: FilterType,
|
||||||
chat_type: VarInt,
|
chat_type: VarInt,
|
||||||
sender_name: TextComponent<'a>,
|
sender_name: TextComponent,
|
||||||
target_name: Option<TextComponent<'a>>,
|
target_name: Option<TextComponent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
sender,
|
sender,
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use serde::Serialize;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:set_title_text")]
|
#[client_packet("play:set_title_text")]
|
||||||
pub struct CTitleText<'a> {
|
pub struct CTitleText<'a> {
|
||||||
title: TextComponent<'a>,
|
title: &'a TextComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CTitleText<'a> {
|
impl<'a> CTitleText<'a> {
|
||||||
pub fn new(title: TextComponent<'a>) -> Self {
|
pub fn new(title: &'a TextComponent) -> Self {
|
||||||
Self { title }
|
Self { title }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use serde::Serialize;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:set_subtitle_text")]
|
#[client_packet("play:set_subtitle_text")]
|
||||||
pub struct CSubtitle<'a> {
|
pub struct CSubtitle<'a> {
|
||||||
subtitle: TextComponent<'a>,
|
subtitle: &'a TextComponent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CSubtitle<'a> {
|
impl<'a> CSubtitle<'a> {
|
||||||
pub fn new(subtitle: TextComponent<'a>) -> Self {
|
pub fn new(subtitle: &'a TextComponent) -> Self {
|
||||||
Self { subtitle }
|
Self { subtitle }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,12 @@ use serde::Serialize;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:system_chat")]
|
#[client_packet("play:system_chat")]
|
||||||
pub struct CSystemChatMessage<'a> {
|
pub struct CSystemChatMessage<'a> {
|
||||||
content: &'a TextComponent<'a>,
|
content: &'a TextComponent,
|
||||||
overlay: bool,
|
overlay: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CSystemChatMessage<'a> {
|
impl<'a> CSystemChatMessage<'a> {
|
||||||
pub fn new(content: &'a TextComponent<'a>, overlay: bool) -> Self {
|
pub fn new(content: &'a TextComponent, overlay: bool) -> Self {
|
||||||
Self { content, overlay }
|
Self { content, overlay }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,18 +8,18 @@ use crate::{bytebuf::ByteBufMut, ClientPacket, NumberFormat, VarInt};
|
|||||||
pub struct CUpdateObjectives<'a> {
|
pub struct CUpdateObjectives<'a> {
|
||||||
objective_name: &'a str,
|
objective_name: &'a str,
|
||||||
mode: u8,
|
mode: u8,
|
||||||
display_name: TextComponent<'a>,
|
display_name: TextComponent,
|
||||||
render_type: VarInt,
|
render_type: VarInt,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CUpdateObjectives<'a> {
|
impl<'a> CUpdateObjectives<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
objective_name: &'a str,
|
objective_name: &'a str,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
display_name: TextComponent<'a>,
|
display_name: TextComponent,
|
||||||
render_type: RenderType,
|
render_type: RenderType,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
objective_name,
|
objective_name,
|
||||||
|
|||||||
@ -11,8 +11,8 @@ pub struct CUpdateScore<'a> {
|
|||||||
entity_name: &'a str,
|
entity_name: &'a str,
|
||||||
objective_name: &'a str,
|
objective_name: &'a str,
|
||||||
value: VarInt,
|
value: VarInt,
|
||||||
display_name: Option<TextComponent<'a>>,
|
display_name: Option<TextComponent>,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CUpdateScore<'a> {
|
impl<'a> CUpdateScore<'a> {
|
||||||
@ -20,8 +20,8 @@ impl<'a> CUpdateScore<'a> {
|
|||||||
entity_name: &'a str,
|
entity_name: &'a str,
|
||||||
objective_name: &'a str,
|
objective_name: &'a str,
|
||||||
value: VarInt,
|
value: VarInt,
|
||||||
display_name: Option<TextComponent<'a>>,
|
display_name: Option<TextComponent>,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
entity_name,
|
entity_name,
|
||||||
|
|||||||
@ -160,13 +160,13 @@ pub struct KnownPack<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub enum NumberFormat<'a> {
|
pub enum NumberFormat {
|
||||||
/// Show nothing
|
/// Show nothing
|
||||||
Blank,
|
Blank,
|
||||||
/// The styling to be used when formatting the score number
|
/// The styling to be used when formatting the score number
|
||||||
Styled(Style<'a>),
|
Styled(Style),
|
||||||
/// The text to be used as placeholder.
|
/// The text to be used as placeholder.
|
||||||
Fixed(TextComponent<'a>),
|
Fixed(TextComponent),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
@ -202,12 +202,12 @@ impl PositionFlag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Label<'a> {
|
pub enum Label {
|
||||||
BuiltIn(LinkType),
|
BuiltIn(LinkType),
|
||||||
TextComponent(TextComponent<'a>),
|
TextComponent(TextComponent),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for Label<'_> {
|
impl Serialize for Label {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
@ -222,12 +222,12 @@ impl Serialize for Label<'_> {
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct Link<'a> {
|
pub struct Link<'a> {
|
||||||
pub is_built_in: bool,
|
pub is_built_in: bool,
|
||||||
pub label: Label<'a>,
|
pub label: Label,
|
||||||
pub url: &'a String,
|
pub url: &'a String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Link<'a> {
|
impl<'a> Link<'a> {
|
||||||
pub fn new(label: Label<'a>, url: &'a String) -> Self {
|
pub fn new(label: Label, url: &'a String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
is_built_in: match label {
|
is_built_in: match label {
|
||||||
Label::BuiltIn(_) => true,
|
Label::BuiltIn(_) => true,
|
||||||
|
|||||||
@ -11,6 +11,6 @@ pub struct ChatType {
|
|||||||
pub struct Decoration {
|
pub struct Decoration {
|
||||||
translation_key: String,
|
translation_key: String,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
style: Option<Style<'static>>,
|
style: Option<Style>,
|
||||||
parameters: Vec<String>,
|
parameters: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ impl ArgumentConsumer for BlockArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ impl ArgumentConsumer for BoolArgConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ impl ArgumentConsumer for BossbarColorArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
let colors = ["blue", "green", "pink", "purple", "red", "white", "yellow"];
|
let colors = ["blue", "green", "pink", "purple", "red", "white", "yellow"];
|
||||||
let suggestions: Vec<CommandSuggestion> = colors
|
let suggestions: Vec<CommandSuggestion> = colors
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@ -51,7 +51,7 @@ impl ArgumentConsumer for BossbarStyleArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
let styles = [
|
let styles = [
|
||||||
"notched_10",
|
"notched_10",
|
||||||
"notched_12",
|
"notched_12",
|
||||||
|
|||||||
@ -52,7 +52,7 @@ where
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ impl ArgumentConsumer for CommandTreeArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
server: &'a Server,
|
server: &'a Server,
|
||||||
input: &'a str,
|
input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
let Some(input) = input.split_single_whitespace_including_empty_parts().last() else {
|
let Some(input) = input.split_single_whitespace_including_empty_parts().last() else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -51,7 +51,7 @@ impl ArgumentConsumer for EntitiesArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,7 +73,7 @@ impl ArgumentConsumer for EntityArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,7 +54,7 @@ impl ArgumentConsumer for GamemodeArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ impl ArgumentConsumer for ItemArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ impl ArgumentConsumer for MsgArgConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ impl ArgumentConsumer for PlayersArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,7 @@ impl ArgumentConsumer for Position2DArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,7 @@ impl ArgumentConsumer for Position3DArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,7 +47,7 @@ impl ArgumentConsumer for BlockPosArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ impl ArgumentConsumer for ResourceLocationArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
if !self.autocomplete {
|
if !self.autocomplete {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ impl ArgumentConsumer for RotationArgumentConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,7 +43,7 @@ impl ArgumentConsumer for SimpleArgConsumer {
|
|||||||
_sender: &CommandSender<'a>,
|
_sender: &CommandSender<'a>,
|
||||||
_server: &'a Server,
|
_server: &'a Server,
|
||||||
_input: &'a str,
|
_input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -577,14 +577,12 @@ pub fn init_command_tree() -> CommandTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn send_success_message(sender: &CommandSender<'_>, message: String) {
|
async fn send_success_message(sender: &CommandSender<'_>, message: String) {
|
||||||
sender
|
sender.send_message(TextComponent::text(message)).await;
|
||||||
.send_message(TextComponent::text(message.as_str()))
|
|
||||||
.await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn send_error_message(sender: &CommandSender<'_>, message: String) {
|
async fn send_error_message(sender: &CommandSender<'_>, message: String) {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(message.as_str()).color(Color::Named(NamedColor::Red)))
|
.send_message(TextComponent::text(message).color(Color::Named(NamedColor::Red)))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,20 +36,20 @@ async fn clear_player(target: &Player) -> usize {
|
|||||||
|
|
||||||
fn clear_command_text_output(item_count: usize, targets: &[Arc<Player>]) -> TextComponent {
|
fn clear_command_text_output(item_count: usize, targets: &[Arc<Player>]) -> TextComponent {
|
||||||
match targets {
|
match targets {
|
||||||
[target] if item_count == 0 => TextComponent::text_string(format!(
|
[target] if item_count == 0 => TextComponent::text(format!(
|
||||||
"No items were found on player {}",
|
"No items were found on player {}",
|
||||||
target.gameprofile.name
|
target.gameprofile.name
|
||||||
))
|
))
|
||||||
.color_named(NamedColor::Red),
|
.color_named(NamedColor::Red),
|
||||||
[target] => TextComponent::text_string(format!(
|
[target] => TextComponent::text(format!(
|
||||||
"Removed {} item(s) on player {}",
|
"Removed {} item(s) on player {}",
|
||||||
item_count, target.gameprofile.name
|
item_count, target.gameprofile.name
|
||||||
)),
|
)),
|
||||||
targets if item_count == 0 => {
|
targets if item_count == 0 => {
|
||||||
TextComponent::text_string(format!("No items were found on {} players", targets.len()))
|
TextComponent::text(format!("No items were found on {} players", targets.len()))
|
||||||
.color_named(NamedColor::Red)
|
.color_named(NamedColor::Red)
|
||||||
}
|
}
|
||||||
targets => TextComponent::text_string(format!(
|
targets => TextComponent::text(format!(
|
||||||
"Removed {item_count} item(s) from {} players",
|
"Removed {item_count} item(s) from {} players",
|
||||||
targets.len()
|
targets.len()
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -144,7 +144,7 @@ impl CommandExecutor for SetblockExecutor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text_string(format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Placed {} blocks of {} from {from} to {to}",
|
"Placed {} blocks of {} from {from} to {to}",
|
||||||
placed_blocks, block.name
|
placed_blocks, block.name
|
||||||
)))
|
)))
|
||||||
|
|||||||
@ -40,14 +40,14 @@ impl CommandExecutor for GamemodeTargetSelf {
|
|||||||
if let Player(target) = sender {
|
if let Player(target) = sender {
|
||||||
if target.gamemode.load() == gamemode {
|
if target.gamemode.load() == gamemode {
|
||||||
target
|
target
|
||||||
.send_system_message(&TextComponent::text(&format!(
|
.send_system_message(&TextComponent::text(format!(
|
||||||
"You already in {gamemode:?} gamemode"
|
"You already in {gamemode:?} gamemode"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
target.set_gamemode(gamemode).await;
|
target.set_gamemode(gamemode).await;
|
||||||
target
|
target
|
||||||
.send_system_message(&TextComponent::text(&format!(
|
.send_system_message(&TextComponent::text(format!(
|
||||||
"Game mode was set to {gamemode:?}"
|
"Game mode was set to {gamemode:?}"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -82,7 +82,7 @@ impl CommandExecutor for GamemodeTargetPlayer {
|
|||||||
if target.gamemode.load() == gamemode {
|
if target.gamemode.load() == gamemode {
|
||||||
if target_count == 1 {
|
if target_count == 1 {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"{} is already in {:?} gamemode",
|
"{} is already in {:?} gamemode",
|
||||||
target.gameprofile.name, gamemode
|
target.gameprofile.name, gamemode
|
||||||
)))
|
)))
|
||||||
@ -92,7 +92,7 @@ impl CommandExecutor for GamemodeTargetPlayer {
|
|||||||
target.set_gamemode(gamemode).await;
|
target.set_gamemode(gamemode).await;
|
||||||
if target_count == 1 {
|
if target_count == 1 {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"{}'s Game mode was set to {:?}",
|
"{}'s Game mode was set to {:?}",
|
||||||
target.gameprofile.name, gamemode
|
target.gameprofile.name, gamemode
|
||||||
)))
|
)))
|
||||||
|
|||||||
@ -56,7 +56,7 @@ impl CommandExecutor for GiveExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text_string(match targets {
|
.send_message(TextComponent::text(match targets {
|
||||||
[target] => format!(
|
[target] => format!(
|
||||||
"Gave {item_count} {} to {}",
|
"Gave {item_count} {} to {}",
|
||||||
item_name, target.gameprofile.name
|
item_name, target.gameprofile.name
|
||||||
|
|||||||
@ -48,12 +48,12 @@ impl CommandExecutor for CommandHelpExecutor {
|
|||||||
|
|
||||||
let mut message = TextComponent::text("")
|
let mut message = TextComponent::text("")
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string("-".repeat((52 - header_text.len()) / 2) + " ")
|
TextComponent::text("-".repeat((52 - header_text.len()) / 2) + " ")
|
||||||
.color_named(NamedColor::Yellow),
|
.color_named(NamedColor::Yellow),
|
||||||
)
|
)
|
||||||
.add_child(TextComponent::text(&header_text))
|
.add_child(TextComponent::text(header_text.clone()))
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(
|
TextComponent::text(
|
||||||
" ".to_owned() + &"-".repeat((52 - header_text.len()) / 2) + "\n",
|
" ".to_owned() + &"-".repeat((52 - header_text.len()) / 2) + "\n",
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Yellow),
|
.color_named(NamedColor::Yellow),
|
||||||
@ -62,7 +62,7 @@ impl CommandExecutor for CommandHelpExecutor {
|
|||||||
TextComponent::text("Command: ")
|
TextComponent::text("Command: ")
|
||||||
.color_named(NamedColor::Aqua)
|
.color_named(NamedColor::Aqua)
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(format!("/{command_names}"))
|
TextComponent::text(format!("/{command_names}"))
|
||||||
.color_named(NamedColor::Gold)
|
.color_named(NamedColor::Gold)
|
||||||
.bold(),
|
.bold(),
|
||||||
)
|
)
|
||||||
@ -75,7 +75,7 @@ impl CommandExecutor for CommandHelpExecutor {
|
|||||||
TextComponent::text("Description: ")
|
TextComponent::text("Description: ")
|
||||||
.color_named(NamedColor::Aqua)
|
.color_named(NamedColor::Aqua)
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(format!("{description}\n"))
|
TextComponent::text(format!("{description}\n"))
|
||||||
.color_named(NamedColor::White),
|
.color_named(NamedColor::White),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -83,14 +83,13 @@ impl CommandExecutor for CommandHelpExecutor {
|
|||||||
TextComponent::text("Usage: ")
|
TextComponent::text("Usage: ")
|
||||||
.color_named(NamedColor::Aqua)
|
.color_named(NamedColor::Aqua)
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(format!("{usage}\n"))
|
TextComponent::text(format!("{usage}\n")).color_named(NamedColor::White),
|
||||||
.color_named(NamedColor::White),
|
|
||||||
)
|
)
|
||||||
.click_event(ClickEvent::SuggestCommand(format!("{tree}").into())),
|
.click_event(ClickEvent::SuggestCommand(format!("{tree}").into())),
|
||||||
);
|
);
|
||||||
|
|
||||||
message = message
|
message =
|
||||||
.add_child(TextComponent::text_string("-".repeat(52)).color_named(NamedColor::Yellow));
|
message.add_child(TextComponent::text("-".repeat(52)).color_named(NamedColor::Yellow));
|
||||||
|
|
||||||
sender.send_message(message).await;
|
sender.send_message(message).await;
|
||||||
|
|
||||||
@ -165,14 +164,14 @@ impl CommandExecutor for BaseHelpExecutor {
|
|||||||
|
|
||||||
let mut message = TextComponent::text("")
|
let mut message = TextComponent::text("")
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string("-".repeat((52 - header_text.len() - 3) / 2) + " ")
|
TextComponent::text("-".repeat((52 - header_text.len() - 3) / 2) + " ")
|
||||||
.color_named(NamedColor::Yellow),
|
.color_named(NamedColor::Yellow),
|
||||||
)
|
)
|
||||||
.add_child(arrow_left.clone())
|
.add_child(arrow_left.clone())
|
||||||
.add_child(TextComponent::text(&header_text))
|
.add_child(TextComponent::text(header_text.clone()))
|
||||||
.add_child(arrow_right.clone())
|
.add_child(arrow_right.clone())
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(
|
TextComponent::text(
|
||||||
" ".to_owned() + &"-".repeat((52 - header_text.len() - 3) / 2) + "\n",
|
" ".to_owned() + &"-".repeat((52 - header_text.len() - 3) / 2) + "\n",
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Yellow),
|
.color_named(NamedColor::Yellow),
|
||||||
@ -180,17 +179,16 @@ impl CommandExecutor for BaseHelpExecutor {
|
|||||||
|
|
||||||
for tree in page_commands {
|
for tree in page_commands {
|
||||||
message = message.add_child(
|
message = message.add_child(
|
||||||
TextComponent::text_string("/".to_owned() + &tree.names.join(", /"))
|
TextComponent::text("/".to_owned() + &tree.names.join(", /"))
|
||||||
.color_named(NamedColor::Gold)
|
.color_named(NamedColor::Gold)
|
||||||
.add_child(TextComponent::text(" - ").color_named(NamedColor::Yellow))
|
.add_child(TextComponent::text(" - ").color_named(NamedColor::Yellow))
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(tree.description.clone() + "\n")
|
TextComponent::text(tree.description.clone() + "\n")
|
||||||
.color_named(NamedColor::White),
|
.color_named(NamedColor::White),
|
||||||
)
|
)
|
||||||
.add_child(TextComponent::text(" Usage: ").color_named(NamedColor::Yellow))
|
.add_child(TextComponent::text(" Usage: ").color_named(NamedColor::Yellow))
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(format!("{tree}"))
|
TextComponent::text(format!("{tree}")).color_named(NamedColor::White),
|
||||||
.color_named(NamedColor::White),
|
|
||||||
)
|
)
|
||||||
.add_child(TextComponent::text("\n").color_named(NamedColor::White))
|
.add_child(TextComponent::text("\n").color_named(NamedColor::White))
|
||||||
.click_event(ClickEvent::SuggestCommand(
|
.click_event(ClickEvent::SuggestCommand(
|
||||||
@ -202,16 +200,14 @@ impl CommandExecutor for BaseHelpExecutor {
|
|||||||
let footer_text = format!(" Page {page}/{total_pages} ");
|
let footer_text = format!(" Page {page}/{total_pages} ");
|
||||||
message = message
|
message = message
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string("-".repeat((52 - footer_text.len() - 3) / 2) + " ")
|
TextComponent::text("-".repeat((52 - footer_text.len() - 3) / 2) + " ")
|
||||||
.color_named(NamedColor::Yellow),
|
.color_named(NamedColor::Yellow),
|
||||||
)
|
)
|
||||||
.add_child(arrow_left)
|
.add_child(arrow_left)
|
||||||
.add_child(TextComponent::text(&footer_text))
|
.add_child(TextComponent::text(footer_text.clone()))
|
||||||
.add_child(arrow_right)
|
.add_child(arrow_right)
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text_string(
|
TextComponent::text(" ".to_owned() + &"-".repeat((52 - footer_text.len() - 3) / 2))
|
||||||
" ".to_owned() + &"-".repeat((52 - footer_text.len() - 3) / 2),
|
|
||||||
)
|
|
||||||
.color_named(NamedColor::Yellow),
|
.color_named(NamedColor::Yellow),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ impl CommandExecutor for KickExecutor {
|
|||||||
let msg = if target_count == 1 {
|
let msg = if target_count == 1 {
|
||||||
TextComponent::text("Player has been kicked.")
|
TextComponent::text("Player has been kicked.")
|
||||||
} else {
|
} else {
|
||||||
TextComponent::text_string(format!("{target_count} players have been kicked."))
|
TextComponent::text(format!("{target_count} players have been kicked."))
|
||||||
};
|
};
|
||||||
|
|
||||||
sender.send_message(msg.color_named(NamedColor::Blue)).await;
|
sender.send_message(msg.color_named(NamedColor::Blue)).await;
|
||||||
|
|||||||
@ -37,7 +37,7 @@ impl CommandExecutor for KillExecutor {
|
|||||||
let msg = if target_count == 1 {
|
let msg = if target_count == 1 {
|
||||||
TextComponent::text("Entity has been killed.")
|
TextComponent::text("Entity has been killed.")
|
||||||
} else {
|
} else {
|
||||||
TextComponent::text_string(format!("{target_count} entities have been killed."))
|
TextComponent::text(format!("{target_count} entities have been killed."))
|
||||||
};
|
};
|
||||||
|
|
||||||
sender.send_message(msg.color_named(NamedColor::Blue)).await;
|
sender.send_message(msg.color_named(NamedColor::Blue)).await;
|
||||||
|
|||||||
@ -28,9 +28,9 @@ impl CommandExecutor for ListExecutor {
|
|||||||
let players: Vec<Arc<Player>> = server.get_all_players().await;
|
let players: Vec<Arc<Player>> = server.get_all_players().await;
|
||||||
|
|
||||||
let message = if players.is_empty() {
|
let message = if players.is_empty() {
|
||||||
"There are no players online."
|
"There are no players online.".to_owned()
|
||||||
} else {
|
} else {
|
||||||
&format!(
|
format!(
|
||||||
"There are {} of a max of {} players online: {}",
|
"There are {} of a max of {} players online: {}",
|
||||||
players.len(),
|
players.len(),
|
||||||
BASIC_CONFIG.max_players,
|
BASIC_CONFIG.max_players,
|
||||||
|
|||||||
@ -63,7 +63,7 @@ impl CommandExecutor for OpExecutor {
|
|||||||
|
|
||||||
let player_name = player.gameprofile.name.clone();
|
let player_name = player.gameprofile.name.clone();
|
||||||
let message = format!("Made {player_name} a server operator.");
|
let message = format!("Made {player_name} a server operator.");
|
||||||
let msg = TextComponent::text(&message);
|
let msg = TextComponent::text(message);
|
||||||
sender.send_message(msg).await;
|
sender.send_message(msg).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,14 +32,14 @@ impl CommandExecutor for PumpkinExecutor {
|
|||||||
) -> Result<(), CommandError> {
|
) -> Result<(), CommandError> {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text(&format!("Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION})"))
|
TextComponent::text(format!("Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION})"))
|
||||||
.hover_event(HoverEvent::ShowText(Cow::from("Click to Copy Version")))
|
.hover_event(HoverEvent::ShowText(Cow::from("Click to Copy Version")))
|
||||||
.click_event(ClickEvent::CopyToClipboard(Cow::from(format!(
|
.click_event(ClickEvent::CopyToClipboard(Cow::from(format!(
|
||||||
"Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION})"
|
"Pumpkin {CARGO_PKG_VERSION} ({GIT_VERSION})"
|
||||||
))))
|
))))
|
||||||
.color_named(NamedColor::Green)
|
.color_named(NamedColor::Green)
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text(&format!(", {CARGO_PKG_DESCRIPTION}"))
|
TextComponent::text(format!(", {CARGO_PKG_DESCRIPTION}"))
|
||||||
.click_event(ClickEvent::CopyToClipboard(Cow::from(
|
.click_event(ClickEvent::CopyToClipboard(Cow::from(
|
||||||
CARGO_PKG_DESCRIPTION,
|
CARGO_PKG_DESCRIPTION,
|
||||||
)))
|
)))
|
||||||
@ -49,7 +49,7 @@ impl CommandExecutor for PumpkinExecutor {
|
|||||||
.color_named(NamedColor::White),
|
.color_named(NamedColor::White),
|
||||||
)
|
)
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text(&format!(
|
TextComponent::text(format!(
|
||||||
" (Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL})"
|
" (Minecraft {CURRENT_MC_VERSION}, Protocol {CURRENT_MC_PROTOCOL})"
|
||||||
))
|
))
|
||||||
.click_event(ClickEvent::CopyToClipboard(Cow::from(format!(
|
.click_event(ClickEvent::CopyToClipboard(Cow::from(format!(
|
||||||
|
|||||||
@ -32,7 +32,7 @@ impl CommandExecutor for SayExecutor {
|
|||||||
|
|
||||||
server
|
server
|
||||||
.broadcast_packet_all(&CSystemChatMessage::new(
|
.broadcast_packet_all(&CSystemChatMessage::new(
|
||||||
&TextComponent::text(&format!("[{sender}] {msg}")),
|
&TextComponent::text(format!("[{sender}] {msg}")),
|
||||||
false,
|
false,
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -38,7 +38,7 @@ impl CommandExecutor for PumpkinExecutor {
|
|||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text("Seed: [")
|
TextComponent::text("Seed: [")
|
||||||
.add_child(
|
.add_child(
|
||||||
TextComponent::text(&seed.clone())
|
TextComponent::text(seed.clone())
|
||||||
.hover_event(HoverEvent::ShowText(Cow::from(
|
.hover_event(HoverEvent::ShowText(Cow::from(
|
||||||
"Click to Copy to Clipboard",
|
"Click to Copy to Clipboard",
|
||||||
)))
|
)))
|
||||||
|
|||||||
@ -67,10 +67,9 @@ impl CommandExecutor for SetblockExecutor {
|
|||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(if success {
|
.send_message(if success {
|
||||||
TextComponent::text_string(format!("Placed block {} at {pos}", block.name,))
|
TextComponent::text(format!("Placed block {} at {pos}", block.name,))
|
||||||
} else {
|
} else {
|
||||||
TextComponent::text_string(format!("Kept block at {pos}"))
|
TextComponent::text(format!("Kept block at {pos}")).color_named(NamedColor::Red)
|
||||||
.color_named(NamedColor::Red)
|
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ impl CommandExecutor for TimeQueryExecutor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sender.send_message(TextComponent::text(&msg)).await;
|
sender.send_message(TextComponent::text(msg)).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ impl CommandExecutor for TimeChangeExecutor {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
sender.send_message(TextComponent::text(&msg)).await;
|
sender.send_message(TextComponent::text(msg)).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ impl CommandExecutor for WorldborderGetExecutor {
|
|||||||
|
|
||||||
let diameter = border.new_diameter.round() as i32;
|
let diameter = border.new_diameter.round() as i32;
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"The world border is currently {diameter} block(s) wide"
|
"The world border is currently {diameter} block(s) wide"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -92,7 +92,7 @@ impl CommandExecutor for WorldborderSetExecutor {
|
|||||||
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
distance_consumer().default_name()
|
distance_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -113,7 +113,7 @@ impl CommandExecutor for WorldborderSetExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the world border to {distance:.1} block(s) wide"
|
"Set the world border to {distance:.1} block(s) wide"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -141,7 +141,7 @@ impl CommandExecutor for WorldborderSetTimeExecutor {
|
|||||||
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
distance_consumer().default_name()
|
distance_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -153,7 +153,7 @@ impl CommandExecutor for WorldborderSetTimeExecutor {
|
|||||||
let Ok(time) = time_consumer().find_arg_default_name(args)? else {
|
let Ok(time) = time_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
time_consumer().default_name()
|
time_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -176,11 +176,11 @@ impl CommandExecutor for WorldborderSetTimeExecutor {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
std::cmp::Ordering::Less => {
|
std::cmp::Ordering::Less => {
|
||||||
sender.send_message(TextComponent::text(&format!("Shrinking the world border to {distance:.2} blocks wide over {time} second(s)"))).await;
|
sender.send_message(TextComponent::text(format!("Shrinking the world border to {distance:.2} blocks wide over {time} second(s)"))).await;
|
||||||
}
|
}
|
||||||
std::cmp::Ordering::Greater => {
|
std::cmp::Ordering::Greater => {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Growing the world border to {distance:.2} blocks wide over {time} seconds"
|
"Growing the world border to {distance:.2} blocks wide over {time} seconds"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -213,7 +213,7 @@ impl CommandExecutor for WorldborderAddExecutor {
|
|||||||
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
distance_consumer().default_name()
|
distance_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -236,7 +236,7 @@ impl CommandExecutor for WorldborderAddExecutor {
|
|||||||
let distance = border.new_diameter + distance;
|
let distance = border.new_diameter + distance;
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the world border to {distance:.1} block(s) wide"
|
"Set the world border to {distance:.1} block(s) wide"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -264,7 +264,7 @@ impl CommandExecutor for WorldborderAddTimeExecutor {
|
|||||||
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
let Ok(distance) = distance_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
distance_consumer().default_name()
|
distance_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -276,7 +276,7 @@ impl CommandExecutor for WorldborderAddTimeExecutor {
|
|||||||
let Ok(time) = time_consumer().find_arg_default_name(args)? else {
|
let Ok(time) = time_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
time_consumer().default_name()
|
time_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -301,11 +301,11 @@ impl CommandExecutor for WorldborderAddTimeExecutor {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
std::cmp::Ordering::Less => {
|
std::cmp::Ordering::Less => {
|
||||||
sender.send_message(TextComponent::text(&format!("Shrinking the world border to {distance:.2} blocks wide over {time} second(s)"))).await;
|
sender.send_message(TextComponent::text(format!("Shrinking the world border to {distance:.2} blocks wide over {time} second(s)"))).await;
|
||||||
}
|
}
|
||||||
std::cmp::Ordering::Greater => {
|
std::cmp::Ordering::Greater => {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Growing the world border to {distance:.2} blocks wide over {time} seconds"
|
"Growing the world border to {distance:.2} blocks wide over {time} seconds"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -338,7 +338,7 @@ impl CommandExecutor for WorldborderCenterExecutor {
|
|||||||
let Vector2 { x, z } = Position2DArgumentConsumer.find_arg_default_name(args)?;
|
let Vector2 { x, z } = Position2DArgumentConsumer.find_arg_default_name(args)?;
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the center of world border to {x:.2}, {z:.2}"
|
"Set the center of world border to {x:.2}, {z:.2}"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -366,7 +366,7 @@ impl CommandExecutor for WorldborderDamageAmountExecutor {
|
|||||||
let Ok(damage_per_block) = damage_per_block_consumer().find_arg_default_name(args)? else {
|
let Ok(damage_per_block) = damage_per_block_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
damage_per_block_consumer().default_name()
|
damage_per_block_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -389,7 +389,7 @@ impl CommandExecutor for WorldborderDamageAmountExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the world border damage to {damage_per_block:.2} per block each second"
|
"Set the world border damage to {damage_per_block:.2} per block each second"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -417,7 +417,7 @@ impl CommandExecutor for WorldborderDamageBufferExecutor {
|
|||||||
let Ok(buffer) = damage_buffer_consumer().find_arg_default_name(args)? else {
|
let Ok(buffer) = damage_buffer_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
damage_buffer_consumer().default_name()
|
damage_buffer_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -440,7 +440,7 @@ impl CommandExecutor for WorldborderDamageBufferExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the world border damage buffer to {buffer:.2} block(s)"
|
"Set the world border damage buffer to {buffer:.2} block(s)"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -468,7 +468,7 @@ impl CommandExecutor for WorldborderWarningDistanceExecutor {
|
|||||||
let Ok(distance) = warning_distance_consumer().find_arg_default_name(args)? else {
|
let Ok(distance) = warning_distance_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
warning_distance_consumer().default_name()
|
warning_distance_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -491,7 +491,7 @@ impl CommandExecutor for WorldborderWarningDistanceExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the world border warning distance to {distance} block(s)"
|
"Set the world border warning distance to {distance} block(s)"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
@ -519,7 +519,7 @@ impl CommandExecutor for WorldborderWarningTimeExecutor {
|
|||||||
let Ok(time) = time_consumer().find_arg_default_name(args)? else {
|
let Ok(time) = time_consumer().find_arg_default_name(args)? else {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(format!(
|
TextComponent::text(format!(
|
||||||
"{} is out of bounds.",
|
"{} is out of bounds.",
|
||||||
time_consumer().default_name()
|
time_consumer().default_name()
|
||||||
))
|
))
|
||||||
@ -542,7 +542,7 @@ impl CommandExecutor for WorldborderWarningTimeExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::text(&format!(
|
.send_message(TextComponent::text(format!(
|
||||||
"Set the world border warning time to {time} second(s)"
|
"Set the world border warning time to {time} second(s)"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -71,7 +71,7 @@ impl CommandDispatcher {
|
|||||||
Ok(err) => {
|
Ok(err) => {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::text_string(err)
|
TextComponent::text(err)
|
||||||
.color_named(pumpkin_core::text::color::NamedColor::Red),
|
.color_named(pumpkin_core::text::color::NamedColor::Red),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -94,7 +94,7 @@ impl CommandDispatcher {
|
|||||||
src: &mut CommandSender<'a>,
|
src: &mut CommandSender<'a>,
|
||||||
server: &'a Server,
|
server: &'a Server,
|
||||||
cmd: &'a str,
|
cmd: &'a str,
|
||||||
) -> Vec<CommandSuggestion<'a>> {
|
) -> Vec<CommandSuggestion> {
|
||||||
let mut parts = cmd.split_whitespace();
|
let mut parts = cmd.split_whitespace();
|
||||||
let Some(key) = parts.next() else {
|
let Some(key) = parts.next() else {
|
||||||
return Vec::new();
|
return Vec::new();
|
||||||
@ -254,7 +254,7 @@ impl CommandDispatcher {
|
|||||||
tree: &'a CommandTree,
|
tree: &'a CommandTree,
|
||||||
raw_args: &mut RawArgs<'a>,
|
raw_args: &mut RawArgs<'a>,
|
||||||
input: &'a str,
|
input: &'a str,
|
||||||
) -> Result<Option<Vec<CommandSuggestion<'a>>>, CommandError> {
|
) -> Result<Option<Vec<CommandSuggestion>>, CommandError> {
|
||||||
let mut parsed_args: ConsumedArgs = HashMap::new();
|
let mut parsed_args: ConsumedArgs = HashMap::new();
|
||||||
|
|
||||||
for node in path.iter().map(|&i| &tree.nodes[i]) {
|
for node in path.iter().map(|&i| &tree.nodes[i]) {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ impl fmt::Display for CommandSender<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CommandSender<'a> {
|
impl<'a> CommandSender<'a> {
|
||||||
pub async fn send_message(&self, text: TextComponent<'a>) {
|
pub async fn send_message(&self, text: TextComponent) {
|
||||||
match self {
|
match self {
|
||||||
CommandSender::Console => log::info!("{}", text.to_pretty_console()),
|
CommandSender::Console => log::info!("{}", text.to_pretty_console()),
|
||||||
CommandSender::Player(c) => c.send_system_message(&text).await,
|
CommandSender::Player(c) => c.send_system_message(&text).await,
|
||||||
|
|||||||
@ -524,7 +524,7 @@ impl Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Kicks the Client with a reason depending on the connection state
|
/// Kicks the Client with a reason depending on the connection state
|
||||||
pub async fn kick<'a>(&self, reason: TextComponent<'a>) {
|
pub async fn kick(&self, reason: TextComponent) {
|
||||||
if self
|
if self
|
||||||
.client
|
.client
|
||||||
.closed
|
.closed
|
||||||
@ -565,7 +565,7 @@ impl Player {
|
|||||||
self.client
|
self.client
|
||||||
.send_packet(&CCombatDeath::new(
|
.send_packet(&CCombatDeath::new(
|
||||||
self.entity_id().into(),
|
self.entity_id().into(),
|
||||||
TextComponent::text("noob"),
|
&TextComponent::text("noob"),
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -640,7 +640,7 @@ impl Player {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_system_message<'a>(&self, text: &TextComponent<'a>) {
|
pub async fn send_system_message(&self, text: &TextComponent) {
|
||||||
self.client
|
self.client
|
||||||
.send_packet(&CSystemChatMessage::new(text, false))
|
.send_packet(&CSystemChatMessage::new(text, false))
|
||||||
.await;
|
.await;
|
||||||
@ -662,9 +662,9 @@ impl Player {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.is_kick() {
|
if e.is_kick() {
|
||||||
if let Some(kick_reason) = e.client_kick_reason() {
|
if let Some(kick_reason) = e.client_kick_reason() {
|
||||||
self.kick(TextComponent::text(&kick_reason)).await;
|
self.kick(TextComponent::text(kick_reason)).await;
|
||||||
} else {
|
} else {
|
||||||
self.kick(TextComponent::text(&format!(
|
self.kick(TextComponent::text(format!(
|
||||||
"Error while reading incoming packet {e}"
|
"Error while reading incoming packet {e}"
|
||||||
)))
|
)))
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ impl Player {
|
|||||||
.send_packet(&COpenScreen::new(
|
.send_packet(&COpenScreen::new(
|
||||||
inventory.total_opened_containers.into(),
|
inventory.total_opened_containers.into(),
|
||||||
VarInt(window_type as i32),
|
VarInt(window_type as i32),
|
||||||
title,
|
&title,
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
drop(inventory);
|
drop(inventory);
|
||||||
|
|||||||
@ -576,7 +576,9 @@ impl Client {
|
|||||||
ConnectionState::Config => self.try_send_packet(&CConfigDisconnect::new(reason)).await,
|
ConnectionState::Config => self.try_send_packet(&CConfigDisconnect::new(reason)).await,
|
||||||
// This way players get kicked when players using client functions (e.g. poll, send_packet)
|
// This way players get kicked when players using client functions (e.g. poll, send_packet)
|
||||||
ConnectionState::Play => {
|
ConnectionState::Play => {
|
||||||
self.try_send_packet(&CPlayDisconnect::new(&TextComponent::text(reason)))
|
self.try_send_packet(&CPlayDisconnect::new(&TextComponent::text(
|
||||||
|
reason.to_owned(),
|
||||||
|
)))
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|||||||
@ -523,10 +523,10 @@ impl Player {
|
|||||||
chat_message.timestamp,
|
chat_message.timestamp,
|
||||||
chat_message.salt,
|
chat_message.salt,
|
||||||
&[],
|
&[],
|
||||||
Some(TextComponent::text(&message)),
|
Some(TextComponent::text(message.clone())),
|
||||||
FilterType::PassThrough,
|
FilterType::PassThrough,
|
||||||
1.into(),
|
1.into(),
|
||||||
TextComponent::text(&gameprofile.name),
|
TextComponent::text(gameprofile.name.clone()),
|
||||||
None,
|
None,
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -63,32 +63,32 @@ impl Player {
|
|||||||
// Maybe this section could be implemented. feel free to change
|
// Maybe this section could be implemented. feel free to change
|
||||||
let bossbar = bossbar.clone();
|
let bossbar = bossbar.clone();
|
||||||
let boss_action = BosseventAction::Add {
|
let boss_action = BosseventAction::Add {
|
||||||
title: TextComponent::text_string(bossbar.title),
|
title: TextComponent::text(bossbar.title),
|
||||||
health: bossbar.health,
|
health: bossbar.health,
|
||||||
color: (bossbar.color as u8).into(),
|
color: (bossbar.color as u8).into(),
|
||||||
division: (bossbar.division as u8).into(),
|
division: (bossbar.division as u8).into(),
|
||||||
flags: bossbar.flags as u8,
|
flags: bossbar.flags as u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
let packet = CBossEvent::new(bossbar.uuid, boss_action);
|
let packet = CBossEvent::new(&bossbar.uuid, boss_action);
|
||||||
self.client.send_packet(&packet).await;
|
self.client.send_packet(&packet).await;
|
||||||
}
|
}
|
||||||
pub async fn remove_bossbar(&self, uuid: Uuid) {
|
pub async fn remove_bossbar(&self, uuid: Uuid) {
|
||||||
let boss_action = BosseventAction::Remove;
|
let boss_action = BosseventAction::Remove;
|
||||||
|
|
||||||
let packet = CBossEvent::new(uuid, boss_action);
|
let packet = CBossEvent::new(&uuid, boss_action);
|
||||||
self.client.send_packet(&packet).await;
|
self.client.send_packet(&packet).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_bossbar_health(&self, uuid: Uuid, health: f32) {
|
pub async fn update_bossbar_health(&self, uuid: &Uuid, health: f32) {
|
||||||
let boss_action = BosseventAction::UpdateHealth(health);
|
let boss_action = BosseventAction::UpdateHealth(health);
|
||||||
|
|
||||||
let packet = CBossEvent::new(uuid, boss_action);
|
let packet = CBossEvent::new(uuid, boss_action);
|
||||||
self.client.send_packet(&packet).await;
|
self.client.send_packet(&packet).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_bossbar_title(&self, uuid: Uuid, title: String) {
|
pub async fn update_bossbar_title(&self, uuid: &Uuid, title: String) {
|
||||||
let boss_action = BosseventAction::UpdateTile(TextComponent::text_string(title));
|
let boss_action = BosseventAction::UpdateTile(TextComponent::text(title));
|
||||||
|
|
||||||
let packet = CBossEvent::new(uuid, boss_action);
|
let packet = CBossEvent::new(uuid, boss_action);
|
||||||
self.client.send_packet(&packet).await;
|
self.client.send_packet(&packet).await;
|
||||||
@ -96,7 +96,7 @@ impl Player {
|
|||||||
|
|
||||||
pub async fn update_bossbar_style(
|
pub async fn update_bossbar_style(
|
||||||
&self,
|
&self,
|
||||||
uuid: Uuid,
|
uuid: &Uuid,
|
||||||
color: BossbarColor,
|
color: BossbarColor,
|
||||||
dividers: BossbarDivisions,
|
dividers: BossbarDivisions,
|
||||||
) {
|
) {
|
||||||
@ -109,7 +109,7 @@ impl Player {
|
|||||||
self.client.send_packet(&packet).await;
|
self.client.send_packet(&packet).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_bossbar_flags(&self, uuid: Uuid, flags: BossbarFlags) {
|
pub async fn update_bossbar_flags(&self, uuid: &Uuid, flags: BossbarFlags) {
|
||||||
let boss_action = BosseventAction::UpdateFlags(flags as u8);
|
let boss_action = BosseventAction::UpdateFlags(flags as u8);
|
||||||
|
|
||||||
let packet = CBossEvent::new(uuid, boss_action);
|
let packet = CBossEvent::new(uuid, boss_action);
|
||||||
|
|||||||
@ -178,7 +178,7 @@ impl CustomBossbars {
|
|||||||
.collect();
|
.collect();
|
||||||
for player in matching_players {
|
for player in matching_players {
|
||||||
player
|
player
|
||||||
.update_bossbar_health(bossbar.bossbar_data.uuid, bossbar.bossbar_data.health)
|
.update_bossbar_health(&bossbar.bossbar_data.uuid, bossbar.bossbar_data.health)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ impl CustomBossbars {
|
|||||||
for player in matching_players {
|
for player in matching_players {
|
||||||
player
|
player
|
||||||
.update_bossbar_title(
|
.update_bossbar_title(
|
||||||
bossbar.bossbar_data.uuid,
|
&bossbar.bossbar_data.uuid,
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -301,7 +301,7 @@ impl CustomBossbars {
|
|||||||
for player in matching_players {
|
for player in matching_players {
|
||||||
player
|
player
|
||||||
.update_bossbar_style(
|
.update_bossbar_style(
|
||||||
bossbar.bossbar_data.uuid,
|
&bossbar.bossbar_data.uuid,
|
||||||
bossbar.bossbar_data.color.clone(),
|
bossbar.bossbar_data.color.clone(),
|
||||||
bossbar.bossbar_data.division.clone(),
|
bossbar.bossbar_data.division.clone(),
|
||||||
)
|
)
|
||||||
@ -343,7 +343,7 @@ impl CustomBossbars {
|
|||||||
for player in matching_players {
|
for player in matching_players {
|
||||||
player
|
player
|
||||||
.update_bossbar_style(
|
.update_bossbar_style(
|
||||||
bossbar.bossbar_data.uuid,
|
&bossbar.bossbar_data.uuid,
|
||||||
bossbar.bossbar_data.color.clone(),
|
bossbar.bossbar_data.color.clone(),
|
||||||
bossbar.bossbar_data.division.clone(),
|
bossbar.bossbar_data.division.clone(),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -722,7 +722,7 @@ impl World {
|
|||||||
// Handle join message
|
// Handle join message
|
||||||
// TODO: Config
|
// TODO: Config
|
||||||
let msg_txt = format!("{} joined the game.", player.gameprofile.name.as_str());
|
let msg_txt = format!("{} joined the game.", player.gameprofile.name.as_str());
|
||||||
let msg_comp = TextComponent::text(msg_txt.as_str()).color_named(NamedColor::Yellow);
|
let msg_comp = TextComponent::text(msg_txt).color_named(NamedColor::Yellow);
|
||||||
for player in current_players.values() {
|
for player in current_players.values() {
|
||||||
player.send_system_message(&msg_comp).await;
|
player.send_system_message(&msg_comp).await;
|
||||||
}
|
}
|
||||||
@ -764,8 +764,7 @@ impl World {
|
|||||||
// Send disconnect message / quit message to players in the same world
|
// Send disconnect message / quit message to players in the same world
|
||||||
// TODO: Config
|
// TODO: Config
|
||||||
let disconn_msg_txt = format!("{} left the game.", player.gameprofile.name.as_str());
|
let disconn_msg_txt = format!("{} left the game.", player.gameprofile.name.as_str());
|
||||||
let disconn_msg_cmp =
|
let disconn_msg_cmp = TextComponent::text(disconn_msg_txt).color_named(NamedColor::Yellow);
|
||||||
TextComponent::text(disconn_msg_txt.as_str()).color_named(NamedColor::Yellow);
|
|
||||||
for player in self.current_players.lock().await.values() {
|
for player in self.current_players.lock().await.values() {
|
||||||
player.send_system_message(&disconn_msg_cmp).await;
|
player.send_system_message(&disconn_msg_cmp).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,18 +78,18 @@ impl Scoreboard {
|
|||||||
|
|
||||||
pub struct ScoreboardObjective<'a> {
|
pub struct ScoreboardObjective<'a> {
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
display_name: TextComponent<'a>,
|
display_name: TextComponent,
|
||||||
render_type: RenderType,
|
render_type: RenderType,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ScoreboardObjective<'a> {
|
impl<'a> ScoreboardObjective<'a> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub const fn new(
|
pub const fn new(
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
display_name: TextComponent<'a>,
|
display_name: TextComponent,
|
||||||
render_type: RenderType,
|
render_type: RenderType,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
name,
|
name,
|
||||||
@ -104,8 +104,8 @@ pub struct ScoreboardScore<'a> {
|
|||||||
entity_name: &'a str,
|
entity_name: &'a str,
|
||||||
objective_name: &'a str,
|
objective_name: &'a str,
|
||||||
value: VarInt,
|
value: VarInt,
|
||||||
display_name: Option<TextComponent<'a>>,
|
display_name: Option<TextComponent>,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ScoreboardScore<'a> {
|
impl<'a> ScoreboardScore<'a> {
|
||||||
@ -114,8 +114,8 @@ impl<'a> ScoreboardScore<'a> {
|
|||||||
entity_name: &'a str,
|
entity_name: &'a str,
|
||||||
objective_name: &'a str,
|
objective_name: &'a str,
|
||||||
value: VarInt,
|
value: VarInt,
|
||||||
display_name: Option<TextComponent<'a>>,
|
display_name: Option<TextComponent>,
|
||||||
number_format: Option<NumberFormat<'a>>,
|
number_format: Option<NumberFormat>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
entity_name,
|
entity_name,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user