实验性
表示在专用服务器配置中定义的服务器变量的集合。
A collection of server variables defined in dedicated server configuration.
import { variables, secrets } from "@minecraft/server-admin";import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net";const serverUrl = variables.get('serverEndpoint');function getPlayerProfile(playerId: string): Promise<HttpResponse> { const req = new HttpRequest(serverUrl + 'getPlayerProfile'); req.body = JSON.stringify({ playerId, }); const authTokenSec = secrets.get('authtoken'); if (!authTokenSec) { throw new Error('authtoken secret not defined.'); } req.method = HttpRequestMethod.Post; req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)]; return http.request(req);} 复制
import { variables, secrets } from "@minecraft/server-admin";import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net";const serverUrl = variables.get('serverEndpoint');function getPlayerProfile(playerId: string): Promise<HttpResponse> { const req = new HttpRequest(serverUrl + 'getPlayerProfile'); req.body = JSON.stringify({ playerId, }); const authTokenSec = secrets.get('authtoken'); if (!authTokenSec) { throw new Error('authtoken secret not defined.'); } req.method = HttpRequestMethod.Post; req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)]; return http.request(req);}
只读
已配置且可用的服务器变量名称组成的数组。
A list of available, configured server variables.
返回在专用服务器配置 JSON 文件中定义的指定变量的值。
Returns the value of variable that has been configured in a dedicated server configuration JSON file.
无法在只读模式下调用此函数,详见 WorldBeforeEvents。
表示在专用服务器配置中定义的服务器变量的集合。
A collection of server variables defined in dedicated server configuration.
示例: getPlayerProfile.ts