44import com .mojang .brigadier .context .CommandContext ;
55import com .mojang .brigadier .suggestion .Suggestions ;
66import com .mojang .brigadier .suggestion .SuggestionsBuilder ;
7+ import com .mojang .brigadier .tree .LiteralCommandNode ;
78import dev .dfonline .codeclient .action .Action ;
89import dev .dfonline .codeclient .action .None ;
910import dev .dfonline .codeclient .action .impl .*;
1314import dev .dfonline .codeclient .location .Plot ;
1415import dev .dfonline .codeclient .websocket .SocketHandler ;
1516import net .fabricmc .fabric .api .client .command .v2 .FabricClientCommandSource ;
17+ import net .minecraft .block .entity .SignText ;
1618import net .minecraft .client .font .TextRenderer ;
1719import net .minecraft .item .ItemStack ;
1820import net .minecraft .text .ClickEvent ;
2224import net .minecraft .util .Formatting ;
2325import net .minecraft .util .math .BlockPos ;
2426import org .apache .commons .io .FileUtils ;
27+ import org .jetbrains .annotations .Nullable ;
2528
2629import java .io .IOException ;
2730import java .nio .file .Files ;
@@ -286,7 +289,7 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
286289 return -1 ;
287290 })));
288291
289- dispatcher .register (literal ("jump" )
292+ LiteralCommandNode < FabricClientCommandSource > jumpCommand = dispatcher .register (literal ("jump" )
290293 .then (literal ("player" ).then (argument ("name" , greedyString ()).suggests ((context , builder ) -> suggestJump (JumpType .PLAYER_EVENT , context , builder )).executes (context -> {
291294 var name = context .getArgument ("name" , String .class );
292295 jump (JumpType .PLAYER_EVENT ,name );
@@ -308,6 +311,9 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
308311 return 0 ;
309312 })))
310313 );
314+
315+ dispatcher .register (literal ("goto" ).redirect (jumpCommand ));
316+
311317// dispatcher.register(literal("swapininv").executes(context -> {
312318// if(CodeClient.location instanceof Dev) {
313319// PlaceTemplates action = Utility.createSwapper(Utility.templatesInInventory(), () -> {
@@ -551,10 +557,25 @@ private static CompletableFuture<Suggestions> suggestJump(JumpType type, Command
551557 }
552558 private static void jump (JumpType type , String name ) {
553559 if (CodeClient .location instanceof Dev dev && CodeClient .currentAction instanceof None ) {
554- var results = dev .scanForSigns (type .pattern ,Pattern .compile ("^" + Pattern .quote (name ) + "$" ));
560+ @ Nullable HashMap <BlockPos , SignText > results = null ;
561+ // functions/processes in diamondfire are case-sensitive, and you can have two functions with the same name if they have different cases.
562+ if (type == JumpType .FUNCTION || type == JumpType .PROCESS ) {
563+ results = dev .scanForSigns (type .pattern ,Pattern .compile ("^" + Pattern .quote (name ) + "$" ));
564+ } else {
565+ // however, events do not have this problem and the case of what you type shouldn't matter.
566+ results = dev .scanForSigns (type .pattern ,Pattern .compile ("^" + Pattern .quote (name ) + "$" , Pattern .CASE_INSENSITIVE ));
567+ }
568+
555569 if (results == null ) return ;
556570 var first = results .keySet ().stream ().findFirst ();
557- if (first .isEmpty ()) return ;
571+
572+ // no exact match exists in the plot, so we can run a less restrictive search.
573+ if (first .isEmpty ()) {
574+ results = dev .scanForSigns (type .pattern ,Pattern .compile ("^.*" +Pattern .quote (name )+".*$" , Pattern .CASE_INSENSITIVE ));
575+ if (results == null ) return ;
576+ first = results .keySet ().stream ().findFirst ();
577+ if (first .isEmpty ()) return ; // there is no partial match, so the player doesn't get sent
578+ }
558579 CodeClient .currentAction = new GoTo (first .get ().toCenterPos (), () -> CodeClient .currentAction = new None ());
559580 CodeClient .currentAction .init ();
560581 }
0 commit comments