Fix
This commit is contained in:
parent
03267e3318
commit
99a331c6ab
4
generate.sh
Executable file
4
generate.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cargo run
|
||||||
|
cargo fmt
|
@ -1,3 +1,5 @@
|
|||||||
|
// This file is automatically generated.
|
||||||
|
// It is not intended for manual editing.
|
||||||
{{#each imports as |i|~}}
|
{{#each imports as |i|~}}
|
||||||
use {{i}};
|
use {{i}};
|
||||||
{{/each}}
|
{{/each~}}
|
||||||
|
@ -239,6 +239,20 @@ impl Decoder for u8 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Encoder for u16 {
|
||||||
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
|
Ok(writer.write_u16::<BigEndian>(*self)?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Decoder for u16 {
|
||||||
|
type Output = Self;
|
||||||
|
|
||||||
|
fn decode<R: Read>(reader: &mut R) -> Result<Self::Output, DecodeError> {
|
||||||
|
Ok(reader.read_u16::<BigEndian>()?)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Encoder for i32 {
|
impl Encoder for i32 {
|
||||||
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
fn encode<W: Write>(&self, writer: &mut W) -> Result<(), EncodeError> {
|
||||||
Ok(writer.write_i32::<BigEndian>(*self)?)
|
Ok(writer.write_i32::<BigEndian>(*self)?)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// This file is automatically generated.
|
||||||
|
// It is not intended for manual editing.
|
||||||
use crate::DecodeError;
|
use crate::DecodeError;
|
||||||
use crate::Decoder;
|
use crate::Decoder;
|
||||||
use minecraft_protocol_derive::Packet;
|
use minecraft_protocol_derive::Packet;
|
||||||
@ -41,6 +43,7 @@ impl HandshakeServerBoundPacket {
|
|||||||
Self::SetProtocol(set_protocol)
|
Self::SetProtocol(set_protocol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct SetProtocol {
|
pub struct SetProtocol {
|
||||||
#[packet(with = "var_int")]
|
#[packet(with = "var_int")]
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
// This file is automatically generated.
|
||||||
|
// It is not intended for manual editing.
|
||||||
use crate::DecodeError;
|
use crate::DecodeError;
|
||||||
use crate::Decoder;
|
use crate::Decoder;
|
||||||
use std::io::Read;
|
|
||||||
use minecraft_protocol_derive::Packet;
|
use minecraft_protocol_derive::Packet;
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
pub enum LoginServerBoundPacket {
|
pub enum LoginServerBoundPacket {
|
||||||
LoginStart(LoginStart),
|
LoginStart(LoginStart),
|
||||||
EncryptionResponse(EncryptionResponse),
|
EncryptionResponse(EncryptionResponse),
|
||||||
LoginPluginResponse(LoginPluginResponse)
|
LoginPluginResponse(LoginPluginResponse),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginServerBoundPacket {
|
impl LoginServerBoundPacket {
|
||||||
@ -15,7 +16,7 @@ impl LoginServerBoundPacket {
|
|||||||
match self {
|
match self {
|
||||||
Self::LoginStart(_) => 0x00,
|
Self::LoginStart(_) => 0x00,
|
||||||
Self::EncryptionResponse(_) => 0x01,
|
Self::EncryptionResponse(_) => 0x01,
|
||||||
Self::LoginPluginResponse(_) => 0x02
|
Self::LoginPluginResponse(_) => 0x02,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,14 +37,12 @@ impl LoginServerBoundPacket {
|
|||||||
|
|
||||||
Ok(Self::LoginPluginResponse(login_plugin_response))
|
Ok(Self::LoginPluginResponse(login_plugin_response))
|
||||||
}
|
}
|
||||||
_ => Err(DecodeError::UnknownPacketType { type_id })
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn login_start(username: String) -> Self {
|
pub fn login_start(username: String) -> Self {
|
||||||
let login_start = LoginStart {
|
let login_start = LoginStart { username };
|
||||||
username
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::LoginStart(login_start)
|
Self::LoginStart(login_start)
|
||||||
}
|
}
|
||||||
@ -51,27 +50,25 @@ impl LoginServerBoundPacket {
|
|||||||
pub fn encryption_response(shared_secret: Vec<u8>, verify_token: Vec<u8>) -> Self {
|
pub fn encryption_response(shared_secret: Vec<u8>, verify_token: Vec<u8>) -> Self {
|
||||||
let encryption_response = EncryptionResponse {
|
let encryption_response = EncryptionResponse {
|
||||||
shared_secret,
|
shared_secret,
|
||||||
verify_token
|
verify_token,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::EncryptionResponse(encryption_response)
|
Self::EncryptionResponse(encryption_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn login_plugin_response(message_id: i32, data: Vec<u8>) -> Self {
|
pub fn login_plugin_response(message_id: i32, data: Vec<u8>) -> Self {
|
||||||
let login_plugin_response = LoginPluginResponse {
|
let login_plugin_response = LoginPluginResponse { message_id, data };
|
||||||
message_id,
|
|
||||||
data
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::LoginPluginResponse(login_plugin_response)
|
Self::LoginPluginResponse(login_plugin_response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum LoginClientBoundPacket {
|
pub enum LoginClientBoundPacket {
|
||||||
Disconnect(Disconnect),
|
Disconnect(Disconnect),
|
||||||
EncryptionRequest(EncryptionRequest),
|
EncryptionRequest(EncryptionRequest),
|
||||||
Success(Success),
|
Success(Success),
|
||||||
Compress(Compress),
|
Compress(Compress),
|
||||||
LoginPluginRequest(LoginPluginRequest)
|
LoginPluginRequest(LoginPluginRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LoginClientBoundPacket {
|
impl LoginClientBoundPacket {
|
||||||
@ -81,7 +78,7 @@ impl LoginClientBoundPacket {
|
|||||||
Self::EncryptionRequest(_) => 0x01,
|
Self::EncryptionRequest(_) => 0x01,
|
||||||
Self::Success(_) => 0x02,
|
Self::Success(_) => 0x02,
|
||||||
Self::Compress(_) => 0x03,
|
Self::Compress(_) => 0x03,
|
||||||
Self::LoginPluginRequest(_) => 0x04
|
Self::LoginPluginRequest(_) => 0x04,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,41 +109,38 @@ impl LoginClientBoundPacket {
|
|||||||
|
|
||||||
Ok(Self::LoginPluginRequest(login_plugin_request))
|
Ok(Self::LoginPluginRequest(login_plugin_request))
|
||||||
}
|
}
|
||||||
_ => Err(DecodeError::UnknownPacketType { type_id })
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disconnect(reason: String) -> Self {
|
pub fn disconnect(reason: String) -> Self {
|
||||||
let disconnect = Disconnect {
|
let disconnect = Disconnect { reason };
|
||||||
reason
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::Disconnect(disconnect)
|
Self::Disconnect(disconnect)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encryption_request(server_id: String, public_key: Vec<u8>, verify_token: Vec<u8>) -> Self {
|
pub fn encryption_request(
|
||||||
|
server_id: String,
|
||||||
|
public_key: Vec<u8>,
|
||||||
|
verify_token: Vec<u8>,
|
||||||
|
) -> Self {
|
||||||
let encryption_request = EncryptionRequest {
|
let encryption_request = EncryptionRequest {
|
||||||
server_id,
|
server_id,
|
||||||
public_key,
|
public_key,
|
||||||
verify_token
|
verify_token,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::EncryptionRequest(encryption_request)
|
Self::EncryptionRequest(encryption_request)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn success(uuid: String, username: String) -> Self {
|
pub fn success(uuid: String, username: String) -> Self {
|
||||||
let success = Success {
|
let success = Success { uuid, username };
|
||||||
uuid,
|
|
||||||
username
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::Success(success)
|
Self::Success(success)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compress(threshold: i32) -> Self {
|
pub fn compress(threshold: i32) -> Self {
|
||||||
let compress = Compress {
|
let compress = Compress { threshold };
|
||||||
threshold
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::Compress(compress)
|
Self::Compress(compress)
|
||||||
}
|
}
|
||||||
@ -155,21 +149,22 @@ impl LoginClientBoundPacket {
|
|||||||
let login_plugin_request = LoginPluginRequest {
|
let login_plugin_request = LoginPluginRequest {
|
||||||
message_id,
|
message_id,
|
||||||
channel,
|
channel,
|
||||||
data
|
data,
|
||||||
};
|
};
|
||||||
|
|
||||||
Self::LoginPluginRequest(login_plugin_request)
|
Self::LoginPluginRequest(login_plugin_request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct LoginStart {
|
pub struct LoginStart {
|
||||||
pub username: String
|
pub username: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct EncryptionResponse {
|
pub struct EncryptionResponse {
|
||||||
pub shared_secret: Vec<u8>,
|
pub shared_secret: Vec<u8>,
|
||||||
pub verify_token: Vec<u8>
|
pub verify_token: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
@ -177,32 +172,31 @@ pub struct LoginPluginResponse {
|
|||||||
#[packet(with = "var_int")]
|
#[packet(with = "var_int")]
|
||||||
pub message_id: i32,
|
pub message_id: i32,
|
||||||
#[packet(with = "rest")]
|
#[packet(with = "rest")]
|
||||||
pub data: Vec<u8>
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct Disconnect {
|
pub struct Disconnect {
|
||||||
pub reason: String
|
pub reason: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct EncryptionRequest {
|
pub struct EncryptionRequest {
|
||||||
pub server_id: String,
|
pub server_id: String,
|
||||||
pub public_key: Vec<u8>,
|
pub public_key: Vec<u8>,
|
||||||
pub verify_token: Vec<u8>
|
pub verify_token: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct Success {
|
pub struct Success {
|
||||||
pub uuid: String,
|
pub uuid: String,
|
||||||
pub username: String
|
pub username: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct Compress {
|
pub struct Compress {
|
||||||
#[packet(with = "var_int")]
|
#[packet(with = "var_int")]
|
||||||
pub threshold: i32
|
pub threshold: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
@ -211,6 +205,5 @@ pub struct LoginPluginRequest {
|
|||||||
pub message_id: i32,
|
pub message_id: i32,
|
||||||
pub channel: String,
|
pub channel: String,
|
||||||
#[packet(with = "rest")]
|
#[packet(with = "rest")]
|
||||||
pub data: Vec<u8>
|
pub data: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,33 +1,32 @@
|
|||||||
|
// This file is automatically generated.
|
||||||
|
// It is not intended for manual editing.
|
||||||
use crate::DecodeError;
|
use crate::DecodeError;
|
||||||
use crate::Decoder;
|
use crate::Decoder;
|
||||||
use std::io::Read;
|
|
||||||
use minecraft_protocol_derive::Packet;
|
use minecraft_protocol_derive::Packet;
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
pub enum StatusServerBoundPacket {
|
pub enum StatusServerBoundPacket {
|
||||||
StatusRequest,
|
StatusRequest,
|
||||||
PingRequest(PingRequest)
|
PingRequest(PingRequest),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusServerBoundPacket {
|
impl StatusServerBoundPacket {
|
||||||
pub fn get_type_id(&self) -> u8 {
|
pub fn get_type_id(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Self::StatusRequest => 0x00,
|
Self::StatusRequest => 0x00,
|
||||||
Self::PingRequest(_) => 0x01
|
Self::PingRequest(_) => 0x01,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode<R: Read>(type_id: u8, reader: &mut R) -> Result<Self, DecodeError> {
|
pub fn decode<R: Read>(type_id: u8, reader: &mut R) -> Result<Self, DecodeError> {
|
||||||
match type_id {
|
match type_id {
|
||||||
0x00 => {
|
0x00 => Ok(Self::StatusRequest),
|
||||||
Ok(Self::StatusRequest)
|
|
||||||
}
|
|
||||||
0x01 => {
|
0x01 => {
|
||||||
let ping_request = PingRequest::decode(reader)?;
|
let ping_request = PingRequest::decode(reader)?;
|
||||||
|
|
||||||
Ok(Self::PingRequest(ping_request))
|
Ok(Self::PingRequest(ping_request))
|
||||||
}
|
}
|
||||||
_ => Err(DecodeError::UnknownPacketType { type_id })
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,23 +35,22 @@ impl StatusServerBoundPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ping_request(time: i64) -> Self {
|
pub fn ping_request(time: i64) -> Self {
|
||||||
let ping_request = PingRequest {
|
let ping_request = PingRequest { time };
|
||||||
time
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::PingRequest(ping_request)
|
Self::PingRequest(ping_request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum StatusClientBoundPacket {
|
pub enum StatusClientBoundPacket {
|
||||||
StatusResponse(StatusResponse),
|
StatusResponse(StatusResponse),
|
||||||
PingResponse(PingResponse)
|
PingResponse(PingResponse),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusClientBoundPacket {
|
impl StatusClientBoundPacket {
|
||||||
pub fn get_type_id(&self) -> u8 {
|
pub fn get_type_id(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
Self::StatusResponse(_) => 0x00,
|
Self::StatusResponse(_) => 0x00,
|
||||||
Self::PingResponse(_) => 0x01
|
Self::PingResponse(_) => 0x01,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,39 +66,34 @@ impl StatusClientBoundPacket {
|
|||||||
|
|
||||||
Ok(Self::PingResponse(ping_response))
|
Ok(Self::PingResponse(ping_response))
|
||||||
}
|
}
|
||||||
_ => Err(DecodeError::UnknownPacketType { type_id })
|
_ => Err(DecodeError::UnknownPacketType { type_id }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn status_response(response: String) -> Self {
|
pub fn status_response(response: String) -> Self {
|
||||||
let status_response = StatusResponse {
|
let status_response = StatusResponse { response };
|
||||||
response
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::StatusResponse(status_response)
|
Self::StatusResponse(status_response)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ping_response(time: i64) -> Self {
|
pub fn ping_response(time: i64) -> Self {
|
||||||
let ping_response = PingResponse {
|
let ping_response = PingResponse { time };
|
||||||
time
|
|
||||||
};
|
|
||||||
|
|
||||||
Self::PingResponse(ping_response)
|
Self::PingResponse(ping_response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct PingRequest {
|
pub struct PingRequest {
|
||||||
pub time: i64
|
pub time: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct StatusResponse {
|
pub struct StatusResponse {
|
||||||
pub response: String
|
pub response: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Packet, Debug)]
|
#[derive(Packet, Debug)]
|
||||||
pub struct PingResponse {
|
pub struct PingResponse {
|
||||||
pub time: i64
|
pub time: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user