Skip to content

Commit

Permalink
Make Icon Optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Aug 21, 2024
1 parent e23587b commit b370391
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pumpkin-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ pub struct StatusResponse {
pub version: Version,
pub players: Players,
pub description: String,
pub favicon: String, // data:image/png;base64,<data>
// Players, favicon ...
pub favicon: Option<String>, // data:image/png;base64,<data>
// Players, favicon ...
}
#[derive(Serialize)]
pub struct Version {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/client/player_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl Client {
if config.hurt_animation {
// TODO
// thats how we prevent borrow errors :c
let packet = &CHurtAnimation::new(&entity_id, 10.0);
let packet = &CHurtAnimation::new(&entity_id, attacker_player.entity.yaw);
self.send_packet(packet);
client.send_packet(packet);
server.broadcast_packet_expect(
Expand Down
10 changes: 8 additions & 2 deletions pumpkin/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{
cell::{RefCell, RefMut},
collections::HashMap,
io::Cursor,
path::Path,
rc::Rc,
sync::{
atomic::{AtomicI32, Ordering},
Expand Down Expand Up @@ -408,7 +409,12 @@ impl Server {
}

pub fn build_response(config: &BasicConfiguration) -> StatusResponse {
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/icon.png");
let icon_path = concat!(env!("CARGO_MANIFEST_DIR"), "/icon.png");
let icon = if Path::new(icon_path).exists() {
Some(Self::load_icon(icon_path))
} else {
None
};

StatusResponse {
version: Version {
Expand All @@ -424,7 +430,7 @@ impl Server {
}],
},
description: config.motd.clone(),
favicon: Self::load_icon(path),
favicon: icon,
}
}

Expand Down

0 comments on commit b370391

Please sign in to comment.