fix: Received unknown packet id 130
this was mostly because of poor naming, While there are two CServerLinks packets, I accidentally send the play CServerLinks in the login state which has a different packet id
This commit is contained in:
parent
3dae300f81
commit
1d96701cc0
@ -1,87 +1,16 @@
|
|||||||
use crate::VarInt;
|
use crate::{Link, VarInt};
|
||||||
use pumpkin_core::text::TextComponent;
|
|
||||||
use pumpkin_macros::client_packet;
|
use pumpkin_macros::client_packet;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("config:server_links")]
|
#[client_packet("config:server_links")]
|
||||||
pub struct CServerLinks<'a> {
|
pub struct CConfigServerLinks<'a> {
|
||||||
links_count: &'a VarInt,
|
links_count: &'a VarInt,
|
||||||
links: &'a [Link<'a>],
|
links: &'a [Link<'a>],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CServerLinks<'a> {
|
impl<'a> CConfigServerLinks<'a> {
|
||||||
pub fn new(links_count: &'a VarInt, links: &'a [Link<'a>]) -> Self {
|
pub fn new(links_count: &'a VarInt, links: &'a [Link<'a>]) -> Self {
|
||||||
Self { links_count, links }
|
Self { links_count, links }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Label<'a> {
|
|
||||||
BuiltIn(LinkType),
|
|
||||||
TextComponent(TextComponent<'a>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Label<'_> {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
match self {
|
|
||||||
Label::BuiltIn(link_type) => link_type.serialize(serializer),
|
|
||||||
Label::TextComponent(component) => component.serialize(serializer),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
pub struct Link<'a> {
|
|
||||||
pub is_built_in: bool,
|
|
||||||
pub label: Label<'a>,
|
|
||||||
pub url: &'a String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Link<'a> {
|
|
||||||
pub fn new(label: Label<'a>, url: &'a String) -> Self {
|
|
||||||
Self {
|
|
||||||
is_built_in: match label {
|
|
||||||
Label::BuiltIn(_) => true,
|
|
||||||
Label::TextComponent(_) => false,
|
|
||||||
},
|
|
||||||
label,
|
|
||||||
url,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum LinkType {
|
|
||||||
BugReport,
|
|
||||||
CommunityGuidelines,
|
|
||||||
Support,
|
|
||||||
Status,
|
|
||||||
Feedback,
|
|
||||||
Community,
|
|
||||||
Website,
|
|
||||||
Forums,
|
|
||||||
News,
|
|
||||||
Announcements,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for LinkType {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
match self {
|
|
||||||
LinkType::BugReport => VarInt(0).serialize(serializer),
|
|
||||||
LinkType::CommunityGuidelines => VarInt(1).serialize(serializer),
|
|
||||||
LinkType::Support => VarInt(2).serialize(serializer),
|
|
||||||
LinkType::Status => VarInt(3).serialize(serializer),
|
|
||||||
LinkType::Feedback => VarInt(4).serialize(serializer),
|
|
||||||
LinkType::Community => VarInt(5).serialize(serializer),
|
|
||||||
LinkType::Website => VarInt(6).serialize(serializer),
|
|
||||||
LinkType::Forums => VarInt(7).serialize(serializer),
|
|
||||||
LinkType::News => VarInt(8).serialize(serializer),
|
|
||||||
LinkType::Announcements => VarInt(9).serialize(serializer),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use crate::codec::identifier::Identifier;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("login:cookie_request")]
|
#[client_packet("login:cookie_request")]
|
||||||
/// Requests a cookie that was previously stored.
|
/// Requests a cookie that was previously stored.
|
||||||
pub struct CCookieRequest<'a> {
|
pub struct CLoginCookieRequest<'a> {
|
||||||
key: &'a Identifier,
|
key: &'a Identifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CCookieRequest<'a> {
|
impl<'a> CLoginCookieRequest<'a> {
|
||||||
pub fn new(key: &'a Identifier) -> Self {
|
pub fn new(key: &'a Identifier) -> Self {
|
||||||
Self { key }
|
Self { key }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,11 +6,11 @@ use crate::codec::identifier::Identifier;
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:cookie_request")]
|
#[client_packet("play:cookie_request")]
|
||||||
/// Requests a cookie that was previously stored.
|
/// Requests a cookie that was previously stored.
|
||||||
pub struct CCookieRequest<'a> {
|
pub struct CPlayCookieRequest<'a> {
|
||||||
key: &'a Identifier,
|
key: &'a Identifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CCookieRequest<'a> {
|
impl<'a> CPlayCookieRequest<'a> {
|
||||||
pub fn new(key: &'a Identifier) -> Self {
|
pub fn new(key: &'a Identifier) -> Self {
|
||||||
Self { key }
|
Self { key }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,87 +1,16 @@
|
|||||||
use crate::VarInt;
|
use crate::{Link, VarInt};
|
||||||
use pumpkin_core::text::TextComponent;
|
|
||||||
use pumpkin_macros::client_packet;
|
use pumpkin_macros::client_packet;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::Serialize;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[client_packet("play:server_links")]
|
#[client_packet("play:server_links")]
|
||||||
pub struct CServerLinks<'a> {
|
pub struct CPlayServerLinks<'a> {
|
||||||
links_count: &'a VarInt,
|
links_count: &'a VarInt,
|
||||||
links: &'a [Link<'a>],
|
links: &'a [Link<'a>],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CServerLinks<'a> {
|
impl<'a> CPlayServerLinks<'a> {
|
||||||
pub fn new(links_count: &'a VarInt, links: &'a [Link<'a>]) -> Self {
|
pub fn new(links_count: &'a VarInt, links: &'a [Link<'a>]) -> Self {
|
||||||
Self { links_count, links }
|
Self { links_count, links }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Label<'a> {
|
|
||||||
BuiltIn(LinkType),
|
|
||||||
TextComponent(TextComponent<'a>),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for Label<'_> {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
match self {
|
|
||||||
Label::BuiltIn(link_type) => link_type.serialize(serializer),
|
|
||||||
Label::TextComponent(component) => component.serialize(serializer),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
|
||||||
pub struct Link<'a> {
|
|
||||||
pub is_built_in: bool,
|
|
||||||
pub label: Label<'a>,
|
|
||||||
pub url: &'a String,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Link<'a> {
|
|
||||||
pub fn new(label: Label<'a>, url: &'a String) -> Self {
|
|
||||||
Self {
|
|
||||||
is_built_in: match label {
|
|
||||||
Label::BuiltIn(_) => true,
|
|
||||||
Label::TextComponent(_) => false,
|
|
||||||
},
|
|
||||||
label,
|
|
||||||
url,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum LinkType {
|
|
||||||
BugReport,
|
|
||||||
CommunityGuidelines,
|
|
||||||
Support,
|
|
||||||
Status,
|
|
||||||
Feedback,
|
|
||||||
Community,
|
|
||||||
Website,
|
|
||||||
Forums,
|
|
||||||
News,
|
|
||||||
Announcements,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for LinkType {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
match self {
|
|
||||||
LinkType::BugReport => VarInt(0).serialize(serializer),
|
|
||||||
LinkType::CommunityGuidelines => VarInt(1).serialize(serializer),
|
|
||||||
LinkType::Support => VarInt(2).serialize(serializer),
|
|
||||||
LinkType::Status => VarInt(3).serialize(serializer),
|
|
||||||
LinkType::Feedback => VarInt(4).serialize(serializer),
|
|
||||||
LinkType::Community => VarInt(5).serialize(serializer),
|
|
||||||
LinkType::Website => VarInt(6).serialize(serializer),
|
|
||||||
LinkType::Forums => VarInt(7).serialize(serializer),
|
|
||||||
LinkType::News => VarInt(8).serialize(serializer),
|
|
||||||
LinkType::Announcements => VarInt(9).serialize(serializer),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ use bytebuf::{packet_id::Packet, ReadingError};
|
|||||||
use bytes::{Buf, BufMut, Bytes};
|
use bytes::{Buf, BufMut, Bytes};
|
||||||
use codec::{identifier::Identifier, var_int::VarInt};
|
use codec::{identifier::Identifier, var_int::VarInt};
|
||||||
use pumpkin_core::text::{style::Style, TextComponent};
|
use pumpkin_core::text::{style::Style, TextComponent};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
|
|
||||||
pub mod bytebuf;
|
pub mod bytebuf;
|
||||||
#[cfg(feature = "clientbound")]
|
#[cfg(feature = "clientbound")]
|
||||||
@ -186,3 +186,73 @@ impl PositionFlag {
|
|||||||
flags.iter().fold(0, |acc, flag| acc | flag.get_mask())
|
flags.iter().fold(0, |acc, flag| acc | flag.get_mask())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub enum Label<'a> {
|
||||||
|
BuiltIn(LinkType),
|
||||||
|
TextComponent(TextComponent<'a>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serialize for Label<'_> {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
Label::BuiltIn(link_type) => link_type.serialize(serializer),
|
||||||
|
Label::TextComponent(component) => component.serialize(serializer),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
pub struct Link<'a> {
|
||||||
|
pub is_built_in: bool,
|
||||||
|
pub label: Label<'a>,
|
||||||
|
pub url: &'a String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> Link<'a> {
|
||||||
|
pub fn new(label: Label<'a>, url: &'a String) -> Self {
|
||||||
|
Self {
|
||||||
|
is_built_in: match label {
|
||||||
|
Label::BuiltIn(_) => true,
|
||||||
|
Label::TextComponent(_) => false,
|
||||||
|
},
|
||||||
|
label,
|
||||||
|
url,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum LinkType {
|
||||||
|
BugReport,
|
||||||
|
CommunityGuidelines,
|
||||||
|
Support,
|
||||||
|
Status,
|
||||||
|
Feedback,
|
||||||
|
Community,
|
||||||
|
Website,
|
||||||
|
Forums,
|
||||||
|
News,
|
||||||
|
Announcements,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serialize for LinkType {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
LinkType::BugReport => VarInt(0).serialize(serializer),
|
||||||
|
LinkType::CommunityGuidelines => VarInt(1).serialize(serializer),
|
||||||
|
LinkType::Support => VarInt(2).serialize(serializer),
|
||||||
|
LinkType::Status => VarInt(3).serialize(serializer),
|
||||||
|
LinkType::Feedback => VarInt(4).serialize(serializer),
|
||||||
|
LinkType::Community => VarInt(5).serialize(serializer),
|
||||||
|
LinkType::Website => VarInt(6).serialize(serializer),
|
||||||
|
LinkType::Forums => VarInt(7).serialize(serializer),
|
||||||
|
LinkType::News => VarInt(8).serialize(serializer),
|
||||||
|
LinkType::Announcements => VarInt(9).serialize(serializer),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -4,13 +4,12 @@ use pumpkin_config::{ADVANCED_CONFIG, BASIC_CONFIG};
|
|||||||
use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
use pumpkin_protocol::{
|
use pumpkin_protocol::{
|
||||||
client::{
|
client::{
|
||||||
config::{CConfigAddResourcePack, CKnownPacks},
|
config::{CConfigAddResourcePack, CConfigServerLinks, CKnownPacks},
|
||||||
login::{CLoginSuccess, CSetCompression},
|
login::{CLoginSuccess, CSetCompression},
|
||||||
play::{CServerLinks, Label, Link, LinkType},
|
|
||||||
},
|
},
|
||||||
codec::var_int::VarInt,
|
codec::var_int::VarInt,
|
||||||
server::login::{SEncryptionResponse, SLoginCookieResponse, SLoginPluginResponse, SLoginStart},
|
server::login::{SEncryptionResponse, SLoginCookieResponse, SLoginPluginResponse, SLoginStart},
|
||||||
ConnectionState, KnownPack,
|
ConnectionState, KnownPack, Label, Link, LinkType,
|
||||||
};
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@ -326,8 +325,11 @@ impl Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ADVANCED_CONFIG.server_links.enabled {
|
if ADVANCED_CONFIG.server_links.enabled {
|
||||||
self.send_packet(&CServerLinks::new(&VarInt(LINKS.len() as i32), &LINKS))
|
self.send_packet(&CConfigServerLinks::new(
|
||||||
.await;
|
&VarInt(LINKS.len() as i32),
|
||||||
|
&LINKS,
|
||||||
|
))
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
// known data packs
|
// known data packs
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user