Skip to content
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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions feather/server/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ motd = "A Feather server"
max_players = 16
default_gamemode = "creative"
view_distance = 12
default_header = ""
default_footer = ""
Copy link
Contributor

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).


[log]
# If you prefer less verbose logs, switch this to "info".
Expand Down
6 changes: 5 additions & 1 deletion feather/server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::{fs, net::IpAddr, path::Path, str::FromStr};

use anyhow::Context;
use base::Gamemode;
use base::{Gamemode, Text};
use serde::{Deserialize, Deserializer};

use crate::{favicon::Favicon, Options};
Expand Down Expand Up @@ -66,6 +66,8 @@ impl Config {
view_distance: self.server.view_distance,
max_players: self.server.max_players,
default_gamemode: self.server.default_gamemode,
default_header: self.server.default_header.clone(),
default_footer: self.server.default_footer.clone(),
proxy_mode: match self.proxy.proxy_mode {
ProxyMode::None => None,
ProxyMode::Bungee => Some(crate::options::ProxyMode::Bungeecord),
Expand All @@ -90,6 +92,8 @@ pub struct ServerConfig {
pub max_players: u32,
pub default_gamemode: Gamemode,
pub view_distance: u32,
pub default_header: Text,
pub default_footer: Text,
}

#[derive(Debug, Deserialize)]
Expand Down
8 changes: 7 additions & 1 deletion feather/server/src/options.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use base::Gamemode;
use base::{Gamemode, Text};

use crate::favicon::Favicon;

Expand Down Expand Up @@ -28,6 +28,12 @@ pub struct Options {
/// The default gamemode for new players.
pub default_gamemode: Gamemode,

/// The default tablist header.
pub default_header: Text,

/// The default tablist footer.
pub default_footer: Text,

/// Proxy IP forwarding mode
pub proxy_mode: Option<ProxyMode>,
// HMAC key used with Velocity IP forwarding.
Expand Down
8 changes: 5 additions & 3 deletions feather/server/src/systems/tablist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ use common::{
Game,
};
use ecs::{SysResult, SystemExecutor};
use libcraft_text::{Text, TextComponent};
use quill_common::events::{EntityRemoveEvent, PlayerJoinEvent};
use quill_common::{components::Name, entities::Player};
use uuid::Uuid;

use crate::{ClientId, Server};

pub fn register(game: &mut Game, systems: &mut SystemExecutor<Game>) {
let server_options = game.resources.get::<Server>().unwrap().options.clone();

game.insert_resource(TablistHeaderFooter {
header: Text::Component(Box::new(TextComponent::empty())),
footer: Text::Component(Box::new(TextComponent::empty())),
header: server_options.default_header.clone(),
footer: server_options.default_footer.clone(),
});

systems
.group::<Server>()
.add_system(remove_tablist_players)
Expand Down