-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
171 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,33 @@ | ||
use pumpkin_macros::packet; | ||
use serde::Serialize; | ||
|
||
use crate::{bytebuf::ByteBuffer, ClientPacket, VarInt}; | ||
use crate::{RawBytes, VarInt}; | ||
|
||
#[derive(Serialize)] | ||
#[packet(0x01)] | ||
pub struct CEncryptionRequest<'a> { | ||
server_id: &'a str, // 20 | ||
public_key_length: VarInt, | ||
public_key: &'a [u8], | ||
public_key: RawBytes<'a>, | ||
verify_token_length: VarInt, | ||
verify_token: &'a [u8], | ||
verify_token: RawBytes<'a>, | ||
should_authenticate: bool, | ||
} | ||
|
||
impl<'a> CEncryptionRequest<'a> { | ||
pub fn new( | ||
server_id: &'a str, | ||
public_key: &'a [u8], | ||
verify_token: &'a [u8], | ||
public_key: RawBytes<'a>, | ||
verify_token: RawBytes<'a>, | ||
should_authenticate: bool, | ||
) -> Self { | ||
Self { | ||
server_id, | ||
public_key_length: public_key.len().into(), | ||
public_key_length: public_key.0.len().into(), | ||
public_key, | ||
verify_token_length: verify_token.len().into(), | ||
verify_token_length: verify_token.0.len().into(), | ||
verify_token, | ||
should_authenticate, | ||
} | ||
} | ||
} | ||
|
||
impl<'a> ClientPacket for CEncryptionRequest<'a> { | ||
fn write(&self, bytebuf: &mut ByteBuffer) { | ||
bytebuf.put_string(self.server_id); | ||
bytebuf.put_var_int(&self.public_key_length); | ||
bytebuf.put_slice(self.public_key); | ||
bytebuf.put_var_int(&self.verify_token_length); | ||
bytebuf.put_slice(self.verify_token); | ||
bytebuf.put_bool(self.should_authenticate); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
pumpkin-protocol/src/client/play/c_disguised_chat_message.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use pumpkin_macros::packet; | ||
|
||
use crate::{text::TextComponent, ClientPacket, VarInt}; | ||
|
||
#[derive(Clone)] | ||
#[packet(0x1E)] | ||
pub struct CDisguisedChatMessage { | ||
message: TextComponent, | ||
chat_type: VarInt, | ||
sender_name: TextComponent, | ||
target_name: Option<TextComponent>, | ||
} | ||
|
||
impl CDisguisedChatMessage { | ||
pub fn new( | ||
message: TextComponent, | ||
chat_type: VarInt, | ||
sender_name: TextComponent, | ||
target_name: Option<TextComponent>, | ||
) -> Self { | ||
Self { | ||
message, | ||
chat_type, | ||
sender_name, | ||
target_name, | ||
} | ||
} | ||
} | ||
|
||
impl ClientPacket for CDisguisedChatMessage { | ||
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) { | ||
bytebuf.put_slice(&self.message.encode()); | ||
bytebuf.put_var_int(&self.chat_type); | ||
bytebuf.put_slice(&self.sender_name.encode()); | ||
bytebuf.put_option(&self.target_name, |p, v| p.put_slice(&v.encode())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use pumpkin_macros::packet; | ||
|
||
use crate::{ | ||
bytebuf::{ByteBuffer, DeserializerError}, | ||
ServerPacket, | ||
}; | ||
|
||
// derive(Deserialize)] | ||
#[packet(0x06)] | ||
pub struct SChatMessage { | ||
pub message: String, | ||
pub timestamp: i64, | ||
pub salt: i64, | ||
pub signature: Option<Vec<u8>>, | ||
// pub messagee_count: VarInt, | ||
// acknowledged: BitSet, | ||
} | ||
|
||
impl ServerPacket for SChatMessage { | ||
fn read(bytebuf: &mut ByteBuffer) -> Result<Self, DeserializerError> { | ||
Ok(Self { | ||
message: bytebuf.get_string().unwrap(), | ||
timestamp: bytebuf.get_i64(), | ||
salt: bytebuf.get_i64(), | ||
signature: bytebuf.get_option(|v| v.get_slice().to_vec()), | ||
//messagee_count: bytebuf.get_var_int(), | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.