我想创建一个命令,获取执行该命令的玩家的坐标,并将其储存在三个int(X Y Z)中,并能够在另一个命令中使用它们来传送玩家到这些坐标(这是一个产卵命令),对不起,我的英语很差。
你需要创建一个CommandExecutor,解释在这里。此处. 你可以得到 场地 的碎片(X Y Z)。玩家的位置. 然后你需要把它保存在某个地方,以便在执行其他命令时访问它,例如在Hashmap中把位置链接到玩家。
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
// get location and location fragments
Location loc = player.getLocation();
double x = loc.getX();
double y = loc.getY();
double y = loc.getZ();
// convert to int (information loss)
int xInt = (int)x;
int yInt = (int)y;
int zInt = (int)z;
}
}