package net.minecraft.commands.execution; import com.mojang.brigadier.Command; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.ContextChain; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.commands.ExecutionCommandSource; import org.jspecify.annotations.Nullable; public interface CustomCommandExecutor { void run(T sender, ContextChain currentStep, ChainModifiers modifiers, ExecutionControl output); public interface CommandAdapter extends CustomCommandExecutor, Command { @Override default int run(final CommandContext context) throws CommandSyntaxException { throw new UnsupportedOperationException("This function should not run"); } } public abstract static class WithErrorHandling> implements CustomCommandExecutor { public final void run(final T sender, final ContextChain currentStep, final ChainModifiers modifiers, final ExecutionControl output) { try { this.runGuarded(sender, currentStep, modifiers, output); } catch (CommandSyntaxException var6) { this.onError(var6, sender, modifiers, output.tracer()); sender.callback().onFailure(); } } protected void onError(final CommandSyntaxException e, final T sender, final ChainModifiers modifiers, @Nullable final TraceCallbacks tracer) { sender.handleError(e, modifiers.isForked(), tracer); } protected abstract void runGuarded(T sender, ContextChain currentStep, ChainModifiers modifiers, ExecutionControl output) throws CommandSyntaxException; } }