-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
10 changed files
with
136 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,31 @@ | ||
use pumpkin_macros::packet; | ||
use pumpkin_text::TextComponent; | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize)] | ||
#[packet(0x09)] | ||
pub struct CConfigAddResourcePack { | ||
uuid: uuid::Uuid, | ||
url: String, | ||
hash: String, | ||
forced: bool, | ||
prompt_message: Option<TextComponent>, | ||
} | ||
|
||
impl CConfigAddResourcePack { | ||
pub fn new( | ||
uuid: uuid::Uuid, | ||
url: String, | ||
hash: String, | ||
forced: bool, | ||
prompt_message: Option<TextComponent>, | ||
) -> Self { | ||
Self { | ||
uuid, | ||
url, | ||
hash, | ||
forced, | ||
prompt_message, | ||
} | ||
} | ||
} |
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,40 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct ResourcePack { | ||
pub enabled: bool, | ||
/// The path to the resource pack. | ||
pub resource_pack_url: String, | ||
/// The SHA1 hash (40) of the resource pack. | ||
pub resource_pack_sha1: String, | ||
/// Custom propmt Text component, Leave blank for none | ||
pub prompt_message: String, | ||
/// Will force the Player to accept the resource pack | ||
pub force: bool, | ||
} | ||
|
||
impl ResourcePack { | ||
pub fn validate(&self) { | ||
assert_eq!( | ||
!self.resource_pack_url.is_empty(), | ||
!self.resource_pack_sha1.is_empty(), | ||
"Resource Pack path or Sha1 hash is missing" | ||
); | ||
assert!( | ||
self.resource_pack_sha1.len() <= 40, | ||
"Resource pack sha1 hash is too long (max. 40)" | ||
) | ||
} | ||
} | ||
|
||
impl Default for ResourcePack { | ||
fn default() -> Self { | ||
Self { | ||
enabled: false, | ||
resource_pack_url: "".into(), | ||
resource_pack_sha1: "".into(), | ||
force: false, | ||
prompt_message: "".into(), | ||
} | ||
} | ||
} |
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