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.jetbrains.annotations.Nullable; public interface CustomCommandExecutor { void run(T source, ContextChain contextChain, ChainModifiers chainModifiers, ExecutionControl executionControl); public interface CommandAdapter extends Command, CustomCommandExecutor { @Override default int run(CommandContext commandContext) throws CommandSyntaxException { throw new UnsupportedOperationException("This function should not run"); } } public abstract static class WithErrorHandling> implements CustomCommandExecutor { public final void run(T executionCommandSource, ContextChain contextChain, ChainModifiers chainModifiers, ExecutionControl executionControl) { try { this.runGuarded(executionCommandSource, contextChain, chainModifiers, executionControl); } catch (CommandSyntaxException var6) { this.onError(var6, executionCommandSource, chainModifiers, executionControl.tracer()); executionCommandSource.callback().onFailure(); } } protected void onError(CommandSyntaxException error, T source, ChainModifiers chainModifiers, @Nullable TraceCallbacks traceCallbacks) { source.handleError(error, chainModifiers.isForked(), traceCallbacks); } protected abstract void runGuarded(T source, ContextChain contextChain, ChainModifiers chainModifiers, ExecutionControl executionControl) throws CommandSyntaxException; } }