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 javax.annotation.Nullable; import net.minecraft.commands.ExecutionCommandSource; public interface CustomCommandExecutor { void run(T p_310884_, ContextChain p_312906_, ChainModifiers p_310837_, ExecutionControl p_310586_); public interface CommandAdapter extends Command, CustomCommandExecutor { @Override default int run(CommandContext p_309955_) throws CommandSyntaxException { throw new UnsupportedOperationException("This function should not run"); } } public abstract static class WithErrorHandling> implements CustomCommandExecutor { public final void run(T p_310241_, ContextChain p_311766_, ChainModifiers p_310779_, ExecutionControl p_309382_) { try { this.runGuarded(p_310241_, p_311766_, p_310779_, p_309382_); } catch (CommandSyntaxException commandsyntaxexception) { this.onError(commandsyntaxexception, p_310241_, p_310779_, p_309382_.tracer()); p_310241_.callback().onFailure(); } } protected void onError(CommandSyntaxException p_313040_, T p_312743_, ChainModifiers p_309642_, @Nullable TraceCallbacks p_309545_) { p_312743_.handleError(p_313040_, p_309642_.isForked(), p_309545_); } protected abstract void runGuarded(T p_311664_, ContextChain p_312225_, ChainModifiers p_309888_, ExecutionControl p_313051_) throws CommandSyntaxException; } }