-
Notifications
You must be signed in to change notification settings - Fork 146
Support for custom tablist header and footer #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
c016d23
35babb7
a8fbd38
e4507b1
ba952b3
db7473a
48f8f42
22f2902
486dd86
7e0535f
45d01df
3a96ed0
3c3f707
b0c2320
f6f8675
abe25d8
342dba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,12 @@ pub struct EntityRemoveEvent; | |
/// Triggered when an entity is added into the world. | ||
#[derive(Debug)] | ||
pub struct EntityCreateEvent; | ||
|
||
#[derive(Debug, Clone)] | ||
pub struct TablistHeaderFooter { | ||
pub header: String, | ||
pub footer: String, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct TablistExtrasUpdateEvent; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #522 is now merged, so quill-compatible events should be in |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
use base::{Gamemode, ProfileProperty}; | ||
use common::{ | ||
events::{EntityRemoveEvent, PlayerJoinEvent}, | ||
events::{EntityRemoveEvent, PlayerJoinEvent, TablistExtrasUpdateEvent, TablistHeaderFooter}, | ||
Game, | ||
}; | ||
use ecs::{SysResult, SystemExecutor}; | ||
|
@@ -11,11 +11,17 @@ use uuid::Uuid; | |
|
||
use crate::{ClientId, Server}; | ||
|
||
pub fn register(systems: &mut SystemExecutor<Game>) { | ||
pub fn register(game: &mut Game, systems: &mut SystemExecutor<Game>) { | ||
game.insert_resource(TablistHeaderFooter { | ||
header: "{\"text\":\"\"}".to_string(), | ||
footer: "{\"text\":\"\"}".to_string(), | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be great if you add the initial values to config.toml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's that important to have default values, because this isn't a vanilla feature. If anyone needs this, it would be better to use a plugin. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feather is not even close to be fully survival-compatible, so the only usage for Feather in production will be lobbies and mini-games. And there's 99% chance that everyone needs this feature. If someone wants more advanced features (like placeholders, animations), it would still be possible to override the resource by a plugin. I don't know why vanilla server doesn't have this feature, but lack of feature is not a good thing to copy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then in what format and where in the config would you like it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just like motd, using
|
||
systems | ||
.group::<Server>() | ||
.add_system(remove_tablist_players) | ||
.add_system(add_tablist_players); | ||
.add_system(add_tablist_players) | ||
.add_system(update_tablist_header) | ||
.add_system(send_tablist_header_on_join); | ||
} | ||
|
||
fn remove_tablist_players(game: &mut Game, server: &mut Server) -> SysResult { | ||
|
@@ -62,3 +68,25 @@ fn add_tablist_players(game: &mut Game, server: &mut Server) -> SysResult { | |
} | ||
Ok(()) | ||
} | ||
|
||
fn update_tablist_header(game: &mut Game, server: &mut Server) -> SysResult { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It updates not only header, but also footer. |
||
for _ in game.ecs.query::<&TablistExtrasUpdateEvent>().iter() { | ||
let header_footer = game.resources.get::<TablistHeaderFooter>()?; | ||
server.broadcast_with(|client| { | ||
client.send_tablist_header_footer(&header_footer.header, &header_footer.footer) | ||
}); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn send_tablist_header_on_join(game: &mut Game, server: &mut Server) -> SysResult { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sends not only header, but also footer. |
||
for (_, (_, &client_id)) in game.ecs.query::<(&PlayerJoinEvent, &ClientId)>().iter() { | ||
let header_footer = game.resources.get::<TablistHeaderFooter>()?; | ||
server | ||
.clients | ||
.get(client_id) | ||
.unwrap() | ||
.send_tablist_header_footer(&header_footer.header, &header_footer.footer); | ||
} | ||
Ok(()) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.