Add ref types to login and remove code coverage
This commit is contained in:
parent
87b1e7a250
commit
3be31e8b81
@ -2,6 +2,5 @@ minecraft-protocol
|
||||
============
|
||||
[](https://crates.io/crates/minecraft-protocol)
|
||||
[](https://travis-ci.com/eihwaz/minecraft-protocol)
|
||||
[](https://codecov.io/gh/eihwaz/minecraft-protocol)
|
||||
|
||||
Library for decoding and encoding Minecraft packets
|
||||
|
@ -50,8 +50,8 @@ pub fn main() {
|
||||
output::State::Login,
|
||||
),
|
||||
// (
|
||||
// transform_protocol_state(State::Game, &protocol_input.game),
|
||||
// State::Game,
|
||||
// transform_protocol_state(output::State::Game, &protocol_input.game),
|
||||
// output::State::Game,
|
||||
// ),
|
||||
];
|
||||
|
||||
@ -216,7 +216,7 @@ fn transform_field(unformatted_field_name: &str, data: &Data) -> Option<output::
|
||||
}
|
||||
|
||||
fn format_field_name(unformatted_field_name: &str) -> String {
|
||||
if unformatted_field_name == "Type" {
|
||||
if unformatted_field_name == "type" {
|
||||
String::from("type_")
|
||||
} else {
|
||||
unformatted_field_name.to_snake_case()
|
||||
@ -248,15 +248,6 @@ fn transform_data_type(name: &str) -> Option<output::DataType> {
|
||||
}
|
||||
}
|
||||
|
||||
fn modify_field(packet_name: &str, field: output::Field) -> output::Field {
|
||||
match (packet_name, field.name.as_str()) {
|
||||
("StatusResponse", "response") => field.change_type(output::DataType::RefType {
|
||||
ref_name: "ServerStatus".to_owned(),
|
||||
}),
|
||||
_ => field,
|
||||
}
|
||||
}
|
||||
|
||||
fn rename_packet(name: &str, bound: &output::Bound) -> String {
|
||||
match (name, bound) {
|
||||
("EncryptionBegin", output::Bound::Server) => "EncryptionResponse",
|
||||
@ -270,6 +261,17 @@ fn rename_packet(name: &str, bound: &output::Bound) -> String {
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
fn modify_field(packet_name: &str, field: output::Field) -> output::Field {
|
||||
match (packet_name, field.name.as_str()) {
|
||||
("StatusResponse", "response") => field.change_type(output::DataType::RefType {
|
||||
ref_name: "ServerStatus".to_owned(),
|
||||
}),
|
||||
("Success", "uuid") => field.change_type(output::DataType::Uuid { hyphenated: true }),
|
||||
("Disconnect", "reason") => field.change_type(output::DataType::Chat),
|
||||
_ => field,
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct GenerateContext<'a> {
|
||||
packet_enum_name: String,
|
||||
|
@ -1,9 +1,11 @@
|
||||
// This file is automatically generated.
|
||||
// It is not intended for manual editing.
|
||||
use crate::chat::Message;
|
||||
use crate::DecodeError;
|
||||
use crate::Decoder;
|
||||
use minecraft_protocol_derive::Packet;
|
||||
use std::io::Read;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub enum LoginServerBoundPacket {
|
||||
LoginStart(LoginStart),
|
||||
@ -113,7 +115,7 @@ impl LoginClientBoundPacket {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn disconnect(reason: String) -> Self {
|
||||
pub fn disconnect(reason: Chat) -> Self {
|
||||
let disconnect = Disconnect { reason };
|
||||
|
||||
Self::Disconnect(disconnect)
|
||||
@ -133,7 +135,7 @@ impl LoginClientBoundPacket {
|
||||
Self::EncryptionRequest(encryption_request)
|
||||
}
|
||||
|
||||
pub fn success(uuid: String, username: String) -> Self {
|
||||
pub fn success(uuid: Uuid, username: String) -> Self {
|
||||
let success = Success { uuid, username };
|
||||
|
||||
Self::Success(success)
|
||||
@ -177,7 +179,7 @@ pub struct LoginPluginResponse {
|
||||
|
||||
#[derive(Packet, Debug)]
|
||||
pub struct Disconnect {
|
||||
pub reason: String,
|
||||
pub reason: Chat,
|
||||
}
|
||||
|
||||
#[derive(Packet, Debug)]
|
||||
@ -189,7 +191,8 @@ pub struct EncryptionRequest {
|
||||
|
||||
#[derive(Packet, Debug)]
|
||||
pub struct Success {
|
||||
pub uuid: String,
|
||||
#[packet(with = "uuid_hyp_str")]
|
||||
pub uuid: Uuid,
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user