-
Notifications
You must be signed in to change notification settings - Fork 146
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
Support for custom tablist header and footer #513
base: main
Are you sure you want to change the base?
Conversation
added system for adding or changing tablist headers and footers. To make the tablist prettier
Tablist header and footer now in TablistHeaderFooter type Resources now used to store TablistHeaderFooter
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 comment
The 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 comment
The 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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
In what format
Just like motd, using Text::from(str)
. Or there is libcraft_text::markdown
module that allows writing rich text components in format @red some text @on_hover @show_text @green some hover text
, but I don't see any existing usage or documentation for this format.
Where
[server]
section
Add configurable values to config.toml
feather/server/config.toml
Outdated
default_header = "" | ||
default_footer = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users won't understand what header/footer is, I think it should be named like tablist_header
or playerlist_header
, and have default values to make it even more obvious (like vanilla's "A Minecraft Server" default motd).
Rename `default_header` to `tablist_header` Rename `default_footer` to `tablist_footer`
feather/common/src/events.rs
Outdated
#[derive(Debug, Clone)] | ||
pub struct TablistHeaderFooter { | ||
pub header: Text, | ||
pub footer: Text, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feather_common::events
is for events, while TablistHeaderFooter
is a resource. I'm not sure what file would fit best for this small struct, but definitely not events.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does it need to be for plugins to get to it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quill/common
. Quill doesn't support resources though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create feather/common/src/tablist.rs
or quill/common/src/tablist.rs
, but not in feather/server
. No other crate can access feather-server
.
@@ -63,6 +75,34 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
It updates not only header, but also 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 comment
The reason will be displayed to describe this comment to others. Learn more.
It sends not only header, but also footer.
Rename `update_tablist_header` to `update_tablist_header_footer` Rename `send_tablist_header_on_join` to `send_tablist_header_footer_on_join`
…into pretty_tablist
(45d01df) |
feather/server/src/options.rs
Outdated
/// The default tablist header. | ||
pub tablist_header: Text, | ||
|
||
/// The default tablist footer. | ||
pub tablist_footer: Text, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have Config
for server config and Options
for Server
options (mostly for initial connection handling, status, ping, working with proxies), so I think tablist values should only be in Config
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let server_options = game.resources.get::<Server>().unwrap().options.clone();
game.insert_resource(TablistHeaderFooter {
header: server_options.tablist_header.clone(),
footer: server_options.tablist_footer.clone(),
});
Then how do I get it from config to use it for TablistHeaderFooter
in tablist.rs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass it to register(game) function, or even better, make Config
(or even Rc<Config>
to make it immutable) a resource and Options
non-resource. Options
is never used as a resource (just did a quick search on cs.github)
Add config to resources
…into pretty_tablist
feather/common/src/events.rs
Outdated
#[derive(Debug)] | ||
pub struct TablistExtrasUpdateEvent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#522 is now merged, so quill-compatible events should be in quill/common/srs/events/change.rs
, implement Serialize, Deserialize, Clone, be defined in quill/common/src/component.rs
in HostComponent
enum and have bincode_component_impl!
in the end.
I'm not sure if this should be store in the default config. It would be quite easy to write a plugin, which sets the header and footer based on a config file. Going down this rapid hole, would result in a masive config file. |
It's currently impossible to write a plugin that interacts with resources, and we don't have a config API yet. Also, I think it would be a great first experience if we have static tablist header/footer built-in, the same way as we do with motd. Like I said in the previous conversation, everyone wants a pretty tablist in their [mini-game or lobby] server, and it's important to have very-commonly-used features built-in rather than to rely on third-party "must-have" plugins (which we don't even have yet). |
Tablist header and footer
Status
Description
Created a new
TablistHeaderFooter
that is sent to newly connected players. Other code can update this by changing this structure inGame::Resources
and causing aTablistExtrasUpdateEvent
which resends the data to all clients.Related issues
Checklist
cargo fmt
,cargo clippy --all-targets
,cargo build --release
andcargo test
and fixed any generated errors!