ReturnCommand.java
net.minecraft.server.commands.ReturnCommand
信息
- 全限定名:net.minecraft.server.commands.ReturnCommand
- 类型:public class
- 包:net.minecraft.server.commands
- 源码路径:src/main/java/net/minecraft/server/commands/ReturnCommand.java
- 起始行号:L19
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
-
net.minecraft.server.commands.ReturnCommand.ReturnFailCustomExecutor- 类型:
class - 修饰符:
private static - 源码定位:
L33 - 说明:
TODO
- 类型:
-
net.minecraft.server.commands.ReturnCommand.ReturnFromCommandCustomModifier- 类型:
class - 修饰符:
private static - 源码定位:
L42 - 说明:
TODO
- 类型:
-
net.minecraft.server.commands.ReturnCommand.ReturnValueCustomExecutor- 类型:
class - 修饰符:
private static - 源码定位:
L57 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static <T extends ExecutionCommandSource<T>> void register(CommandDispatcher<T> dispatcher) @ L20
- 方法名:register
- 源码定位:L20
- 返回类型:<T extends ExecutionCommandSource
> void - 修饰符:public static
参数:
- dispatcher: CommandDispatcher
说明:
TODO
代码
public class ReturnCommand {
public static <T extends ExecutionCommandSource<T>> void register(CommandDispatcher<T> dispatcher) {
dispatcher.register(
LiteralArgumentBuilder.<T>literal("return")
.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
.then(
RequiredArgumentBuilder.<T, Integer>argument("value", IntegerArgumentType.integer())
.executes(new ReturnCommand.ReturnValueCustomExecutor<>())
)
.then(LiteralArgumentBuilder.<T>literal("fail").executes(new ReturnCommand.ReturnFailCustomExecutor<>()))
.then(LiteralArgumentBuilder.<T>literal("run").forward(dispatcher.getRoot(), new ReturnCommand.ReturnFromCommandCustomModifier<>(), false))
);
}
private static class ReturnFailCustomExecutor<T extends ExecutionCommandSource<T>> implements CustomCommandExecutor.CommandAdapter<T> {
public void run(T sender, ContextChain<T> currentStep, ChainModifiers modifiers, ExecutionControl<T> output) {
sender.callback().onFailure();
Frame frame = output.currentFrame();
frame.returnFailure();
frame.discard();
}
}
private static class ReturnFromCommandCustomModifier<T extends ExecutionCommandSource<T>> implements CustomModifierExecutor.ModifierAdapter<T> {
public void apply(T originalSource, List<T> currentSources, ContextChain<T> currentStep, ChainModifiers modifiers, ExecutionControl<T> output) {
if (currentSources.isEmpty()) {
if (modifiers.isReturn()) {
output.queueNext(FallthroughTask.instance());
}
} else {
output.currentFrame().discard();
ContextChain<T> nextState = currentStep.nextStage();
String command = nextState.getTopContext().getInput();
output.queueNext(new BuildContexts.Continuation<>(command, nextState, modifiers.setReturn(), originalSource, currentSources));
}
}
}
private static class ReturnValueCustomExecutor<T extends ExecutionCommandSource<T>> implements CustomCommandExecutor.CommandAdapter<T> {
public void run(T sender, ContextChain<T> currentStep, ChainModifiers modifiers, ExecutionControl<T> output) {
int returnValue = IntegerArgumentType.getInteger(currentStep.getTopContext(), "value");
sender.callback().onSuccess(returnValue);
Frame frame = output.currentFrame();
frame.returnSuccess(returnValue);
frame.discard();
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Commands.hasPermission()
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
FallthroughTask.instance()
- 引用位置: