@@ -32,9 +32,8 @@ use thiserror::Error;
3232use tokio:: {
3333 net:: TcpStream ,
3434 sync:: { Mutex , OwnedSemaphorePermit , RwLock } ,
35- time:: { self , timeout, Instant } ,
35+ time:: { timeout, Instant } ,
3636} ;
37- use tokio_util:: sync:: CancellationToken ;
3837use uuid:: Uuid ;
3938
4039use crate :: {
@@ -271,8 +270,7 @@ impl SharedPlayer {
271270 data : Bounded ( Bytes ( & [ 3 ] ) ) ,
272271 } ;
273272
274- let mut io = self . 0 . io . lock ( ) . await ;
275- io. tx ( & req) . await ?;
273+ self . 0 . io . tx ( & req) . await ?;
276274
277275 Ok ( ( ) )
278276 }
@@ -503,10 +501,13 @@ impl SharedPlayer {
503501 let mut queue = player. 0 . frame_queue . lock ( ) . await ;
504502 queue. push ( frame) ;
505503 }
506- Err ( why) => match why. downcast_ref :: < tokio:: io:: Error > ( ) . map ( |e| e. kind ( ) ) {
507- Some ( tokio:: io:: ErrorKind :: UnexpectedEof ) => return ,
508- _ => ( ) ,
509- } ,
504+ Err ( why) => {
505+ if let Some ( tokio:: io:: ErrorKind :: UnexpectedEof ) =
506+ why. downcast_ref :: < tokio:: io:: Error > ( ) . map ( |e| e. kind ( ) )
507+ {
508+ return ;
509+ }
510+ }
510511 }
511512 }
512513 } ) ;
@@ -518,26 +519,20 @@ impl SharedPlayer {
518519 let packet: SetPlayerPositionS = frame. decode ( ) ?;
519520
520521 let tp_state = self . 0 . tp_state . read ( ) . await ;
521- match * tp_state {
522- TeleportState :: Clear => {
523- let mut entity = self . 0 . entity . write ( ) . await ;
524- entity. reposition ( packet. x , packet. feet_y , packet. z ) ;
525- }
526- _ => ( ) ,
522+ if * tp_state == TeleportState :: Clear {
523+ let mut entity = self . 0 . entity . write ( ) . await ;
524+ entity. reposition ( packet. x , packet. feet_y , packet. z ) ;
527525 }
528526 }
529527
530528 SetPlayerPositionAndRotationS :: ID => {
531529 let packet: SetPlayerPositionAndRotationS = frame. decode ( ) ?;
532530
533531 let tp_state = self . 0 . tp_state . read ( ) . await ;
534- match * tp_state {
535- TeleportState :: Clear => {
536- let mut entity = self . 0 . entity . write ( ) . await ;
537- entity. reposition ( packet. x , packet. feet_y , packet. z ) ;
538- entity. rotate ( packet. yaw , packet. pitch ) ;
539- }
540- _ => ( ) ,
532+ if * tp_state == TeleportState :: Clear {
533+ let mut entity = self . 0 . entity . write ( ) . await ;
534+ entity. reposition ( packet. x , packet. feet_y , packet. z ) ;
535+ entity. rotate ( packet. yaw , packet. pitch ) ;
541536 }
542537 }
543538
0 commit comments