Skip to content

Commit 7500058

Browse files
committed
Remove as_message(), add write_fmlhs_plugin_message()
1 parent 4c1dd74 commit 7500058

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/server/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,9 +692,9 @@ impl Server {
692692
println!("Received FML|HS ServerHello {} {:?}", fml_protocol_version, override_dimension);
693693

694694
self.write_plugin_message("REGISTER", "FML|HS\0FML\0FML|MP\0FML\0FORGE".as_bytes());
695-
self.write_plugin_message("FML|HS", &plugin_messages::FmlHs::ClientHello { fml_protocol_version }.as_message());
695+
self.write_fmlhs_plugin_message(&plugin_messages::FmlHs::ClientHello { fml_protocol_version });
696696
let mods: crate::protocol::LenPrefixed<crate::protocol::VarInt, plugin_messages::Mod> = Default::default();
697-
self.write_plugin_message("FML|HS", &plugin_messages::FmlHs::ModList { mods }.as_message());
697+
self.write_fmlhs_plugin_message(&plugin_messages::FmlHs::ModList { mods });
698698
},
699699
_ => (),
700700
}
@@ -703,6 +703,15 @@ impl Server {
703703
}
704704
}
705705

706+
fn write_fmlhs_plugin_message(&mut self, msg: &plugin_messages::FmlHs) {
707+
use crate::protocol::Serializable;
708+
709+
let mut buf: Vec<u8> = vec![];
710+
msg.write_to(&mut buf).unwrap();
711+
712+
self.write_plugin_message("FML|HS", &buf);
713+
}
714+
706715
fn write_plugin_message(&mut self, channel: &str, data: &[u8]) {
707716
println!("Sending plugin message: channel={}, data={:?}", channel, data);
708717
if self.protocol_version >= 47 {

src/server/plugin_messages.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,6 @@ impl<'a> Serializable for FmlHs<'a> {
103103
}
104104
}
105105

106-
impl<'a> FmlHs<'a> {
107-
// TODO: remove this wrapper and call write_to directly
108-
pub fn as_message(&'a self) -> Vec<u8> {
109-
let mut buf: Vec<u8> = vec![];
110-
self.write_to(&mut buf).unwrap();
111-
buf
112-
}
113-
}
114-
115106
pub struct Brand {
116107
pub brand: String,
117108
}

0 commit comments

Comments
 (0)