@@ -43,8 +43,7 @@ public void OnSettingUpdate()
4343 public override void Initialize ( )
4444 {
4545 SetNetworkPacketEventEnabled ( true ) ;
46- replay = new ReplayHandler ( GetProtocolVersion ( ) ) ;
47- replay . MetaData . serverName = GetServerHost ( ) + GetServerPort ( ) ;
46+ replay = new ReplayHandler ( GetProtocolVersion ( ) , $ "{ GetServerHost ( ) } :{ GetServerPort ( ) } ") ;
4847 backupCounter = Settings . DoubleToTick ( Config . Backup_Interval ) ;
4948
5049 McClient . dispatcher . Register ( l => l . Literal ( "help" )
@@ -68,6 +67,8 @@ public override void OnUnload()
6867 {
6968 McClient . dispatcher . Unregister ( CommandName ) ;
7069 McClient . dispatcher . GetRoot ( ) . GetChild ( "help" ) . RemoveChild ( CommandName ) ;
70+ replay ? . Dispose ( ) ;
71+ replay = null ;
7172 }
7273
7374 private int OnCommandHelp ( CmdResult r , string ? cmd )
@@ -85,9 +86,9 @@ private int OnCommandSave(CmdResult r)
8586 {
8687 try
8788 {
88- if ( replay ! . RecordRunning )
89+ if ( replay is { RecordRunning : true } )
8990 {
90- replay . CreateBackupReplay ( Path . Combine ( "replay_recordings" , replay . GetReplayDefaultName ( ) ) ) ;
91+ replay . CreateBackupReplay ( Path . Combine ( replay . ReplayFileDirectory , replay . GetReplayDefaultName ( ) ) ) ;
9192 return r . SetAndReturn ( CmdResult . Status . Done , Translations . bot_replayCapture_created ) ;
9293 }
9394 else
@@ -103,7 +104,7 @@ private int OnCommandStop(CmdResult r)
103104 {
104105 try
105106 {
106- if ( replay ! . RecordRunning )
107+ if ( replay is { RecordRunning : true } )
107108 {
108109 replay . OnShutDown ( ) ;
109110 return r . SetAndReturn ( CmdResult . Status . Done , Translations . bot_replayCapture_stopped ) ;
@@ -119,16 +120,16 @@ private int OnCommandStop(CmdResult r)
119120
120121 public override void OnNetworkPacket ( int packetID , List < byte > packetData , bool isLogin , bool isInbound )
121122 {
122- replay ! . AddPacket ( packetID , packetData , isLogin , isInbound ) ;
123+ replay ? . AddPacket ( packetID , packetData , isLogin , isInbound ) ;
123124 }
124125
125126 public override void Update ( )
126127 {
127- if ( Config . Backup_Interval > 0 && replay ! . RecordRunning )
128+ if ( Config . Backup_Interval > 0 && replay is { RecordRunning : true } )
128129 {
129130 if ( backupCounter <= 0 )
130131 {
131- replay . CreateBackupReplay ( Path . Combine ( "recording_cache" , "REPLAY_BACKUP.mcpr" ) ) ;
132+ replay . CreateBackupReplay ( replay . GetBackupReplayPath ( ) ) ;
132133 backupCounter = Settings . DoubleToTick ( Config . Backup_Interval ) ;
133134 }
134135 else backupCounter -- ;
@@ -137,7 +138,7 @@ public override void Update()
137138
138139 public override bool OnDisconnect ( DisconnectReason reason , string message )
139140 {
140- replay ! . OnShutDown ( ) ;
141+ replay ? . OnShutDown ( ) ;
141142 return base . OnDisconnect ( reason , message ) ;
142143 }
143144 }
0 commit comments