-
-
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.
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
- Loading branch information
Showing
6 changed files
with
90 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,16 @@ | ||
use crate::VarInt; | ||
use pumpkin_core::text::TextComponent; | ||
use crate::{Link, VarInt}; | ||
use pumpkin_macros::client_packet; | ||
use serde::{Serialize, Serializer}; | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize)] | ||
#[client_packet("config:server_links")] | ||
pub struct CServerLinks<'a> { | ||
pub struct CConfigServerLinks<'a> { | ||
links_count: &'a VarInt, | ||
links: &'a [Link<'a>], | ||
} | ||
|
||
impl<'a> CServerLinks<'a> { | ||
impl<'a> CConfigServerLinks<'a> { | ||
pub fn new(links_count: &'a VarInt, links: &'a [Link<'a>]) -> Self { | ||
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), | ||
} | ||
} | ||
} |
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,87 +1,16 @@ | ||
use crate::VarInt; | ||
use pumpkin_core::text::TextComponent; | ||
use crate::{Link, VarInt}; | ||
use pumpkin_macros::client_packet; | ||
use serde::{Serialize, Serializer}; | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize)] | ||
#[client_packet("play:server_links")] | ||
pub struct CServerLinks<'a> { | ||
pub struct CPlayServerLinks<'a> { | ||
links_count: &'a VarInt, | ||
links: &'a [Link<'a>], | ||
} | ||
|
||
impl<'a> CServerLinks<'a> { | ||
impl<'a> CPlayServerLinks<'a> { | ||
pub fn new(links_count: &'a VarInt, links: &'a [Link<'a>]) -> Self { | ||
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), | ||
} | ||
} | ||
} |
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