Class Commands

java.lang.Object
net.minecraft.commands.Commands

public class Commands extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • mapSource

      public static <S> com.mojang.brigadier.ParseResults<S> mapSource(com.mojang.brigadier.ParseResults<S> parseResults, UnaryOperator<S> mapper)
    • performPrefixedCommand

      public void performPrefixedCommand(CommandSourceStack source, String command)
    • performCommand

      public void performCommand(com.mojang.brigadier.ParseResults<CommandSourceStack> parseResults, String command)
    • finishParsing

      @Nullable private static com.mojang.brigadier.context.ContextChain<CommandSourceStack> finishParsing(com.mojang.brigadier.ParseResults<CommandSourceStack> parseResults, String command, CommandSourceStack source)
    • executeCommandInContext

      public static void executeCommandInContext(CommandSourceStack source, Consumer<ExecutionContext<CommandSourceStack>> contextConsumer)
    • sendCommands

      public void sendCommands(ServerPlayer player)
    • fillUsableCommands

      private void fillUsableCommands(com.mojang.brigadier.tree.CommandNode<CommandSourceStack> rootCommandSource, com.mojang.brigadier.tree.CommandNode<SharedSuggestionProvider> rootSuggestion, CommandSourceStack source, Map<com.mojang.brigadier.tree.CommandNode<CommandSourceStack>,com.mojang.brigadier.tree.CommandNode<SharedSuggestionProvider>> commandNodeToSuggestionNode)
    • literal

      public static com.mojang.brigadier.builder.LiteralArgumentBuilder<CommandSourceStack> literal(String name)
      Creates a new argument. Intended to be imported statically. The benefit of this over the brigadier LiteralArgumentBuilder.literal method is that it is typed to CommandSource.
    • argument

      public static <T> com.mojang.brigadier.builder.RequiredArgumentBuilder<CommandSourceStack,T> argument(String name, com.mojang.brigadier.arguments.ArgumentType<T> type)
      Creates a new argument. Intended to be imported statically. The benefit of this over the brigadier RequiredArgumentBuilder.argument(java.lang.String, com.mojang.brigadier.arguments.ArgumentType<T>) method is that it is typed to CommandSource.
    • createValidator

      public static Predicate<String> createValidator(Commands.ParseFunction parser)
    • getDispatcher

      public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> getDispatcher()
    • validateParseResults

      public static <S> void validateParseResults(com.mojang.brigadier.ParseResults<S> parseResults) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException
    • getParseException

      @Nullable public static <S> com.mojang.brigadier.exceptions.CommandSyntaxException getParseException(com.mojang.brigadier.ParseResults<S> result)
    • createValidationContext

      public static CommandBuildContext createValidationContext(HolderLookup.Provider provider)
    • validate

      public static void validate()