package net.minecraft.commands.execution.tasks; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.context.ContextChain; import com.mojang.brigadier.exceptions.CommandSyntaxException; import java.util.function.Supplier; import net.minecraft.commands.ExecutionCommandSource; import net.minecraft.commands.execution.ChainModifiers; import net.minecraft.commands.execution.ExecutionContext; import net.minecraft.commands.execution.Frame; import net.minecraft.commands.execution.TraceCallbacks; import net.minecraft.commands.execution.UnboundEntryAction; public class ExecuteCommand> implements UnboundEntryAction { private final String commandInput; private final ChainModifiers modifiers; private final CommandContext executionContext; public ExecuteCommand(String commandInput, ChainModifiers modifiers, CommandContext executionContext) { this.commandInput = commandInput; this.modifiers = modifiers; this.executionContext = executionContext; } public void execute(T executionCommandSource, ExecutionContext executionContext, Frame frame) { executionContext.profiler().push((Supplier)(() -> "execute " + this.commandInput)); try { executionContext.incrementCost(); int i = ContextChain.runExecutable(this.executionContext, executionCommandSource, ExecutionCommandSource.resultConsumer(), this.modifiers.isForked()); TraceCallbacks traceCallbacks = executionContext.tracer(); if (traceCallbacks != null) { traceCallbacks.onReturn(frame.depth(), this.commandInput, i); } } catch (CommandSyntaxException var9) { executionCommandSource.handleError(var9, this.modifiers.isForked(), executionContext.tracer()); } finally { executionContext.profiler().pop(); } } }