@@ -38,7 +38,7 @@ use uuid::Uuid;
3838
3939use crate :: {
4040 protocol:: {
41- datatypes:: { Bounded , Slot , VarInt } ,
41+ datatypes:: { Bounded , Bytes , Rest , Slot , VarInt } ,
4242 packets:: {
4343 login:: * ,
4444 play:: {
@@ -230,8 +230,16 @@ impl SharedPlayer {
230230 let uuid = login. player_uuid ;
231231 let username = login. name . 0 . to_owned ( ) ;
232232
233- #[ cfg( feature = "encryption" ) ]
234- self . login_velocity ( & username) . await ?;
233+ if state. velocity_forwarding {
234+ let understood = self . login_velocity ( ) . await ?;
235+
236+ if !understood {
237+ warn ! (
238+ "Velocity forwarding is on, but client {} did not properly respond to our forwarding request. This will kick in future." ,
239+ self . 0 . id
240+ )
241+ }
242+ }
235243
236244 let success = LoginSuccessC {
237245 uuid,
@@ -262,17 +270,20 @@ impl SharedPlayer {
262270 Ok ( ( ) )
263271 }
264272
265- #[ cfg( feature = "encryption" ) ]
266- async fn login_velocity ( & self , _username : & str ) -> Result < ( ) > {
273+ async fn login_velocity ( & self ) -> Result < bool > {
267274 let req = PluginRequestC {
268275 message_id : VarInt ( 0 ) ,
269276 channel : Bounded ( "velocity:player_info" ) ,
270- data : Bounded ( Bytes ( & [ 3 ] ) ) ,
277+ data : Rest ( Bytes ( & [ 3 ] ) ) ,
271278 } ;
272279
273280 self . 0 . io . tx ( & req) . await ?;
274281
275- Ok ( ( ) )
282+ let res = self . 0 . io . rx :: < PluginResponseS > ( ) . await ?;
283+ let res: PluginResponseS = res. decode ( ) ?;
284+
285+ // todo: replace with a profile maybe?
286+ Ok ( res. data . is_some ( ) && req. message_id . 0 == res. message_id . 0 )
276287 }
277288
278289 async fn begin_play ( & self ) -> Result < ( ) > {
0 commit comments