Make TextComponent::translate simpler
This commit is contained in:
parent
4f3c146500
commit
148ac38fe3
2
.github/workflows/typos.yml
vendored
2
.github/workflows/typos.yml
vendored
@ -18,4 +18,4 @@ jobs:
|
|||||||
- name: Checkout Actions Repository
|
- name: Checkout Actions Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Spell Check Repo
|
- name: Spell Check Repo
|
||||||
uses: crate-ci/typos@v1.29.5
|
uses: crate-ci/typos@v1.29.7
|
||||||
@ -91,14 +91,15 @@ impl TextComponent {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn translate<K>(key: K, with: Vec<TextComponent>) -> Self
|
pub fn translate<K, W>(key: K, with: W) -> Self
|
||||||
where
|
where
|
||||||
K: Into<Cow<'static, str>>,
|
K: Into<Cow<'static, str>>,
|
||||||
|
W: Into<Vec<TextComponent>>,
|
||||||
{
|
{
|
||||||
Self(TextComponentBase {
|
Self(TextComponentBase {
|
||||||
content: TextContent::Translate {
|
content: TextContent::Translate {
|
||||||
translate: key.into(),
|
translate: key.into(),
|
||||||
with: with.into_iter().map(|x| x.0).collect(),
|
with: with.into().into_iter().map(|x| x.0).collect(),
|
||||||
},
|
},
|
||||||
style: Style::default(),
|
style: Style::default(),
|
||||||
extra: vec![],
|
extra: vec![],
|
||||||
@ -271,7 +272,7 @@ mod test {
|
|||||||
fn test_serialize_text_component() {
|
fn test_serialize_text_component() {
|
||||||
let msg_comp = TextComponent::translate(
|
let msg_comp = TextComponent::translate(
|
||||||
"multiplayer.player.joined",
|
"multiplayer.player.joined",
|
||||||
[TextComponent::text("NAME".to_string())].into(),
|
[TextComponent::text("NAME".to_string())],
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Yellow);
|
.color_named(NamedColor::Yellow);
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ async fn ban_player(sender: &CommandSender<'_>, player: &Player, reason: Option<
|
|||||||
|
|
||||||
if banned_players.get_entry(&player.gameprofile).is_some() {
|
if banned_players.get_entry(&player.gameprofile).is_some() {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate("commands.ban.failed", [].into()))
|
.send_message(TextComponent::translate("commands.ban.failed", []))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -92,15 +92,14 @@ async fn ban_player(sender: &CommandSender<'_>, player: &Player, reason: Option<
|
|||||||
[
|
[
|
||||||
TextComponent::text(player.gameprofile.name.clone()),
|
TextComponent::text(player.gameprofile.name.clone()),
|
||||||
TextComponent::text(reason),
|
TextComponent::text(reason),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
player
|
player
|
||||||
.kick(TextComponent::translate(
|
.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.banned",
|
"multiplayer.disconnect.banned",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,10 +83,7 @@ async fn ban_ip(sender: &CommandSender<'_>, server: &Server, target: &str, reaso
|
|||||||
|
|
||||||
let Some(target_ip) = parse_ip(target, server).await else {
|
let Some(target_ip) = parse_ip(target, server).await else {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.banip.invalid", []))
|
||||||
"commands.banip.invalid",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -95,7 +92,7 @@ async fn ban_ip(sender: &CommandSender<'_>, server: &Server, target: &str, reaso
|
|||||||
|
|
||||||
if banned_ips.get_entry(&target_ip).is_some() {
|
if banned_ips.get_entry(&target_ip).is_some() {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate("commands.banip.failed", [].into()))
|
.send_message(TextComponent::translate("commands.banip.failed", []))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -124,8 +121,7 @@ async fn ban_ip(sender: &CommandSender<'_>, server: &Server, target: &str, reaso
|
|||||||
[
|
[
|
||||||
TextComponent::text(target_ip.to_string()),
|
TextComponent::text(target_ip.to_string()),
|
||||||
TextComponent::text(reason),
|
TextComponent::text(reason),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -135,8 +131,7 @@ async fn ban_ip(sender: &CommandSender<'_>, server: &Server, target: &str, reaso
|
|||||||
[
|
[
|
||||||
TextComponent::text(affected.len().to_string()),
|
TextComponent::text(affected.len().to_string()),
|
||||||
TextComponent::text(names),
|
TextComponent::text(names),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -144,7 +139,7 @@ async fn ban_ip(sender: &CommandSender<'_>, server: &Server, target: &str, reaso
|
|||||||
target
|
target
|
||||||
.kick(TextComponent::translate(
|
.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.ip_banned",
|
"multiplayer.disconnect.ip_banned",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ impl CommandExecutor for BanListAllExecutor {
|
|||||||
async fn handle_banlist(list: Vec<(String, String, String)>, sender: &CommandSender<'_>) {
|
async fn handle_banlist(list: Vec<(String, String, String)>, sender: &CommandSender<'_>) {
|
||||||
if list.is_empty() {
|
if list.is_empty() {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate("commands.banlist.none", [].into()))
|
.send_message(TextComponent::translate("commands.banlist.none", []))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ async fn handle_banlist(list: Vec<(String, String, String)>, sender: &CommandSen
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.banlist.list",
|
"commands.banlist.list",
|
||||||
[TextComponent::text(list.len().to_string())].into(),
|
[TextComponent::text(list.len().to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -130,8 +130,7 @@ async fn handle_banlist(list: Vec<(String, String, String)>, sender: &CommandSen
|
|||||||
TextComponent::text(name),
|
TextComponent::text(name),
|
||||||
TextComponent::text(source),
|
TextComponent::text(source),
|
||||||
TextComponent::text(reason),
|
TextComponent::text(reason),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ impl CommandExecutor for BossbarAddExecuter {
|
|||||||
sender,
|
sender,
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.bossbar.create.failed",
|
"commands.bossbar.create.failed",
|
||||||
vec![TextComponent::text(namespace.to_string())],
|
[TextComponent::text(namespace.to_string())],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -93,7 +93,7 @@ impl CommandExecutor for BossbarAddExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.create.success",
|
"commands.bossbar.create.success",
|
||||||
vec![bossbar_prefix(bossbar.title.clone(), namespace.to_string())],
|
[bossbar_prefix(bossbar.title.clone(), namespace.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ impl CommandExecutor for BossbarGetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.get.max",
|
"commands.bossbar.get.max",
|
||||||
vec![
|
[
|
||||||
bossbar_prefix(
|
bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
@ -145,7 +145,7 @@ impl CommandExecutor for BossbarGetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.get.value",
|
"commands.bossbar.get.value",
|
||||||
vec![
|
[
|
||||||
bossbar_prefix(
|
bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
@ -165,7 +165,7 @@ impl CommandExecutor for BossbarGetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
state,
|
state,
|
||||||
vec![bossbar_prefix(
|
[bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
)],
|
)],
|
||||||
@ -194,7 +194,7 @@ impl CommandExecutor for BossbarListExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.list.bars.none",
|
"commands.bossbar.list.bars.none",
|
||||||
vec![],
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -203,7 +203,7 @@ impl CommandExecutor for BossbarListExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.list.bars.none",
|
"commands.bossbar.list.bars.none",
|
||||||
vec![],
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -228,7 +228,7 @@ impl CommandExecutor for BossbarListExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.list.bars.some",
|
"commands.bossbar.list.bars.some",
|
||||||
vec![
|
[
|
||||||
TextComponent::text(bossbars.len().to_string()),
|
TextComponent::text(bossbars.len().to_string()),
|
||||||
bossbars_text,
|
bossbars_text,
|
||||||
],
|
],
|
||||||
@ -264,7 +264,7 @@ impl CommandExecutor for BossbarRemoveExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.remove.success",
|
"commands.bossbar.remove.success",
|
||||||
vec![bossbar_prefix(
|
[bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
)],
|
)],
|
||||||
@ -330,7 +330,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.color.success",
|
"commands.bossbar.set.color.success",
|
||||||
vec![bossbar_prefix(
|
[bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
)],
|
)],
|
||||||
@ -344,7 +344,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender,
|
sender,
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"parsing.int.invalid",
|
"parsing.int.invalid",
|
||||||
vec![TextComponent::text(i32::MAX.to_string())],
|
[TextComponent::text(i32::MAX.to_string())],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -373,7 +373,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.max.success",
|
"commands.bossbar.set.max.success",
|
||||||
vec![
|
[
|
||||||
bossbar_prefix(
|
bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
@ -403,7 +403,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.name.success",
|
"commands.bossbar.set.name.success",
|
||||||
vec![bossbar_prefix(text_component, namespace.to_string())],
|
[bossbar_prefix(text_component, namespace.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -426,7 +426,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.players.success.none",
|
"commands.bossbar.set.players.success.none",
|
||||||
vec![bossbar_prefix(
|
[bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
)],
|
)],
|
||||||
@ -463,7 +463,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.players.success.some",
|
"commands.bossbar.set.players.success.some",
|
||||||
vec![
|
[
|
||||||
bossbar_prefix(
|
bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
@ -493,7 +493,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.style.success",
|
"commands.bossbar.set.style.success",
|
||||||
vec![bossbar_prefix(
|
[bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
)],
|
)],
|
||||||
@ -507,7 +507,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender,
|
sender,
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"parsing.int.invalid",
|
"parsing.int.invalid",
|
||||||
vec![TextComponent::text(i32::MAX.to_string())],
|
[TextComponent::text(i32::MAX.to_string())],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -531,7 +531,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.bossbar.set.value.success",
|
"commands.bossbar.set.value.success",
|
||||||
vec![
|
[
|
||||||
bossbar_prefix(
|
bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
@ -568,7 +568,7 @@ impl CommandExecutor for BossbarSetExecuter {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
state,
|
state,
|
||||||
vec![bossbar_prefix(
|
[bossbar_prefix(
|
||||||
bossbar.bossbar_data.title.clone(),
|
bossbar.bossbar_data.title.clone(),
|
||||||
namespace.to_string(),
|
namespace.to_string(),
|
||||||
)],
|
)],
|
||||||
@ -682,7 +682,7 @@ async fn handle_bossbar_error(sender: &CommandSender<'_>, error: BossbarUpdateEr
|
|||||||
sender,
|
sender,
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.bossbar.unknown",
|
"commands.bossbar.unknown",
|
||||||
vec![TextComponent::text(location)],
|
[TextComponent::text(location)],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -695,7 +695,7 @@ async fn handle_bossbar_error(sender: &CommandSender<'_>, error: BossbarUpdateEr
|
|||||||
key.push_str(&format!(".{variation}"));
|
key.push_str(&format!(".{variation}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
send_error_message(sender, TextComponent::translate(key, vec![])).await;
|
send_error_message(sender, TextComponent::translate(key, [])).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,12 +40,12 @@ fn clear_command_text_output(item_count: usize, targets: &[Arc<Player>]) -> Text
|
|||||||
match targets {
|
match targets {
|
||||||
[target] if item_count == 0 => TextComponent::translate(
|
[target] if item_count == 0 => TextComponent::translate(
|
||||||
"clear.failed.single",
|
"clear.failed.single",
|
||||||
vec![TextComponent::text(target.gameprofile.name.clone())],
|
[TextComponent::text(target.gameprofile.name.clone())],
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Red),
|
.color_named(NamedColor::Red),
|
||||||
[target] => TextComponent::translate(
|
[target] => TextComponent::translate(
|
||||||
"commands.clear.success.single",
|
"commands.clear.success.single",
|
||||||
vec![
|
[
|
||||||
TextComponent::text(item_count.to_string()),
|
TextComponent::text(item_count.to_string()),
|
||||||
TextComponent::text(target.gameprofile.name.clone())
|
TextComponent::text(target.gameprofile.name.clone())
|
||||||
.click_event(ClickEvent::SuggestCommand(
|
.click_event(ClickEvent::SuggestCommand(
|
||||||
@ -60,12 +60,12 @@ fn clear_command_text_output(item_count: usize, targets: &[Arc<Player>]) -> Text
|
|||||||
),
|
),
|
||||||
targets if item_count == 0 => TextComponent::translate(
|
targets if item_count == 0 => TextComponent::translate(
|
||||||
"clear.failed.multiple",
|
"clear.failed.multiple",
|
||||||
vec![TextComponent::text(targets.len().to_string())],
|
[TextComponent::text(targets.len().to_string())],
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Red),
|
.color_named(NamedColor::Red),
|
||||||
targets => TextComponent::translate(
|
targets => TextComponent::translate(
|
||||||
"commands.clear.success.multiple",
|
"commands.clear.success.multiple",
|
||||||
vec![
|
[
|
||||||
TextComponent::text(item_count.to_string()),
|
TextComponent::text(item_count.to_string()),
|
||||||
TextComponent::text(targets.len().to_string()),
|
TextComponent::text(targets.len().to_string()),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -41,7 +41,7 @@ async fn send_damage_result(
|
|||||||
if !success {
|
if !success {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate("commands.damage.invulnerable", [].into())
|
TextComponent::translate("commands.damage.invulnerable", [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -54,8 +54,7 @@ async fn send_damage_result(
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(target_name),
|
TextComponent::text(target_name),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ impl CommandExecutor for DeopExecutor {
|
|||||||
let player_name = &player.gameprofile.name;
|
let player_name = &player.gameprofile.name;
|
||||||
let msg = TextComponent::translate(
|
let msg = TextComponent::translate(
|
||||||
"commands.deop.success",
|
"commands.deop.success",
|
||||||
[TextComponent::text(player_name.clone())].into(),
|
[TextComponent::text(player_name.clone())],
|
||||||
);
|
);
|
||||||
sender.send_message(msg).await;
|
sender.send_message(msg).await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,8 +59,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(target.gameprofile.name.clone()),
|
TextComponent::text(target.gameprofile.name.clone()),
|
||||||
TextComponent::text(level.to_string()),
|
TextComponent::text(level.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -72,8 +71,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(target.gameprofile.name.clone()),
|
TextComponent::text(target.gameprofile.name.clone()),
|
||||||
TextComponent::text(points.to_string()),
|
TextComponent::text(points.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -95,8 +93,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(targets_len.to_string()),
|
TextComponent::text(targets_len.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
@ -104,8 +101,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(target_name.unwrap()),
|
TextComponent::text(target_name.unwrap()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,8 +112,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(targets_len.to_string()),
|
TextComponent::text(targets_len.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
@ -125,8 +120,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(target_name.unwrap()),
|
TextComponent::text(target_name.unwrap()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,8 +131,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(targets_len.to_string()),
|
TextComponent::text(targets_len.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
@ -146,8 +139,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(target_name.unwrap()),
|
TextComponent::text(target_name.unwrap()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,8 +150,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(targets_len.to_string()),
|
TextComponent::text(targets_len.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
@ -167,8 +158,7 @@ impl ExperienceExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(amount.to_string()),
|
TextComponent::text(amount.to_string()),
|
||||||
TextComponent::text(target_name.unwrap()),
|
TextComponent::text(target_name.unwrap()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,7 +226,7 @@ impl CommandExecutor for ExperienceExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.experience.set.points.invalid",
|
"commands.experience.set.points.invalid",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -246,7 +236,7 @@ impl CommandExecutor for ExperienceExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.experience.set.points.invalid",
|
"commands.experience.set.points.invalid",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -270,7 +260,7 @@ impl CommandExecutor for ExperienceExecutor {
|
|||||||
Err(error_msg) => {
|
Err(error_msg) => {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(error_msg, [].into())
|
TextComponent::translate(error_msg, [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -151,7 +151,7 @@ impl CommandExecutor for SetblockExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.fill.success",
|
"commands.fill.success",
|
||||||
[TextComponent::text(placed_blocks.to_string())].into(),
|
[TextComponent::text(placed_blocks.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ impl CommandExecutor for GamemodeTargetSelf {
|
|||||||
target
|
target
|
||||||
.send_system_message(&TextComponent::translate(
|
.send_system_message(&TextComponent::translate(
|
||||||
"commands.gamemode.success.self",
|
"commands.gamemode.success.self",
|
||||||
[TextComponent::translate(gamemode_string, [].into())].into(),
|
[TextComponent::translate(gamemode_string, [])],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ impl CommandExecutor for GamemodeTargetPlayer {
|
|||||||
target
|
target
|
||||||
.send_system_message(&TextComponent::translate(
|
.send_system_message(&TextComponent::translate(
|
||||||
"gameMode.changed",
|
"gameMode.changed",
|
||||||
[TextComponent::translate(gamemode_string.clone(), [].into())].into(),
|
[TextComponent::translate(gamemode_string.clone(), [])],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
if target_count == 1 {
|
if target_count == 1 {
|
||||||
@ -92,9 +92,8 @@ impl CommandExecutor for GamemodeTargetPlayer {
|
|||||||
"commands.gamemode.success.other",
|
"commands.gamemode.success.other",
|
||||||
[
|
[
|
||||||
TextComponent::text(target.gameprofile.name.clone()),
|
TextComponent::text(target.gameprofile.name.clone()),
|
||||||
TextComponent::translate(gamemode_string, [].into()),
|
TextComponent::translate(gamemode_string, []),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,8 +83,7 @@ impl CommandExecutor for GiveExecutor {
|
|||||||
.click_event(ClickEvent::SuggestCommand(
|
.click_event(ClickEvent::SuggestCommand(
|
||||||
format!("/tell {} ", targets[0].gameprofile.name.clone()).into(),
|
format!("/tell {} ", targets[0].gameprofile.name.clone()).into(),
|
||||||
)),
|
)),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
@ -100,8 +99,7 @@ impl CommandExecutor for GiveExecutor {
|
|||||||
tag: None,
|
tag: None,
|
||||||
}),
|
}),
|
||||||
TextComponent::text(targets.len().to_string()),
|
TextComponent::text(targets.len().to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
sender.send_message(msg).await;
|
sender.send_message(msg).await;
|
||||||
|
|||||||
@ -34,7 +34,7 @@ impl CommandExecutor for KickExecutor {
|
|||||||
|
|
||||||
let reason = match args.get(&ARG_REASON) {
|
let reason = match args.get(&ARG_REASON) {
|
||||||
Some(Arg::Msg(r)) => TextComponent::text(r.clone()),
|
Some(Arg::Msg(r)) => TextComponent::text(r.clone()),
|
||||||
_ => TextComponent::translate("multiplayer.disconnect.kicked", [].into()),
|
_ => TextComponent::translate("multiplayer.disconnect.kicked", []),
|
||||||
};
|
};
|
||||||
|
|
||||||
for target in targets {
|
for target in targets {
|
||||||
|
|||||||
@ -52,11 +52,11 @@ impl CommandExecutor for KillExecutor {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent::translate("commands.kill.success.single", [entity_display].into())
|
TextComponent::translate("commands.kill.success.single", [entity_display])
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.kill.success.multiple",
|
"commands.kill.success.multiple",
|
||||||
[TextComponent::text(target_count.to_string())].into(),
|
[TextComponent::text(target_count.to_string())],
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -93,8 +93,7 @@ impl CommandExecutor for KillSelfExecutor {
|
|||||||
))
|
))
|
||||||
.click_event(ClickEvent::SuggestCommand(
|
.click_event(ClickEvent::SuggestCommand(
|
||||||
format!("/tell {} ", name.clone()).into(),
|
format!("/tell {} ", name.clone()).into(),
|
||||||
))]
|
))],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@ -34,8 +34,7 @@ impl CommandExecutor for ListExecutor {
|
|||||||
TextComponent::text(players.len().to_string()),
|
TextComponent::text(players.len().to_string()),
|
||||||
TextComponent::text(BASIC_CONFIG.max_players.to_string()),
|
TextComponent::text(BASIC_CONFIG.max_players.to_string()),
|
||||||
TextComponent::text(get_player_names(players)),
|
TextComponent::text(get_player_names(players)),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ impl CommandExecutor for OpExecutor {
|
|||||||
|
|
||||||
if player.permission_lvl.load() == new_level {
|
if player.permission_lvl.load() == new_level {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate("commands.op.failed", [].into()))
|
.send_message(TextComponent::translate("commands.op.failed", []))
|
||||||
.await;
|
.await;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ impl CommandExecutor for OpExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.op.success",
|
"commands.op.success",
|
||||||
[TextComponent::text(player_name.clone())].into(),
|
[TextComponent::text(player_name.clone())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,10 +41,7 @@ impl CommandExecutor for PardonExecutor {
|
|||||||
lock.banned_players.remove(idx);
|
lock.banned_players.remove(idx);
|
||||||
} else {
|
} else {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.pardon.failed", []))
|
||||||
"commands.pardon.failed",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -54,7 +51,7 @@ impl CommandExecutor for PardonExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.pardon.success",
|
"commands.pardon.success",
|
||||||
[TextComponent::text(target)].into(),
|
[TextComponent::text(target)],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -34,10 +34,7 @@ impl CommandExecutor for PardonIpExecutor {
|
|||||||
|
|
||||||
let Ok(ip) = IpAddr::from_str(target) else {
|
let Ok(ip) = IpAddr::from_str(target) else {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.pardonip.invalid", []))
|
||||||
"commands.pardonip.invalid",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
@ -48,10 +45,7 @@ impl CommandExecutor for PardonIpExecutor {
|
|||||||
lock.banned_ips.remove(idx);
|
lock.banned_ips.remove(idx);
|
||||||
} else {
|
} else {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.pardonip.failed", []))
|
||||||
"commands.pardonip.failed",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@ -61,7 +55,7 @@ impl CommandExecutor for PardonIpExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.pardonip.success",
|
"commands.pardonip.success",
|
||||||
[TextComponent::text(ip.to_string())].into(),
|
[TextComponent::text(ip.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -52,7 +52,7 @@ impl CommandExecutor for ParticleExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.particle.success",
|
"commands.particle.success",
|
||||||
[TextComponent::text(format!("{particle:?}"))].into(),
|
[TextComponent::text(format!("{particle:?}"))],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,9 +80,9 @@ impl CommandExecutor for SoundExecutor {
|
|||||||
|
|
||||||
// Get target players, defaults to sender if not specified
|
// Get target players, defaults to sender if not specified
|
||||||
let targets = if let Ok(players) = PlayersArgumentConsumer::find_arg(args, ARG_TARGETS) {
|
let targets = if let Ok(players) = PlayersArgumentConsumer::find_arg(args, ARG_TARGETS) {
|
||||||
players.to_vec()
|
players
|
||||||
} else if let Some(player) = sender.as_player() {
|
} else if let Some(player) = sender.as_player() {
|
||||||
vec![player.clone()]
|
&[player.clone()]
|
||||||
} else {
|
} else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
@ -115,7 +115,7 @@ impl CommandExecutor for SoundExecutor {
|
|||||||
let mut players_who_heard = 0;
|
let mut players_who_heard = 0;
|
||||||
|
|
||||||
// Play sound for each target player
|
// Play sound for each target player
|
||||||
for target in &targets {
|
for target in targets {
|
||||||
let pos = position.unwrap_or(target.living_entity.entity.pos.load());
|
let pos = position.unwrap_or(target.living_entity.entity.pos.load());
|
||||||
|
|
||||||
// Check if player can hear the sound based on volume and distance
|
// Check if player can hear the sound based on volume and distance
|
||||||
@ -134,10 +134,7 @@ impl CommandExecutor for SoundExecutor {
|
|||||||
// Send appropriate message based on results
|
// Send appropriate message based on results
|
||||||
if players_who_heard == 0 {
|
if players_who_heard == 0 {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.playsound.failed", []))
|
||||||
"commands.playsound.failed",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
let sound_name = sound.to_name();
|
let sound_name = sound.to_name();
|
||||||
@ -148,8 +145,7 @@ impl CommandExecutor for SoundExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(sound_name),
|
TextComponent::text(sound_name),
|
||||||
TextComponent::text(targets[0].gameprofile.name.clone()),
|
TextComponent::text(targets[0].gameprofile.name.clone()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
} else {
|
} else {
|
||||||
@ -159,8 +155,7 @@ impl CommandExecutor for SoundExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(sound_name),
|
TextComponent::text(sound_name),
|
||||||
TextComponent::text(players_who_heard.to_string()),
|
TextComponent::text(players_who_heard.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,11 +43,10 @@ impl CommandExecutor for PumpkinExecutor {
|
|||||||
[TextComponent::text(seed.clone())
|
[TextComponent::text(seed.clone())
|
||||||
.hover_event(HoverEvent::show_text(TextComponent::translate(
|
.hover_event(HoverEvent::show_text(TextComponent::translate(
|
||||||
Cow::from("chat.copy.click"),
|
Cow::from("chat.copy.click"),
|
||||||
vec![],
|
[],
|
||||||
)))
|
)))
|
||||||
.click_event(ClickEvent::CopyToClipboard(Cow::from(seed)))
|
.click_event(ClickEvent::CopyToClipboard(Cow::from(seed)))
|
||||||
.color_named(NamedColor::Green)]
|
.color_named(NamedColor::Green)],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@ -75,11 +75,10 @@ impl CommandExecutor for SetblockExecutor {
|
|||||||
TextComponent::text(pos.0.x.to_string()),
|
TextComponent::text(pos.0.x.to_string()),
|
||||||
TextComponent::text(pos.0.y.to_string()),
|
TextComponent::text(pos.0.y.to_string()),
|
||||||
TextComponent::text(pos.0.z.to_string()),
|
TextComponent::text(pos.0.z.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate("commands.setblock.failed", [].into())
|
TextComponent::translate("commands.setblock.failed", [])
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@ -22,8 +22,7 @@ impl CommandExecutor for StopExecutor {
|
|||||||
) -> Result<(), CommandError> {
|
) -> Result<(), CommandError> {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate("commands.stop.stopping", [].into())
|
TextComponent::translate("commands.stop.stopping", []).color_named(NamedColor::Red),
|
||||||
.color_named(NamedColor::Red),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ impl CommandExecutor for SummonExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.summon.success",
|
"commands.summon.success",
|
||||||
[TextComponent::text(format!("{entity:?}"))].into(),
|
[TextComponent::text(format!("{entity:?}"))],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -195,10 +195,7 @@ impl CommandExecutor for TpSelfToEntityExecutor {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("permissions.requires.player", []))
|
||||||
"permissions.requires.player",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -226,10 +223,7 @@ impl CommandExecutor for TpSelfToPosExecutor {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("permissions.requires.player", []))
|
||||||
"permissions.requires.player",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -67,21 +67,21 @@ impl CommandExecutor for TimeQueryExecutor {
|
|||||||
let curr_time = level_time.query_daytime();
|
let curr_time = level_time.query_daytime();
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.time.query",
|
"commands.time.query",
|
||||||
[TextComponent::text(curr_time.to_string())].into(),
|
[TextComponent::text(curr_time.to_string())],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
QueryMode::GameTime => {
|
QueryMode::GameTime => {
|
||||||
let curr_time = level_time.query_gametime();
|
let curr_time = level_time.query_gametime();
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.time.query",
|
"commands.time.query",
|
||||||
[TextComponent::text(curr_time.to_string())].into(),
|
[TextComponent::text(curr_time.to_string())],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
QueryMode::Day => {
|
QueryMode::Day => {
|
||||||
let curr_time = level_time.query_day();
|
let curr_time = level_time.query_day();
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.time.query",
|
"commands.time.query",
|
||||||
[TextComponent::text(curr_time.to_string())].into(),
|
[TextComponent::text(curr_time.to_string())],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -131,7 +131,7 @@ impl CommandExecutor for TimeChangeExecutor {
|
|||||||
let curr_time = level_time.query_daytime();
|
let curr_time = level_time.query_daytime();
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.time.add",
|
"commands.time.add",
|
||||||
[TextComponent::text(curr_time.to_string())].into(),
|
[TextComponent::text(curr_time.to_string())],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Mode::Set(_) => {
|
Mode::Set(_) => {
|
||||||
@ -140,7 +140,7 @@ impl CommandExecutor for TimeChangeExecutor {
|
|||||||
level_time.send_time(world).await;
|
level_time.send_time(world).await;
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
"commands.time.set",
|
"commands.time.set",
|
||||||
[TextComponent::text(time_count.to_string())].into(),
|
[TextComponent::text(time_count.to_string())],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -50,7 +50,7 @@ impl CommandExecutor for ClearOrResetExecutor {
|
|||||||
};
|
};
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
text,
|
text,
|
||||||
[TextComponent::text(targets[0].gameprofile.name.clone())].into(),
|
[TextComponent::text(targets[0].gameprofile.name.clone())],
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let text = if reset {
|
let text = if reset {
|
||||||
@ -58,10 +58,7 @@ impl CommandExecutor for ClearOrResetExecutor {
|
|||||||
} else {
|
} else {
|
||||||
"commands.title.cleared.multiple"
|
"commands.title.cleared.multiple"
|
||||||
};
|
};
|
||||||
TextComponent::translate(
|
TextComponent::translate(text, [TextComponent::text(targets.len().to_string())])
|
||||||
text,
|
|
||||||
[TextComponent::text(targets.len().to_string())].into(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
@ -96,12 +93,12 @@ impl CommandExecutor for TitleExecutor {
|
|||||||
.send_message(if targets.len() == 1 {
|
.send_message(if targets.len() == 1 {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
format!("commands.title.show.{mode_name}.single"),
|
format!("commands.title.show.{mode_name}.single"),
|
||||||
[TextComponent::text(targets[0].gameprofile.name.clone())].into(),
|
[TextComponent::text(targets[0].gameprofile.name.clone())],
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TextComponent::translate(
|
TextComponent::translate(
|
||||||
format!("commands.title.show.{mode_name}.multiple"),
|
format!("commands.title.show.{mode_name}.multiple"),
|
||||||
[TextComponent::text(targets.len().to_string())].into(),
|
[TextComponent::text(targets.len().to_string())],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@ -43,10 +43,7 @@ impl CommandExecutor for WeatherExecutor {
|
|||||||
.set_weather_parameters(&world, duration, 0, false, false)
|
.set_weather_parameters(&world, duration, 0, false, false)
|
||||||
.await;
|
.await;
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.weather.set.clear", []))
|
||||||
"commands.weather.set.clear",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
WeatherMode::Rain => {
|
WeatherMode::Rain => {
|
||||||
@ -54,10 +51,7 @@ impl CommandExecutor for WeatherExecutor {
|
|||||||
.set_weather_parameters(&world, 0, duration, true, false)
|
.set_weather_parameters(&world, 0, duration, true, false)
|
||||||
.await;
|
.await;
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.weather.set.rain", []))
|
||||||
"commands.weather.set.rain",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
WeatherMode::Thunder => {
|
WeatherMode::Thunder => {
|
||||||
@ -65,10 +59,7 @@ impl CommandExecutor for WeatherExecutor {
|
|||||||
.set_weather_parameters(&world, 0, duration, true, true)
|
.set_weather_parameters(&world, 0, duration, true, true)
|
||||||
.await;
|
.await;
|
||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate("commands.weather.set.thunder", []))
|
||||||
"commands.weather.set.thunder",
|
|
||||||
[].into(),
|
|
||||||
))
|
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,7 @@ impl CommandExecutor for WorldborderGetExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.get",
|
"commands.worldborder.get",
|
||||||
[TextComponent::text(diameter.to_string())].into(),
|
[TextComponent::text(diameter.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -109,7 +109,7 @@ impl CommandExecutor for WorldborderSetExecutor {
|
|||||||
if (distance - border.new_diameter).abs() < f64::EPSILON {
|
if (distance - border.new_diameter).abs() < f64::EPSILON {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [].into())
|
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -120,7 +120,7 @@ impl CommandExecutor for WorldborderSetExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.set.immediate",
|
"commands.worldborder.set.immediate",
|
||||||
[TextComponent::text(dist)].into(),
|
[TextComponent::text(dist)],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.set_diameter(world, distance, None).await;
|
border.set_diameter(world, distance, None).await;
|
||||||
@ -174,7 +174,7 @@ impl CommandExecutor for WorldborderSetTimeExecutor {
|
|||||||
std::cmp::Ordering::Equal => {
|
std::cmp::Ordering::Equal => {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [].into())
|
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -188,8 +188,7 @@ impl CommandExecutor for WorldborderSetTimeExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(dist),
|
TextComponent::text(dist),
|
||||||
TextComponent::text(time.to_string()),
|
TextComponent::text(time.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -201,8 +200,7 @@ impl CommandExecutor for WorldborderSetTimeExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(dist),
|
TextComponent::text(dist),
|
||||||
TextComponent::text(time.to_string()),
|
TextComponent::text(time.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -248,7 +246,7 @@ impl CommandExecutor for WorldborderAddExecutor {
|
|||||||
if distance == 0.0 {
|
if distance == 0.0 {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [].into())
|
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -261,7 +259,7 @@ impl CommandExecutor for WorldborderAddExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.set.immediate",
|
"commands.worldborder.set.immediate",
|
||||||
[TextComponent::text(dist)].into(),
|
[TextComponent::text(dist)],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.set_diameter(world, distance, None).await;
|
border.set_diameter(world, distance, None).await;
|
||||||
@ -317,7 +315,7 @@ impl CommandExecutor for WorldborderAddTimeExecutor {
|
|||||||
std::cmp::Ordering::Equal => {
|
std::cmp::Ordering::Equal => {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [].into())
|
TextComponent::translate(NOTHING_CHANGED_EXCEPTION, [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -331,8 +329,7 @@ impl CommandExecutor for WorldborderAddTimeExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(dist),
|
TextComponent::text(dist),
|
||||||
TextComponent::text(time.to_string()),
|
TextComponent::text(time.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -344,8 +341,7 @@ impl CommandExecutor for WorldborderAddTimeExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(dist),
|
TextComponent::text(dist),
|
||||||
TextComponent::text(time.to_string()),
|
TextComponent::text(time.to_string()),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -383,8 +379,7 @@ impl CommandExecutor for WorldborderCenterExecutor {
|
|||||||
[
|
[
|
||||||
TextComponent::text(format!("{x:.2}")),
|
TextComponent::text(format!("{x:.2}")),
|
||||||
TextComponent::text(format!("{z:.2}")),
|
TextComponent::text(format!("{z:.2}")),
|
||||||
]
|
],
|
||||||
.into(),
|
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.set_center(world, x, z).await;
|
border.set_center(world, x, z).await;
|
||||||
@ -425,11 +420,8 @@ impl CommandExecutor for WorldborderDamageAmountExecutor {
|
|||||||
if (damage_per_block - border.damage_per_block).abs() < f32::EPSILON {
|
if (damage_per_block - border.damage_per_block).abs() < f32::EPSILON {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(
|
TextComponent::translate("commands.worldborder.damage.amount.failed", [])
|
||||||
"commands.worldborder.damage.amount.failed",
|
.color(Color::Named(NamedColor::Red)),
|
||||||
[].into(),
|
|
||||||
)
|
|
||||||
.color(Color::Named(NamedColor::Red)),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -439,7 +431,7 @@ impl CommandExecutor for WorldborderDamageAmountExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.damage.amount.success",
|
"commands.worldborder.damage.amount.success",
|
||||||
[TextComponent::text(damage)].into(),
|
[TextComponent::text(damage)],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.damage_per_block = damage_per_block;
|
border.damage_per_block = damage_per_block;
|
||||||
@ -480,11 +472,8 @@ impl CommandExecutor for WorldborderDamageBufferExecutor {
|
|||||||
if (buffer - border.buffer).abs() < f32::EPSILON {
|
if (buffer - border.buffer).abs() < f32::EPSILON {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(
|
TextComponent::translate("commands.worldborder.damage.buffer.failed", [])
|
||||||
"commands.worldborder.damage.buffer.failed",
|
.color(Color::Named(NamedColor::Red)),
|
||||||
[].into(),
|
|
||||||
)
|
|
||||||
.color(Color::Named(NamedColor::Red)),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -494,7 +483,7 @@ impl CommandExecutor for WorldborderDamageBufferExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.damage.buffer.success",
|
"commands.worldborder.damage.buffer.success",
|
||||||
[TextComponent::text(buf)].into(),
|
[TextComponent::text(buf)],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.buffer = buffer;
|
border.buffer = buffer;
|
||||||
@ -535,11 +524,8 @@ impl CommandExecutor for WorldborderWarningDistanceExecutor {
|
|||||||
if distance == border.warning_blocks {
|
if distance == border.warning_blocks {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate(
|
TextComponent::translate("commands.worldborder.warning.distance.failed", [])
|
||||||
"commands.worldborder.warning.distance.failed",
|
.color(Color::Named(NamedColor::Red)),
|
||||||
[].into(),
|
|
||||||
)
|
|
||||||
.color(Color::Named(NamedColor::Red)),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -548,7 +534,7 @@ impl CommandExecutor for WorldborderWarningDistanceExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.warning.distance.success",
|
"commands.worldborder.warning.distance.success",
|
||||||
[TextComponent::text(distance.to_string())].into(),
|
[TextComponent::text(distance.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.set_warning_distance(world, distance).await;
|
border.set_warning_distance(world, distance).await;
|
||||||
@ -589,7 +575,7 @@ impl CommandExecutor for WorldborderWarningTimeExecutor {
|
|||||||
if time == border.warning_time {
|
if time == border.warning_time {
|
||||||
sender
|
sender
|
||||||
.send_message(
|
.send_message(
|
||||||
TextComponent::translate("commands.worldborder.warning.time.failed", [].into())
|
TextComponent::translate("commands.worldborder.warning.time.failed", [])
|
||||||
.color(Color::Named(NamedColor::Red)),
|
.color(Color::Named(NamedColor::Red)),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
@ -599,7 +585,7 @@ impl CommandExecutor for WorldborderWarningTimeExecutor {
|
|||||||
sender
|
sender
|
||||||
.send_message(TextComponent::translate(
|
.send_message(TextComponent::translate(
|
||||||
"commands.worldborder.warning.time.success",
|
"commands.worldborder.warning.time.success",
|
||||||
[TextComponent::text(time.to_string())].into(),
|
[TextComponent::text(time.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
border.set_warning_delay(world, time).await;
|
border.set_warning_delay(world, time).await;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ impl LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn send_equipment_changes(&self, equipment: Vec<(EquipmentSlot, ItemStack)>) {
|
pub async fn send_equipment_changes(&self, equipment: &[(EquipmentSlot, ItemStack)]) {
|
||||||
let equipment: Vec<(EquipmentSlot, Slot)> = equipment
|
let equipment: Vec<(EquipmentSlot, Slot)> = equipment
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(slot, stack)| (*slot, Slot::from(stack)))
|
.map(|(slot, stack)| (*slot, Slot::from(stack)))
|
||||||
|
|||||||
@ -504,7 +504,7 @@ impl Player {
|
|||||||
.wait_for_keep_alive
|
.wait_for_keep_alive
|
||||||
.load(std::sync::atomic::Ordering::Relaxed)
|
.load(std::sync::atomic::Ordering::Relaxed)
|
||||||
{
|
{
|
||||||
self.kick(TextComponent::translate("disconnect.timeout", [].into()))
|
self.kick(TextComponent::translate("disconnect.timeout", []))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -552,15 +552,14 @@ impl Client {
|
|||||||
if let Some(entry) = banned_players.get_entry(profile) {
|
if let Some(entry) = banned_players.get_entry(profile) {
|
||||||
let text = TextComponent::translate(
|
let text = TextComponent::translate(
|
||||||
"multiplayer.disconnect.banned.reason",
|
"multiplayer.disconnect.banned.reason",
|
||||||
vec![TextComponent::text(entry.reason.clone())],
|
[TextComponent::text(entry.reason.clone())],
|
||||||
);
|
);
|
||||||
return Some(match entry.expires {
|
return Some(match entry.expires {
|
||||||
Some(expires) => text.add_child(TextComponent::translate(
|
Some(expires) => text.add_child(TextComponent::translate(
|
||||||
"multiplayer.disconnect.banned.expiration",
|
"multiplayer.disconnect.banned.expiration",
|
||||||
[TextComponent::text(
|
[TextComponent::text(
|
||||||
expires.format("%F at %T %Z").to_string(),
|
expires.format("%F at %T %Z").to_string(),
|
||||||
)]
|
)],
|
||||||
.into(),
|
|
||||||
)),
|
)),
|
||||||
None => text,
|
None => text,
|
||||||
});
|
});
|
||||||
@ -572,15 +571,14 @@ impl Client {
|
|||||||
if let Some(entry) = banned_ips.get_entry(&address.ip()) {
|
if let Some(entry) = banned_ips.get_entry(&address.ip()) {
|
||||||
let text = TextComponent::translate(
|
let text = TextComponent::translate(
|
||||||
"multiplayer.disconnect.banned_ip.reason",
|
"multiplayer.disconnect.banned_ip.reason",
|
||||||
vec![TextComponent::text(entry.reason.clone())],
|
[TextComponent::text(entry.reason.clone())],
|
||||||
);
|
);
|
||||||
return Some(match entry.expires {
|
return Some(match entry.expires {
|
||||||
Some(expires) => text.add_child(TextComponent::translate(
|
Some(expires) => text.add_child(TextComponent::translate(
|
||||||
"multiplayer.disconnect.banned_ip.expiration",
|
"multiplayer.disconnect.banned_ip.expiration",
|
||||||
[TextComponent::text(
|
[TextComponent::text(
|
||||||
expires.format("%F at %T %Z").to_string(),
|
expires.format("%F at %T %Z").to_string(),
|
||||||
)]
|
)],
|
||||||
.into(),
|
|
||||||
)),
|
)),
|
||||||
None => text,
|
None => text,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@ impl Client {
|
|||||||
std::cmp::Ordering::Less => {
|
std::cmp::Ordering::Less => {
|
||||||
self.kick(&TextComponent::translate(
|
self.kick(&TextComponent::translate(
|
||||||
"multiplayer.disconnect.outdated_client",
|
"multiplayer.disconnect.outdated_client",
|
||||||
[TextComponent::text(CURRENT_MC_VERSION.to_string())].into(),
|
[TextComponent::text(CURRENT_MC_VERSION.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ impl Client {
|
|||||||
std::cmp::Ordering::Greater => {
|
std::cmp::Ordering::Greater => {
|
||||||
self.kick(&TextComponent::translate(
|
self.kick(&TextComponent::translate(
|
||||||
"multiplayer.disconnect.incompatible",
|
"multiplayer.disconnect.incompatible",
|
||||||
[TextComponent::text(CURRENT_MC_VERSION.to_string())].into(),
|
[TextComponent::text(CURRENT_MC_VERSION.to_string())],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ impl Client {
|
|||||||
if max_players > 0 && server.get_player_count().await >= max_players as usize {
|
if max_players > 0 && server.get_player_count().await >= max_players as usize {
|
||||||
self.kick(&TextComponent::translate(
|
self.kick(&TextComponent::translate(
|
||||||
"multiplayer.disconnect.server_full",
|
"multiplayer.disconnect.server_full",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -189,13 +189,12 @@ impl Client {
|
|||||||
Ok(new_profile) => *profile = new_profile,
|
Ok(new_profile) => *profile = new_profile,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
self.kick(&match error {
|
self.kick(&match error {
|
||||||
AuthError::FailedResponse => TextComponent::translate(
|
AuthError::FailedResponse => {
|
||||||
"multiplayer.disconnect.authservers_down",
|
TextComponent::translate("multiplayer.disconnect.authservers_down", [])
|
||||||
[].into(),
|
}
|
||||||
),
|
|
||||||
AuthError::UnverifiedUsername => TextComponent::translate(
|
AuthError::UnverifiedUsername => TextComponent::translate(
|
||||||
"multiplayer.disconnect.unverified_username",
|
"multiplayer.disconnect.unverified_username",
|
||||||
[].into(),
|
[],
|
||||||
),
|
),
|
||||||
e => TextComponent::text(e.to_string()),
|
e => TextComponent::text(e.to_string()),
|
||||||
})
|
})
|
||||||
@ -209,7 +208,7 @@ impl Client {
|
|||||||
log::debug!("Player (IP '{}', username '{}') tried to log in with the same UUID ('{}') as an online player (IP '{}', username '{}')", &self.address.lock().await, &profile.name, &profile.id, &online_player.client.address.lock().await, &online_player.gameprofile.name);
|
log::debug!("Player (IP '{}', username '{}') tried to log in with the same UUID ('{}') as an online player (IP '{}', username '{}')", &self.address.lock().await, &profile.name, &profile.id, &online_player.client.address.lock().await, &online_player.gameprofile.name);
|
||||||
self.kick(&TextComponent::translate(
|
self.kick(&TextComponent::translate(
|
||||||
"multiplayer.disconnect.duplicate_login",
|
"multiplayer.disconnect.duplicate_login",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -220,7 +219,7 @@ impl Client {
|
|||||||
log::debug!("A player (IP '{}', attempted username '{}') tried to log in with the same username as an online player (UUID '{}', IP '{}', username '{}')", &self.address.lock().await, &profile.name, &profile.id, &online_player.client.address.lock().await, &online_player.gameprofile.name);
|
log::debug!("A player (IP '{}', attempted username '{}') tried to log in with the same username as an online player (UUID '{}', IP '{}', username '{}')", &self.address.lock().await, &profile.name, &profile.id, &online_player.client.address.lock().await, &online_player.gameprofile.name);
|
||||||
self.kick(&TextComponent::translate(
|
self.kick(&TextComponent::translate(
|
||||||
"multiplayer.disconnect.duplicate_login",
|
"multiplayer.disconnect.duplicate_login",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -143,7 +143,7 @@ impl Player {
|
|||||||
if position.x.is_nan() || position.y.is_nan() || position.z.is_nan() {
|
if position.x.is_nan() || position.y.is_nan() || position.z.is_nan() {
|
||||||
self.kick(TextComponent::translate(
|
self.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.invalid_player_movement",
|
"multiplayer.disconnect.invalid_player_movement",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -232,7 +232,7 @@ impl Player {
|
|||||||
{
|
{
|
||||||
self.kick(TextComponent::translate(
|
self.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.invalid_player_movement",
|
"multiplayer.disconnect.invalid_player_movement",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -329,7 +329,7 @@ impl Player {
|
|||||||
if !rotation.yaw.is_finite() || !rotation.pitch.is_finite() {
|
if !rotation.yaw.is_finite() || !rotation.pitch.is_finite() {
|
||||||
self.kick(TextComponent::translate(
|
self.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.invalid_player_movement",
|
"multiplayer.disconnect.invalid_player_movement",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -483,7 +483,7 @@ impl Player {
|
|||||||
inventory.set_selected(dest_slot as u32);
|
inventory.set_selected(dest_slot as u32);
|
||||||
let empty = &ItemStack::new(0, Item::AIR);
|
let empty = &ItemStack::new(0, Item::AIR);
|
||||||
let stack = inventory.held_item().unwrap_or(empty);
|
let stack = inventory.held_item().unwrap_or(empty);
|
||||||
let equipment = vec![(EquipmentSlot::MainHand, *stack)];
|
let equipment = &[(EquipmentSlot::MainHand, *stack)];
|
||||||
self.living_entity.send_equipment_changes(equipment).await;
|
self.living_entity.send_equipment_changes(equipment).await;
|
||||||
self.client
|
self.client
|
||||||
.send_packet(&CSetHeldItem::new(dest_slot as i8))
|
.send_packet(&CSetHeldItem::new(dest_slot as i8))
|
||||||
@ -587,7 +587,7 @@ impl Player {
|
|||||||
if message.chars().any(|c| c == '§' || c < ' ' || c == '\x7F') {
|
if message.chars().any(|c| c == '§' || c < ' ' || c == '\x7F') {
|
||||||
self.kick(TextComponent::translate(
|
self.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.illegal_characters",
|
"multiplayer.disconnect.illegal_characters",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -759,7 +759,7 @@ impl Player {
|
|||||||
// this can't be triggered from a non-modded client.
|
// this can't be triggered from a non-modded client.
|
||||||
self.kick(TextComponent::translate(
|
self.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.invalid_entity_attacked",
|
"multiplayer.disconnect.invalid_entity_attacked",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -793,7 +793,7 @@ impl Player {
|
|||||||
);
|
);
|
||||||
self.kick(TextComponent::translate(
|
self.kick(TextComponent::translate(
|
||||||
"multiplayer.disconnect.invalid_entity_attacked",
|
"multiplayer.disconnect.invalid_entity_attacked",
|
||||||
[].into(),
|
[],
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
@ -1141,7 +1141,7 @@ impl Player {
|
|||||||
inv.set_selected(slot as u32);
|
inv.set_selected(slot as u32);
|
||||||
let empty = &ItemStack::new(0, Item::AIR);
|
let empty = &ItemStack::new(0, Item::AIR);
|
||||||
let stack = inv.held_item().unwrap_or(empty);
|
let stack = inv.held_item().unwrap_or(empty);
|
||||||
let equipment = vec![(EquipmentSlot::MainHand, *stack)];
|
let equipment = &[(EquipmentSlot::MainHand, *stack)];
|
||||||
self.living_entity.send_equipment_changes(equipment).await;
|
self.living_entity.send_equipment_changes(equipment).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ pub struct CachedStatus {
|
|||||||
|
|
||||||
pub struct CachedBranding {
|
pub struct CachedBranding {
|
||||||
/// Cached Server brand buffer so we don't have to rebuild them every time a player joins
|
/// Cached Server brand buffer so we don't have to rebuild them every time a player joins
|
||||||
cached_server_brand: Vec<u8>,
|
cached_server_brand: Box<[u8]>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CachedBranding {
|
impl CachedBranding {
|
||||||
@ -63,11 +63,11 @@ impl CachedBranding {
|
|||||||
}
|
}
|
||||||
const BRAND: &str = "Pumpkin";
|
const BRAND: &str = "Pumpkin";
|
||||||
const BRAND_BYTES: &[u8] = Self::BRAND.as_bytes();
|
const BRAND_BYTES: &[u8] = Self::BRAND.as_bytes();
|
||||||
fn build_brand() -> Vec<u8> {
|
fn build_brand() -> Box<[u8]> {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
VarInt(Self::BRAND.len() as i32).encode(&mut buf);
|
VarInt(Self::BRAND.len() as i32).encode(&mut buf);
|
||||||
buf.extend_from_slice(Self::BRAND_BYTES);
|
buf.extend_from_slice(Self::BRAND_BYTES);
|
||||||
buf
|
buf.into_boxed_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -884,7 +884,7 @@ impl World {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
let msg_comp = TextComponent::translate(
|
let msg_comp = TextComponent::translate(
|
||||||
"multiplayer.player.joined",
|
"multiplayer.player.joined",
|
||||||
[TextComponent::text(player.gameprofile.name.clone())].into(),
|
[TextComponent::text(player.gameprofile.name.clone())],
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Yellow);
|
.color_named(NamedColor::Yellow);
|
||||||
let event = PlayerJoinEvent::new(player.clone(), msg_comp);
|
let event = PlayerJoinEvent::new(player.clone(), msg_comp);
|
||||||
@ -943,7 +943,7 @@ impl World {
|
|||||||
if fire_event {
|
if fire_event {
|
||||||
let msg_comp = TextComponent::translate(
|
let msg_comp = TextComponent::translate(
|
||||||
"multiplayer.player.left",
|
"multiplayer.player.left",
|
||||||
[TextComponent::text(player.gameprofile.name.clone())].into(),
|
[TextComponent::text(player.gameprofile.name.clone())],
|
||||||
)
|
)
|
||||||
.color_named(NamedColor::Yellow);
|
.color_named(NamedColor::Yellow);
|
||||||
let event = PlayerLeaveEvent::new(player.clone(), msg_comp);
|
let event = PlayerLeaveEvent::new(player.clone(), msg_comp);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user