Setting the server name (On F3 screen)
SeseMueller opened this issue · 1 comments
SeseMueller commented
Reproduction
I entered any playground and pressed F3. On the third line, it says "null" for the server brand/name.
This can however be solved quite easily:
The server name can be set i.E. to "Valence".
fn init_clients(
mut clients: Query<
(
&mut EntityLayerId,
&mut VisibleChunkLayer,
&mut VisibleEntityLayers,
&mut Position,
&mut GameMode,
&mut Client,
),
Added<Client>,
>,
layers: Query<Entity, (With<ChunkLayer>, With<EntityLayer>)>,
) {
for (
mut layer_id,
mut visible_chunk_layer,
mut visible_entity_layers,
mut pos,
mut game_mode,
mut client
) in &mut clients
{
let layer = layers.single();
layer_id.0 = layer;
visible_chunk_layer.0 = layer;
visible_entity_layers.0.insert(layer);
pos.set([0.0, SPAWN_Y as f64 + 1.0, 0.0]);
*game_mode = GameMode::Creative;
// The payload is a &[u8] whose first byte is the length of the string
// followed by the string itself.
let payload = [7, b'V', b'a', b'l', b'e', b'n', b'c', b'e'];
client.send_custom_payload(ident!("minecraft:brand"), &payload);
}
}
The send_custom_payload
function with channel "minecraft:brand"
can set the server name to any payload.
Now what
The question is whether this should be set at all/ be turned into a plugin/ etc.
I'd be glad to turn it into a tiny plugin.
rj00a commented
I'd make an extension trait for this and put it in crates/valence_server/src/brand.rs
.
pub trait SetBrand {
fn set_brand(&mut self, brand: &str);
}
impl<T> SetBrand for T where T: WritePacket { ... }