@@ -73,12 +73,16 @@ public static void register() {
7373 private static RequiredArgumentBuilder <ServerCommandSource , Identifier > buildArgTree (CommandHandler handler ) {
7474 return argument ("template" , IdentifierArgumentType .identifier ())
7575 .suggests (STRUCTURE_SUGGESTION_PROVIDER )
76- .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), new Vec3d (0.5 , 2 , 0.5 ), List .of ()))
76+ .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), new Vec3d (0.5 , 2 , 0.5 ), List .of (), List . of () ))
7777 .then (argument ("pos" , Vec3ArgumentType .vec3 ())
78- .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), Vec3ArgumentType .getVec3 (context , "pos" ), List .of ()))
78+ .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), Vec3ArgumentType .getVec3 (context , "pos" ), List .of (), List . of () ))
7979 .then (argument ("setupFunction" , CommandFunctionArgumentType .commandFunction ())
8080 .suggests (FunctionCommand .SUGGESTION_PROVIDER )
81- .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), Vec3ArgumentType .getVec3 (context , "pos" ), CommandFunctionArgumentType .getFunctions (context , "setupFunction" )))));
81+ .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), Vec3ArgumentType .getVec3 (context , "pos" ), CommandFunctionArgumentType .getFunctions (context , "setupFunction" ), List .of ()))
82+ .then (
83+ argument ("playerFunction" , CommandFunctionArgumentType .commandFunction ())
84+ .suggests (FunctionCommand .SUGGESTION_PROVIDER )
85+ .executes (context -> handler .execute (context , IdentifierArgumentType .getIdentifier (context , "template" ), Vec3ArgumentType .getVec3 (context , "pos" ), CommandFunctionArgumentType .getFunctions (context , "setupFunction" ), CommandFunctionArgumentType .getFunctions (context , "playerFunction" ))))));
8286 }
8387
8488 // Joinked from GameCommand because brigadier can't deal with childless redirects
@@ -98,7 +102,7 @@ private static int executeLeave(CommandContext<ServerCommandSource> context) thr
98102 return Command .SINGLE_SUCCESS ;
99103 }
100104
101- private static int executeSign (CommandContext <ServerCommandSource > context , Identifier structure , Vec3d pos , Collection <CommandFunction <ServerCommandSource >> functions ) throws CommandSyntaxException {
105+ private static int executeSign (CommandContext <ServerCommandSource > context , Identifier structure , Vec3d pos , Collection <CommandFunction <ServerCommandSource >> functions , Collection < CommandFunction < ServerCommandSource >> playerFunctions ) throws CommandSyntaxException {
102106 var signPos = BlockPosArgumentType .getLoadedBlockPos (context , "signPos" );
103107 var source = context .getSource ();
104108 var block = source .getWorld ().getBlockState (signPos ).getBlock ();
@@ -163,11 +167,11 @@ private static String getCommandEnd(CommandContext<ServerCommandSource> context)
163167 return context .getInput ().substring (mainNode .getRange ().getStart ());
164168 }
165169
166- private static int executeOpen (CommandContext <ServerCommandSource > context , Identifier structure , Vec3d pos , Collection <CommandFunction <ServerCommandSource >> functions ) throws CommandSyntaxException {
170+ private static int executeOpen (CommandContext <ServerCommandSource > context , Identifier structure , Vec3d pos , Collection <CommandFunction <ServerCommandSource >> functions , Collection < CommandFunction < ServerCommandSource >> playerFunctions ) throws CommandSyntaxException {
167171 var source = context .getSource ();
168172 var player = source .getPlayerOrThrow ();
169173
170- DemoBoxGame .open (new DemoBoxGame .Settings (structure , pos , functions .stream ().map (CommandFunction ::id ).toList ()))
174+ DemoBoxGame .open (new DemoBoxGame .Settings (structure , pos , functions .stream ().map (CommandFunction ::id ).toList (), playerFunctions . stream (). map ( CommandFunction :: id ). toList () ))
171175 .thenAcceptAsync (gameSpace -> {
172176 var space = GameSpaceManager .get ().byPlayer (player );
173177 if (space != null ) space .getPlayers ().kick (player );
@@ -182,6 +186,6 @@ private static int executeOpen(CommandContext<ServerCommandSource> context, Iden
182186
183187 @ FunctionalInterface
184188 private interface CommandHandler {
185- int execute (CommandContext <ServerCommandSource > context , Identifier structure , Vec3d pos , Collection <CommandFunction <ServerCommandSource >> functions ) throws CommandSyntaxException ;
189+ int execute (CommandContext <ServerCommandSource > context , Identifier structure , Vec3d pos , Collection <CommandFunction <ServerCommandSource >> functions , Collection < CommandFunction < ServerCommandSource >> playerFunctions ) throws CommandSyntaxException ;
186190 }
187191}
0 commit comments