We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
CommandNode是MethodAnnotation和ClassAnnotation使用的数据结构,用以增强Argument,使创建命令更为简便
@Command("teleport") public void teleport(@Sender Entity entity,String world,int x,int y,int z)
在MethodAnnotation中,每有一个形参就会添加一个对应的CommandNode,SenderNode和ArgumentNode为CommandNode的子类,负责处理相应的参数
在转换方法为CommandNode时,会首先从ArgumentManager中找对应的Argument,若未找到,则在Provide中寻找,若再未找到将会抛出一个异常
假设用户输入了命令和Args
/teleport hell 10 100 -100
CommandNode就会一个个检查用户的数据正确与否 以上面的命令为例
public void LocationProvider{ @Provide public Location stringLocation(String world,int x,int y,int z){ return new Location(world,x,y,z); } @Provide public Location senderLocation(@Sender Entity entity,int x,int y,int z){ return stringLocation(entity.getWorld(),x,y,z); } }
这个Provider将会在内存中被这样创建
由于有两个方法返回同样的类型,故我们认为他们是等价的
public void teleport(@Sender Entity entity,Location location){ entity.teleport(location); }
面对返回同样一个值,系统会这样构建CommandNode