File tree Expand file tree Collapse file tree
src/main/java/com/vltno/timeloop Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -260,7 +260,27 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher) {
260260 context .getSource ().sendMessage (Text .literal ("Tracking chat is set to: " + newTrackChat ));
261261 LOGGER .info ("Tracking chat set to {}" , newTrackChat );
262262 return 1 ;
263- }))))
263+ })))
264+ .then (CommandManager .literal ("hurtLoopedPlayers" )
265+ .requires (source -> source .hasPermissionLevel (2 ))
266+ .executes (context -> {
267+ context .getSource ().sendMessage (Text .literal ("Hurting looped players is set to: " + mod .hurtLoopedPlayers ));
268+ return 1 ;
269+ })
270+ .then (CommandManager .argument ("value" , BoolArgumentType .bool ())
271+ .executes (context -> {
272+ boolean newHurtLoopedPlayers = BoolArgumentType .getBool (context , "value" );
273+ mod .hurtLoopedPlayers = newHurtLoopedPlayers ;
274+ mod .config .hurtLoopedPlayers = newHurtLoopedPlayers ;
275+ mod .config .save ();
276+
277+ mod .executeCommand ("mocap settings playback invulnerable_playback " + !newHurtLoopedPlayers );
278+
279+ context .getSource ().sendMessage (Text .literal ("Hurting looped players is set to: " + newHurtLoopedPlayers ));
280+ LOGGER .info ("Hurting looped players set to {}" , newHurtLoopedPlayers );
281+ return 1 ;
282+ })))
283+ )
264284
265285 .then (CommandManager .literal ("reset" )
266286 .requires (source -> source .hasPermissionLevel (2 ))
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ public class TimeLoop implements ModInitializer {
4949 public boolean trackItems ;
5050 public LoopTypes loopType ;
5151 public boolean trackChat ;
52+ public boolean hurtLoopedPlayers ;
5253
5354 // The configuration object loaded from disk
5455 public TimeLoopConfig config ;
@@ -105,6 +106,7 @@ public void onInitialize() {
105106 trackItems = config .trackItems ;
106107 loopType = config .loopType ;
107108 trackChat = config .trackChat ;
109+ hurtLoopedPlayers = config .hurtLoopedPlayers ;
108110
109111 loopSceneManager .setRecordingPlayers (config .recordingPlayers );
110112
@@ -120,6 +122,7 @@ public void onInitialize() {
120122 executeCommand ("mocap settings recording start_instantly true" );
121123 executeCommand ("mocap settings recording on_death continue_synced" );
122124 executeCommand ("mocap settings recording chat_recording " + trackChat );
125+ executeCommand ("mocap settings playback invulnerable_playback " + !hurtLoopedPlayers );
123126 executeCommand ("mocap settings recording entity_tracking_distance 1" );
124127
125128 updateEntitiesToTrack (trackItems );
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ public class TimeLoopConfig {
2929 public boolean trackItems = false ;
3030 public LoopTypes loopType = LoopTypes .TICKS ;
3131 public boolean trackChat = false ;
32+ public boolean hurtLoopedPlayers = false ;
3233
3334 public Map <String , PlayerData > recordingPlayers = new HashMap <>();
3435
@@ -60,6 +61,12 @@ public static TimeLoopConfig load(Path configDir) {
6061 System .err .println ("Config file not found or invalid. Generating a default configuration." );
6162 }
6263
64+ // Validate recordingPlayers field and provide defaults if necessary
65+ if (config .recordingPlayers == null || !(config .recordingPlayers instanceof Map )) {
66+ System .err .println ("Invalid or missing recordingPlayers data in config. Initializing with an empty map." );
67+ config .recordingPlayers = new HashMap <>();
68+ }
69+
6370 config .save ();
6471 return config ;
6572 }
You can’t perform that action at this time.
0 commit comments