@@ -145,7 +145,7 @@ public void onInitialize() {
145145 loopBossBar .addPlayer (player );
146146 if (isLooping ) {
147147 LOOP_LOGGER .info ("Starting recording for newly joined player: {}" , playerName );
148- executeCommand ( "mocap recording start " + playerName );
148+ startLoop ( );
149149 }
150150 });
151151
@@ -156,7 +156,7 @@ public void onInitialize() {
156156 loopBossBar .removePlayer (player );
157157 if (isLooping ) {
158158 LOOP_LOGGER .info ("Saving recording for Disconnected player: {}" , playerName );
159- String recordingName = "-" + playerName + " ." + playerName + ".1" ;
159+ String recordingName = "-+mc ." + playerName + ".1" ;
160160 executeCommand (String .format ("mocap recording stop " + recordingName ));
161161 executeCommand ("mocap recording save " + recordingName + " " + recordingName );
162162 }
@@ -222,9 +222,6 @@ public void startLoop() {
222222 ticksLeft = loopLengthTicks ;
223223 LOOP_LOGGER .info ("Starting Loop" );
224224 startRecordings ();
225- for (String playerName : recordingPlayers ) {
226- executeCommand (String .format ("mocap recording start %s" , playerName ));
227- }
228225 }
229226
230227 /**
@@ -234,7 +231,7 @@ private void runLoopIteration() {
234231 LOOP_LOGGER .info ("Starting iteration {} of loop" , loopIteration );
235232 if (trackTimeOfDay ) { serverWorld .setTimeOfDay (startTimeOfDay ); }
236233 for (String playerName : recordingPlayers ) {
237- String recordingName = "-" + playerName + " ." + playerName + ".1" ;
234+ String recordingName = "-+mc ." + playerName + ".1" ;
238235
239236 executeCommand ("mocap playback start " + recordingName );
240237 }
@@ -248,7 +245,6 @@ private void runLoopIteration() {
248245 * Starts the recordings.
249246 */
250247 private void startRecordings () {
251- // Start recording for every player
252248 for (String playerName : recordingPlayers ) {
253249 executeCommand (String .format ("mocap recording start %s" , playerName ));
254250 }
@@ -264,10 +260,10 @@ public void stopLoop() {
264260 config .isLooping = false ;
265261 loopBossBar .visible (false );
266262 for (String playerName : recordingPlayers ) {
267- String recordingName = "-" + playerName + " ." + playerName + ".1" ;
263+ String recordingName = "-+mc ." + playerName + ".1" ;
268264
269265 executeCommand ("mocap recording stop " + recordingName );
270- // executeCommand("mocap recording save " + recordingName + " " + recordingName);
266+ executeCommand ("mocap recording save " + recordingName + " " + recordingName );
271267 }
272268 executeCommand ("mocap playback stop_all including_others" );
273269 tickCounter = 0 ;
@@ -292,74 +288,6 @@ public void executeCommand(String command) {
292288 }
293289 }
294290
295- /**
296- * Checks if a recording file with the specified name exists in the predefined recordings directory.
297- * The method returns a boolean indicating the existence of the file.
298- *
299- * @param recordingName The name of the recording file to check, without the file extension.
300- * @return true if the recording file exists, false otherwise.
301- */
302- private boolean recordingFileExists (String recordingName ) {
303- // Build the complete path for the recording directory using the absolute world path
304- Path recordingDir = worldFolder .resolve ("mocap_files" ).resolve ("recordings" );
305- Path recordingFile = recordingDir .resolve (recordingName .toLowerCase () + ".mcmocap_rec" );
306-
307- boolean exists = recordingFile .toFile ().exists ();
308- if (!exists ) {
309- LOOP_LOGGER .error ("Expected recording file does not exist: {}" , recordingFile .toAbsolutePath ());
310- }
311- return exists ;
312- }
313-
314- /**
315- * Removes outdated entries from the scene file to ensure the number of subscenes does not exceed the maximum allowed loops.
316- *
317- * The method checks if there are more recorded subscenes in the scene file than the value specified by maxLoops. If so,
318- * it removes the oldest entries to maintain the desired number. The updated data is then saved back to the file.
319- *
320- */
321- private void removeOldSceneEntries () {
322- if (isLooping ) {
323- if (maxLoops > 1 ) {
324- Path sceneDir = worldFolder .resolve ("mocap_files" ).resolve ("scenes" );
325- Path sceneFile = sceneDir .resolve (sceneName +".mcmocap_scene" );
326-
327- // Check if the scene file exists
328- if (sceneFile .toFile ().exists ()) {
329- try {
330- // Load the scene data from the file
331- String jsonContent = new String (java .nio .file .Files .readAllBytes (sceneFile ));
332-
333- // Parse the content
334- com .google .gson .JsonObject jsonObject = com .google .gson .JsonParser .parseString (jsonContent ).getAsJsonObject ();
335- com .google .gson .JsonArray subScenes = jsonObject .getAsJsonArray ("subscenes" );
336-
337- // Check if we have more scenes than maxLoops
338- if (subScenes .size () > maxLoops ) {
339- // Calculate the number of scenes to remove
340- int entriesToRemove = subScenes .size () - maxLoops ;
341- // Remove the excess entries (removing from the start of the array)
342- for (int i = 0 ; i < entriesToRemove ; i ++) {
343- subScenes .remove (0 ); // Remove the first (oldest) entry
344- }
345-
346- // Update the JSON object with the modified subScenes array
347- jsonObject .add ("subScenes" , subScenes );
348-
349- // Write the updated JSON back to the file
350- java .nio .file .Files .write (sceneFile , jsonObject .toString ().getBytes ());
351- LOOP_LOGGER .info ("Removed old scene entries to maintain maxLoops: {}" , maxLoops );
352- }
353- } catch (java .io .IOException e ) {
354- LOOP_LOGGER .error ("Failed to read or write scene file: {}" , sceneFile , e );
355- }
356- } else {
357- LOOP_LOGGER .error ("Scene file does not exist: {}" , sceneFile );
358- }
359- }
360- }
361- }
362-
363291 /**
364292 * Updates the entities to be tracked for recording and playback settings.
365293 * This method modifies the entities being tracked based on the specified parameter,
@@ -370,7 +298,7 @@ private void removeOldSceneEntries() {
370298 */
371299 public void updateEntitiesToTrack (boolean items ) {
372300 String entitiesToTrack = "@vehicles" + (items ? ";@items" : "" );
373- executeCommand (String .format ("mocap settings recording record_entities %s" , entitiesToTrack ));
301+ executeCommand (String .format ("mocap settings recording track_entities %s" , entitiesToTrack ));
374302 executeCommand (String .format ("mocap settings playback play_entities %s" , entitiesToTrack ));
375303 }
376304}
0 commit comments