@minecraft/server-admin 1.0.0-beta.1.20.70-preview.21 → 1.0.0-beta.1.20.70-preview.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +57 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* ```json
|
|
19
19
|
* {
|
|
20
20
|
* "module_name": "@minecraft/server-admin",
|
|
21
|
-
* "version": "1.0.0-beta.1.20.70-preview.
|
|
21
|
+
* "version": "1.0.0-beta.1.20.70-preview.24"
|
|
22
22
|
* }
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
@@ -36,6 +36,34 @@ export class SecretString {
|
|
|
36
36
|
/**
|
|
37
37
|
* A collection of server secrets defined in dedicated server
|
|
38
38
|
* configuration.
|
|
39
|
+
* @example getPlayerProfile.ts
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { variables, secrets } from "@minecraft/server-admin";
|
|
42
|
+
* import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net";
|
|
43
|
+
*
|
|
44
|
+
* const serverUrl = variables.get('serverEndpoint');
|
|
45
|
+
*
|
|
46
|
+
* function getPlayerProfile(playerId: string): Promise<HttpResponse> {
|
|
47
|
+
* const req = new HttpRequest(serverUrl + 'getPlayerProfile');
|
|
48
|
+
*
|
|
49
|
+
* req.body = JSON.stringify({
|
|
50
|
+
* playerId,
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* const authTokenSec = secrets.get('authtoken');
|
|
54
|
+
*
|
|
55
|
+
* if (!authTokenSec) {
|
|
56
|
+
* throw new Error('authtoken secret not defined.');
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* req.method = HttpRequestMethod.Post;
|
|
60
|
+
* req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];
|
|
61
|
+
*
|
|
62
|
+
* return http.request(req);
|
|
63
|
+
* }
|
|
64
|
+
*
|
|
65
|
+
* getPlayerProfile('dark navi');
|
|
66
|
+
* ```
|
|
39
67
|
*/
|
|
40
68
|
export class ServerSecrets {
|
|
41
69
|
private constructor();
|
|
@@ -61,6 +89,34 @@ export class ServerSecrets {
|
|
|
61
89
|
/**
|
|
62
90
|
* A collection of server variables defined in dedicated server
|
|
63
91
|
* configuration.
|
|
92
|
+
* @example getPlayerProfile.ts
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import { variables, secrets } from "@minecraft/server-admin";
|
|
95
|
+
* import { http, HttpRequest, HttpRequestMethod, HttpHeader, HttpResponse } from "@minecraft/server-net";
|
|
96
|
+
*
|
|
97
|
+
* const serverUrl = variables.get('serverEndpoint');
|
|
98
|
+
*
|
|
99
|
+
* function getPlayerProfile(playerId: string): Promise<HttpResponse> {
|
|
100
|
+
* const req = new HttpRequest(serverUrl + 'getPlayerProfile');
|
|
101
|
+
*
|
|
102
|
+
* req.body = JSON.stringify({
|
|
103
|
+
* playerId,
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* const authTokenSec = secrets.get('authtoken');
|
|
107
|
+
*
|
|
108
|
+
* if (!authTokenSec) {
|
|
109
|
+
* throw new Error('authtoken secret not defined.');
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* req.method = HttpRequestMethod.Post;
|
|
113
|
+
* req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];
|
|
114
|
+
*
|
|
115
|
+
* return http.request(req);
|
|
116
|
+
* }
|
|
117
|
+
*
|
|
118
|
+
* getPlayerProfile('dark navi');
|
|
119
|
+
* ```
|
|
64
120
|
*/
|
|
65
121
|
export class ServerVariables {
|
|
66
122
|
private constructor();
|