1616import net .minecraft .util .Formatting ;
1717import net .replaceitem .discarpet .config .Bot ;
1818
19+ import java .net .URI ;
1920import java .util .Set ;
2021
2122import static net .minecraft .server .command .CommandManager .literal ;
2223
2324public class DiscarpetCommand {
25+ public static final URI DOCS_URI = URI .create ("https://replaceitem.github.io/carpet-discarpet/" );
2426 private static final SuggestionProvider <ServerCommandSource > BOTS = (commandContext , suggestionsBuilder ) ->
2527 CommandSource .suggestMatching (Discarpet .discordBots .keySet ().stream (), suggestionsBuilder );
2628
@@ -32,8 +34,8 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
3234 MutableText text = Text .literal ("Discarpet version " + version ).formatted (Formatting .BLUE );
3335 text .append ("\n For help, see the " );
3436 text .append (Text .literal ("documentation" ).setStyle (Style .EMPTY
35- .withClickEvent (new ClickEvent ( ClickEvent . Action . OPEN_URL , "https://replaceitem.github.io/carpet-discarpet/" ))
36- .withHoverEvent (new HoverEvent ( HoverEvent . Action . SHOW_TEXT , Text .literal ("Click to get to the Discarpet documentation" )))
37+ .withClickEvent (new ClickEvent . OpenUrl ( DOCS_URI ))
38+ .withHoverEvent (new HoverEvent . ShowText ( Text .literal ("Click to get to the Discarpet documentation" )))
3739 .withFormatting (Formatting .UNDERLINE )
3840 .withColor (Formatting .DARK_BLUE )));
3941 return text ;
@@ -43,7 +45,7 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
4345 executes (commandContext ->{
4446 commandContext .getSource ().sendFeedback (() -> {
4547 Set <String > botIDs = Discarpet .discordBots .keySet ();
46- if (botIDs .size () == 0 ) return Text .literal ("There are no bots active" ).formatted (Formatting .RED );
48+ if (botIDs .isEmpty () ) return Text .literal ("There are no bots active" ).formatted (Formatting .RED );
4749 final MutableText t = Text .literal ("There are " + botIDs .size () + " bots active" ).formatted (Formatting .GREEN );
4850 botIDs .forEach (id -> t .append (Text .literal ("\n " + id ).formatted (Formatting .BLUE )));
4951 return t ;
@@ -61,8 +63,8 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
6163 return Text .literal ("Click here to get the invite link for the bot" )
6264 .styled ((style ) -> style .withColor (Formatting .BLUE )
6365 .withFormatting (Formatting .UNDERLINE )
64- .withClickEvent (new ClickEvent ( ClickEvent . Action . OPEN_URL , invite ))
65- .withHoverEvent (new HoverEvent ( HoverEvent . Action . SHOW_TEXT , Text .literal ("Click to open the invite link" )))
66+ .withClickEvent (new ClickEvent . OpenUrl ( URI . create ( invite ) ))
67+ .withHoverEvent (new HoverEvent . ShowText ( Text .literal ("Click to open the invite link" )))
6668 .withInsertion (invite ));
6769 },false );
6870 return 1 ;
0 commit comments