Support for custom tablist header and footer#513
Support for custom tablist header and footer#513Kecerim24 wants to merge 17 commits intofeather-rs:mainfrom
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.
It would be great if you add the initial values to config.toml
There was a problem hiding this comment.
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.
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.
Then in what format and where in the config would you like it?
There was a problem hiding this comment.
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.
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.
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.
Where does it need to be for plugins to get to it?
There was a problem hiding this comment.
quill/common. Quill doesn't support resources though.
There was a problem hiding this comment.
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.
| Ok(()) | ||
| } | ||
|
|
||
| fn update_tablist_header(game: &mut Game, server: &mut Server) -> SysResult { |
There was a problem hiding this comment.
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.
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.
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.
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.
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.
#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
TablistHeaderFooterthat is sent to newly connected players. Other code can update this by changing this structure inGame::Resourcesand causing aTablistExtrasUpdateEventwhich resends the data to all clients.Related issues
Checklist
cargo fmt,cargo clippy --all-targets,cargo build --releaseandcargo testand fixed any generated errors!