Class CommandPerformEvent

java.lang.Object
dev.architectury.event.events.common.CommandPerformEvent

public class CommandPerformEvent extends Object
This event is invoked whenever a command is issued. The ParseResults can be modified and even a custom Throwable can be used to tell the source of failure.

A command fails when any other result than InteractionResult.PASS is returned. When PASS is used, the getResults() is used for execution.

Equivalent to Forge's CommandEvent event.

  • Field Details

  • Constructor Details

    • CommandPerformEvent

      public CommandPerformEvent(com.mojang.brigadier.ParseResults<net.minecraft.commands.CommandSourceStack> results, @Nullable @Nullable Throwable throwable)
      Parameters:
      results - The initial used parsed results.
      throwable - The initial used throwable.
  • Method Details

    • getResults

      public com.mojang.brigadier.ParseResults<net.minecraft.commands.CommandSourceStack> getResults()
      Returns:
      The parsed results for the issued command.
    • setResults

      public void setResults(com.mojang.brigadier.ParseResults<net.minecraft.commands.CommandSourceStack> results)
      Parameters:
      results - The new results the command should use.
    • getThrowable

      @Nullable public @Nullable Throwable getThrowable()
      Returns:
      An throwable to be used as why the command has failed.
    • setThrowable

      public void setThrowable(@Nullable @Nullable Throwable throwable)
      Parameters:
      throwable - The throwable used when the command has failed.