33import com .mojang .brigadier .CommandDispatcher ;
44import com .mojang .brigadier .arguments .BoolArgumentType ;
55import com .mojang .brigadier .arguments .IntegerArgumentType ;
6+ import com .mojang .brigadier .arguments .StringArgumentType ;
67import net .minecraft .command .CommandRegistryAccess ;
78import net .minecraft .server .command .CommandManager ;
89import net .minecraft .server .command .ServerCommandSource ;
@@ -24,9 +25,11 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
2425 .requires (source -> source .hasPermissionLevel (2 ))
2526 .executes (context -> {
2627 if (!mod .isLooping ) {
28+ mod .startTimeOfDay = mod .serverWorld .getTimeOfDay ();
29+ mod .config .startTimeOfDay = mod .startTimeOfDay ;
2730 mod .startLoop ();
2831 context .getSource ().sendMessage (Text .literal ("Loop started!" ));
29- LOGGER .info ("Loop started" );
32+ LOGGER .info ("loop started" );
3033 return 1 ;
3134 }
3235 context .getSource ().sendMessage (Text .literal ("Loop already running!" ));
@@ -58,7 +61,7 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
5861 LOGGER .info ("Status requested: {}" , status );
5962 return 1 ;
6063 }))
61-
64+
6265 // SETTINGS
6366 .then (CommandManager .literal ("settings" )
6467
@@ -74,16 +77,16 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
7477 mod .loopType = newLoopType ;
7578 mod .config .loopType = newLoopType ;
7679 mod .config .save ();
77-
80+
7881 context .getSource ().sendMessage (Text .literal ("Looping type is set to: " + newLoopType .asString ()));
7982 LOGGER .info ("Loop type set to {}" , newLoopType .asString ());
8083 return 1 ;
8184 })))
8285
83- .then (CommandManager .literal ("setTicks " )
86+ .then (CommandManager .literal ("setLength " )
8487 .requires (source -> source .hasPermissionLevel (2 ))
8588 .executes (context -> {
86- context .getSource ().sendMessage (Text .literal ("Loop ticks is set to: " + mod .loopLengthTicks + " ticks" ));
89+ context .getSource ().sendMessage (Text .literal ("Loop length is set to: " + mod .loopLengthTicks + " ticks" ));
8790 return 1 ;
8891 })
8992 .then (CommandManager .argument ("ticks" , IntegerArgumentType .integer (20 ))
@@ -96,15 +99,16 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
9699 mod .config .ticksLeft = newTicks ;
97100
98101 mod .config .save ();
99- context .getSource ().sendMessage (Text .literal ("Loop ticks is set to: " + newTicks + " ticks" ));
100- LOGGER .info ("Loop ticks set to {} ticks" , newTicks );
102+
103+ context .getSource ().sendMessage (Text .literal ("Loop length is set to: " + newTicks + " ticks" ));
104+ LOGGER .info ("Loop length set to {} ticks" , newTicks );
101105 return 1 ;
102106 })))
103-
107+
104108 .then (CommandManager .literal ("maxLoops" )
105109 .requires (source -> source .hasPermissionLevel (2 ))
106110 .executes (context -> {
107- context .getSource ().sendMessage (Text .literal ("maxLoops is currently set to: " + mod .maxLoops ));
111+ context .getSource ().sendMessage (Text .literal ("Max loops is set to: " + mod .maxLoops ));
108112 return 1 ;
109113 })
110114 .then (CommandManager .argument ("value" , IntegerArgumentType .integer (0 ))
@@ -113,34 +117,48 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
113117 mod .maxLoops = maxLoops ;
114118 mod .config .maxLoops = maxLoops ;
115119 mod .config .save ();
116- context .getSource ().sendMessage (Text .literal ("maxLoops is currently set to: " + maxLoops ));
117- LOGGER .info ("Max Loops set to {}" , maxLoops );
120+ context .getSource ().sendMessage (Text .literal ("Max loops is set to: " + maxLoops ));
121+ LOGGER .info ("Max loops set to {}" , maxLoops );
118122 return 1 ;
119123 })))
120-
124+
121125 .then (CommandManager .literal ("setTimeOfDay" )
122126 .requires (source -> source .hasPermissionLevel (2 ))
123127 .executes (context -> {
124- context .getSource ().sendMessage (Text .literal ("Time is set to: " + mod .timeSetting ));
128+ context .getSource ().sendMessage (Text .literal ("Time of day is set to: " + mod .timeSetting ));
125129 return 1 ;
126130 })
127- .then (CommandManager .argument ("time" , IntegerArgumentType .integer (0 ))
131+ .then (CommandManager .argument ("time" , IntegerArgumentType .integer (0 , 24000 ))
128132 .executes (context -> {
129133 int newTime = IntegerArgumentType .getInteger (context , "time" );
130134 mod .timeSetting = newTime ;
131135 mod .config .timeSetting = newTime ;
132136 mod .config .save ();
133- context .getSource ().sendMessage (Text .literal ("Time is set to: " + newTime ));
134- LOGGER .info ("Time set to {}" , newTime );
137+ context .getSource ().sendMessage (Text .literal ("Time of day is set to: " + newTime ));
138+ LOGGER .info ("Time of day set to {}" , newTime );
135139 return 1 ;
136140 })))
137141
142+ .then (CommandManager .literal ("modifyPlayer" )
143+ .requires (source -> source .hasPermissionLevel (2 ))
144+ .then (CommandManager .argument ("targetPlayer" , StringArgumentType .string ())
145+ .then (CommandManager .argument ("newName" , StringArgumentType .string ())
146+ .then (CommandManager .argument ("newSkin" , StringArgumentType .string ())
147+ .executes (context -> {
148+ String targetPlayer = StringArgumentType .getString (context , "targetPlayer" );
149+ String newName = StringArgumentType .getString (context , "newName" );
150+ String newSkin = StringArgumentType .getString (context , "newSkin" );
151+
152+ mod .modifyPlayerAttributes (targetPlayer , newName , newSkin );
153+ return 1 ;
154+ })))))
155+
138156 // TOGGLES
139157 .then (CommandManager .literal ("toggles" )
140158 .then (CommandManager .literal ("trackTimeOfDay" )
141159 .requires (source -> source .hasPermissionLevel (2 ))
142160 .executes (context -> {
143- context .getSource ().sendMessage (Text .literal ("Tracking time of day is set to: " + mod .trackTimeOfDay ));
161+ context .getSource ().sendMessage (Text .literal ("Track time of day is set to: " + mod .trackTimeOfDay ));
144162 return 1 ;
145163 })
146164 .then (CommandManager .argument ("value" , BoolArgumentType .bool ())
@@ -149,16 +167,16 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
149167 mod .trackTimeOfDay = newTrackTimeOfDay ;
150168 mod .config .trackTimeOfDay = newTrackTimeOfDay ;
151169 mod .config .save ();
152-
153- context .getSource ().sendMessage (Text .literal ("Tracking time of day is set to: " + newTrackTimeOfDay ));
154- LOGGER .info ("Tracking time of day set to {}" , newTrackTimeOfDay );
170+
171+ context .getSource ().sendMessage (Text .literal ("Track time of day is set to: " + newTrackTimeOfDay ));
172+ LOGGER .info ("Track time of day set to {}" , newTrackTimeOfDay );
155173 return 1 ;
156174 })))
157175
158176 .then (CommandManager .literal ("trackItems" )
159177 .requires (source -> source .hasPermissionLevel (2 ))
160178 .executes (context -> {
161- context .getSource ().sendMessage (Text .literal ("Tracking items is set to: " + mod .trackItems ));
179+ context .getSource ().sendMessage (Text .literal ("Track items is set to: " + mod .trackItems ));
162180 return 1 ;
163181 })
164182 .then (CommandManager .argument ("value" , BoolArgumentType .bool ())
@@ -167,14 +185,32 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
167185 mod .trackItems = newTrackItems ;
168186 mod .config .trackItems = newTrackItems ;
169187 mod .config .save ();
170-
188+
171189 mod .updateEntitiesToTrack (newTrackItems );
172-
173- context .getSource ().sendMessage (Text .literal ("Tracking items is set to: " + newTrackItems ));
174- LOGGER .info ("Tracking items set to {}" , newTrackItems );
190+
191+ context .getSource ().sendMessage (Text .literal ("Track items is set to: " + newTrackItems ));
192+ LOGGER .info ("Track items set to {}" , newTrackItems );
175193 return 1 ;
176194 })))
177-
195+
196+ .then (CommandManager .literal ("displayTimeInTicks" )
197+ .requires (source -> source .hasPermissionLevel (2 ))
198+ .executes (context -> {
199+ context .getSource ().sendMessage (Text .literal ("Display time in ticks is set to: " + mod .displayTimeInTicks ));
200+ return 1 ;
201+ })
202+ .then (CommandManager .argument ("value" , BoolArgumentType .bool ())
203+ .executes (context -> {
204+ boolean newDisplayTimeInTicks = BoolArgumentType .getBool (context , "value" );
205+ mod .displayTimeInTicks = newDisplayTimeInTicks ;
206+ mod .config .displayTimeInTicks = newDisplayTimeInTicks ;
207+ mod .config .save ();
208+
209+ context .getSource ().sendMessage (Text .literal ("Display time in ticks is set to: " + newDisplayTimeInTicks ));
210+ LOGGER .info ("Display time in ticks set to {}" , newDisplayTimeInTicks );
211+ return 1 ;
212+ })))
213+
178214 .then (CommandManager .literal ("showLoopInfo" )
179215 .requires (source -> source .hasPermissionLevel (2 ))
180216 .executes (context -> {
@@ -187,13 +223,13 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
187223 mod .showLoopInfo = newShowLoopInfo ;
188224 mod .config .showLoopInfo = newShowLoopInfo ;
189225 mod .config .save ();
190-
226+
191227 mod .loopBossBar .visible (newShowLoopInfo );
192-
228+
193229 context .getSource ().sendMessage (Text .literal ("Showing loop info is set to: " + newShowLoopInfo ));
194230 LOGGER .info ("Show loop info set to {}" , newShowLoopInfo );
195231 return 1 ;
196- })))))
232+ }))))
197233
198234 .then (CommandManager .literal ("reset" )
199235 .requires (source -> source .hasPermissionLevel (2 ))
@@ -203,7 +239,7 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
203239 mod .startTimeOfDay = 0 ;
204240 mod .config .startTimeOfDay = 0 ;
205241
206- mod .timeSetting = 0 ;
242+ mod .timeSetting = 13000 ;
207243 mod .config .timeSetting = 0 ;
208244
209245 mod .ticksLeft = mod .loopLengthTicks ;
@@ -215,6 +251,9 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
215251 mod .loopType = LoopTypes .TICKS ;
216252 mod .config .loopType = LoopTypes .TICKS ;
217253
254+ mod .displayTimeInTicks = false ;
255+ mod .config .displayTimeInTicks = false ;
256+
218257 mod .executeCommand ("mocap playback stop_all" );
219258 mod .loopSceneManager .forEachPlayerSceneName (playerSceneName -> {
220259 mod .executeCommand (String .format ("mocap scenes remove %s" , playerSceneName ));
@@ -226,6 +265,6 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
226265 mod .config .save ();
227266 context .getSource ().sendMessage (Text .literal ("Loop reset!" ));
228267 return 1 ;
229- })));
268+ })))) ;
230269 }
231270}
0 commit comments