Prepare ChatType registry
This commit is contained in:
1 parent
41442c5b5d
commit
5b636111e4
10 files changed
+99
-46
No files matched your search
@@ -5,7 +5,7 @@ use crate::{bytebuf::ByteBuffer, ClientPacket, Property};
|
||||
#[packet(0x02)]
|
||||
pub struct CLoginSuccess<'a> {
|
||||
pub uuid: uuid::Uuid,
|
||||
pub username: String, // 16
|
||||
pub username: &'a str, // 16
|
||||
pub properties: &'a [Property],
|
||||
pub strict_error_handling: bool,
|
||||
}
|
||||
@@ -13,7 +13,7 @@ pub struct CLoginSuccess<'a> {
|
||||
impl<'a> CLoginSuccess<'a> {
|
||||
pub fn new(
|
||||
uuid: uuid::Uuid,
|
||||
username: String,
|
||||
username: &'a str,
|
||||
properties: &'a [Property],
|
||||
strict_error_handling: bool,
|
||||
) -> Self {
|
||||
|
||||
@@ -5,11 +5,11 @@ use crate::VarInt;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[packet(0x2B)]
|
||||
pub struct CLogin {
|
||||
pub struct CLogin<'a> {
|
||||
entity_id: i32,
|
||||
is_hardcore: bool,
|
||||
dimension_count: VarInt,
|
||||
dimension_names: Vec<String>,
|
||||
dimension_names: &'a [&'a str],
|
||||
max_players: VarInt,
|
||||
view_distance: VarInt,
|
||||
simulated_distance: VarInt,
|
||||
@@ -17,7 +17,7 @@ pub struct CLogin {
|
||||
enabled_respawn_screen: bool,
|
||||
limited_crafting: bool,
|
||||
dimension_type: VarInt,
|
||||
dimension_name: String,
|
||||
dimension_name: &'a str,
|
||||
hashed_seed: i64,
|
||||
game_mode: u8,
|
||||
previous_gamemode: i8,
|
||||
@@ -28,12 +28,12 @@ pub struct CLogin {
|
||||
enforce_secure_chat: bool,
|
||||
}
|
||||
|
||||
impl CLogin {
|
||||
impl<'a> CLogin<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
entity_id: i32,
|
||||
is_hardcore: bool,
|
||||
dimension_names: Vec<String>,
|
||||
dimension_names: &'a [&'a str],
|
||||
max_players: VarInt,
|
||||
view_distance: VarInt,
|
||||
simulated_distance: VarInt,
|
||||
@@ -41,7 +41,7 @@ impl CLogin {
|
||||
enabled_respawn_screen: bool,
|
||||
limited_crafting: bool,
|
||||
dimension_type: VarInt,
|
||||
dimension_name: String,
|
||||
dimension_name: &'a str,
|
||||
hashed_seed: i64,
|
||||
game_mode: u8,
|
||||
previous_gamemode: i8,
|
||||
|
||||
@@ -3,7 +3,7 @@ use pumpkin_macros::packet;
|
||||
use pumpkin_text::TextComponent;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::VarInt;
|
||||
use crate::{BitSet, VarInt};
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[packet(0x39)]
|
||||
@@ -14,10 +14,13 @@ pub struct CPlayerChatMessage<'a> {
|
||||
message: String,
|
||||
timestamp: i64,
|
||||
salt: i64,
|
||||
previous_messages_count: VarInt,
|
||||
previous_messages: &'a [PreviousMessage<'a>], // max 20
|
||||
unsigned_content: Option<TextComponent>,
|
||||
/// See `FilterType`
|
||||
filter_type: VarInt,
|
||||
// TODO: THIS IS A HACK, We currently don't support writing or reading bitsets
|
||||
filter_type_bits: bool,
|
||||
chat_type: VarInt,
|
||||
sender_name: TextComponent,
|
||||
target_name: Option<TextComponent>,
|
||||
@@ -46,9 +49,11 @@ impl<'a> CPlayerChatMessage<'a> {
|
||||
message,
|
||||
timestamp,
|
||||
salt,
|
||||
previous_messages_count: previous_messages.len().into(),
|
||||
previous_messages,
|
||||
unsigned_content,
|
||||
filter_type,
|
||||
filter_type_bits: false,
|
||||
chat_type,
|
||||
sender_name,
|
||||
target_name,
|
||||
|
||||
@@ -5,13 +5,13 @@ use crate::VarInt;
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
#[packet(0x42)]
|
||||
pub struct CRemoveEntities {
|
||||
pub struct CRemoveEntities<'a> {
|
||||
count: VarInt,
|
||||
entitiy_ids: Vec<VarInt>,
|
||||
entitiy_ids: &'a [VarInt],
|
||||
}
|
||||
|
||||
impl CRemoveEntities {
|
||||
pub fn new(entitiy_ids: Vec<VarInt>) -> Self {
|
||||
impl<'a> CRemoveEntities<'a> {
|
||||
pub fn new(entitiy_ids: &'a [VarInt]) -> Self {
|
||||
Self {
|
||||
count: VarInt(entitiy_ids.len() as i32),
|
||||
entitiy_ids,
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::io::{self, Write};
|
||||
|
||||
use bytebuf::{packet_id::Packet, ByteBuffer, DeserializerError};
|
||||
use bytes::Buf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize, Serializer};
|
||||
use thiserror::Error;
|
||||
|
||||
pub mod bytebuf;
|
||||
|
||||
Reference in new issue
Block a user