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