@@ -372,6 +372,48 @@ else if(field.getType().isEnum()) {
372372 return -1 ;
373373 })));
374374
375+ dispatcher .register (literal ("search" )
376+ .then (argument ("query" ,greedyString ()).suggests ((context ,builder ) -> suggestJump (JumpType .ANY , context , builder )).executes (context -> {
377+ if (CodeClient .location instanceof Dev dev ) {
378+ var query = context .getArgument ("query" , String .class );
379+ var results = dev .scanForSigns (JumpType .ANY .pattern ,Pattern .compile ("^.*" +Pattern .quote (query )+".*$" , Pattern .CASE_INSENSITIVE ));
380+
381+ if (results == null || results .isEmpty ()) {
382+ Utility .sendMessage (Text .translatable ("codeclient.search.no_results" ), ChatType .INFO );
383+ return 0 ;
384+ }
385+
386+ var message = Text .translatable ("codeclient.search.results" );
387+ results .forEach ((pos ,text ) -> {
388+ var type = text .getMessage (0 , false ).getString ();
389+ var name = text .getMessage (1 , false ).getString ();
390+
391+ String sub = null ;
392+ if (JumpType .PLAYER_EVENT .pattern .matcher (type ).matches ()) sub = "player" ;
393+ else if (JumpType .ENTITY_EVENT .pattern .matcher (type ).matches ()) sub = "entity" ;
394+ else if (JumpType .FUNCTION .pattern .matcher (type ).matches ()) sub = "func" ;
395+ else if (JumpType .PROCESS .pattern .matcher (type ).matches ()) sub = "proc" ;
396+ else return ;
397+
398+ var action = Text .empty ().append (" [⏼]" ).setStyle (Style .EMPTY
399+ .withColor (Formatting .GREEN )
400+ .withClickEvent (new ClickEvent (ClickEvent .Action .RUN_COMMAND , String .format ("/jump %s %s" , sub , name )))
401+ .withHoverEvent (new HoverEvent (HoverEvent .Action .SHOW_TEXT , Text .translatable ("codeclient.search.hover.teleport" , pos .getX (), pos .getY (), pos .getZ ())))
402+ );
403+ var entry = Text .empty ().append ("\n • " ).formatted (Formatting .GREEN )
404+ .append (Text .empty ().append (name ).formatted (Formatting .WHITE ))
405+ .append (action );
406+ message .append (entry );
407+ });
408+
409+ Utility .sendMessage (message , ChatType .SUCCESS );
410+ } else {
411+ Utility .sendMessage (Text .translatable ("codeclient.warning.dev_mode" ), ChatType .FAIL );
412+ }
413+ return 0 ;
414+ })
415+ ));
416+
375417 LiteralCommandNode <FabricClientCommandSource > jumpCommand = dispatcher .register (literal ("jump" )
376418 .then (literal ("player" ).then (argument ("name" , greedyString ()).suggests ((context , builder ) -> suggestJump (JumpType .PLAYER_EVENT , context , builder )).executes (context -> {
377419 var name = context .getArgument ("name" , String .class );
@@ -616,7 +658,8 @@ private static enum JumpType {
616658 PLAYER_EVENT ("PLAYER EVENT" ),
617659 ENTITY_EVENT ("ENTITY EVENT" ),
618660 FUNCTION ("FUNCTION" ),
619- PROCESS ("PROCESS" );
661+ PROCESS ("PROCESS" ),
662+ ANY ("(((PLAYER)|(ENTITY)) EVENT)|(FUNCTION)|(PROCESS)" );
620663
621664 public final Pattern pattern ;
622665 JumpType (String scan ) {
0 commit comments