@minecraft/server-net 1.0.0-beta.00001b41 → 1.0.0-beta.1.12.111-stable
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/README.md +9 -9
- package/index.d.ts +722 -175
- package/package.json +20 -18
- package/.eslintrc.json +0 -23
- package/tests.ts +0 -127
- package/tsconfig.json +0 -20
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# `@minecraft/server-net`
|
|
2
|
-
|
|
3
|
-
The `@minecraft/server-net` module contains types for executing HTTP-based requests. This module can only be used on Bedrock Dedicated Server.
|
|
4
|
-
|
|
5
|
-
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
6
|
-
|
|
7
|
-
See full documentation for this module here:
|
|
8
|
-
|
|
9
|
-
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi
|
|
1
|
+
# `@minecraft/server-net`
|
|
2
|
+
|
|
3
|
+
The `@minecraft/server-net` module contains types for executing HTTP-based requests. This module can only be used on Bedrock Dedicated Server. These APIs do not function within the Minecraft game client or within Minecraft Realms.
|
|
4
|
+
|
|
5
|
+
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
6
|
+
|
|
7
|
+
See full documentation for this module here:
|
|
8
|
+
|
|
9
|
+
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-net/minecraft-server-net
|
package/index.d.ts
CHANGED
|
@@ -1,175 +1,722 @@
|
|
|
1
|
-
// Type definitions for Minecraft Bedrock Edition script APIs
|
|
2
|
-
// Project: https://docs.microsoft.com/minecraft/creator/
|
|
3
|
-
// Definitions by: Jake Shirley <https://github.com/JakeShirley>
|
|
4
|
-
// Mike Ammerlaan <https://github.com/mammerla>
|
|
5
|
-
|
|
6
|
-
/* *****************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
***************************************************************************** */
|
|
9
|
-
/**
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
1
|
+
// Type definitions for Minecraft Bedrock Edition script APIs
|
|
2
|
+
// Project: https://docs.microsoft.com/minecraft/creator/
|
|
3
|
+
// Definitions by: Jake Shirley <https://github.com/JakeShirley>
|
|
4
|
+
// Mike Ammerlaan <https://github.com/mammerla>
|
|
5
|
+
|
|
6
|
+
/* *****************************************************************************
|
|
7
|
+
Copyright (c) Microsoft Corporation.
|
|
8
|
+
***************************************************************************** */
|
|
9
|
+
/**
|
|
10
|
+
* @beta
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
* The `@minecraft/server-net` module contains types for
|
|
13
|
+
* executing HTTP-based requests. This module can only be used
|
|
14
|
+
* on Bedrock Dedicated Server. These APIs do not function
|
|
15
|
+
* within the Minecraft game client or within Minecraft Realms.
|
|
16
|
+
*
|
|
17
|
+
* Manifest Details
|
|
18
|
+
* ```json
|
|
19
|
+
* {
|
|
20
|
+
* "module_name": "@minecraft/server-net",
|
|
21
|
+
* "version": "1.0.0-beta"
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
import * as minecraftcommon from '@minecraft/common';
|
|
27
|
+
import * as minecraftserver from '@minecraft/server';
|
|
28
|
+
import * as minecraftserveradmin from '@minecraft/server-admin';
|
|
29
|
+
export enum HttpRequestMethod {
|
|
30
|
+
/**
|
|
31
|
+
* @remarks
|
|
32
|
+
* Represents the method for an HTTP HEAD request. HEAD
|
|
33
|
+
* requests are similar to a GET request, but are commonly used
|
|
34
|
+
* to retrieve just the HTTP response headers from the
|
|
35
|
+
* specified URI, and not the body contents.
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
Delete = 'Delete',
|
|
39
|
+
/**
|
|
40
|
+
* @remarks
|
|
41
|
+
* Represents the method for an HTTP PUT request. POST requests
|
|
42
|
+
* are commonly used to create a new resource that is a
|
|
43
|
+
* subordinate of the specified URI.
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
Get = 'Get',
|
|
47
|
+
/**
|
|
48
|
+
* @remarks
|
|
49
|
+
* Represents the method for an HTTP PUT request. GET requests
|
|
50
|
+
* are commonly used to retrieve information about a resource
|
|
51
|
+
* at the specified URI.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
Head = 'Head',
|
|
55
|
+
/**
|
|
56
|
+
* @remarks
|
|
57
|
+
* Represents the method for an HTTP PUT request. GET requests
|
|
58
|
+
* are commonly used to retrieve information about a resource
|
|
59
|
+
* at the specified URI.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
Post = 'Post',
|
|
63
|
+
/**
|
|
64
|
+
* @remarks
|
|
65
|
+
* Represents the method for an HTTP PUT request. PUT requests
|
|
66
|
+
* are commonly used to update a single resource that already
|
|
67
|
+
* exists in a resource collection.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
Put = 'Put',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Represents the unique type of network packet.
|
|
75
|
+
*/
|
|
76
|
+
export enum PacketId {
|
|
77
|
+
ActorEventPacket = 'ActorEventPacket',
|
|
78
|
+
ActorPickRequestPacket = 'ActorPickRequestPacket',
|
|
79
|
+
AddActorPacket = 'AddActorPacket',
|
|
80
|
+
AddBehaviorTreePacket = 'AddBehaviorTreePacket',
|
|
81
|
+
AddItemActorPacket = 'AddItemActorPacket',
|
|
82
|
+
AddPaintingPacket = 'AddPaintingPacket',
|
|
83
|
+
AddPlayerPacket = 'AddPlayerPacket',
|
|
84
|
+
AddVolumeEntityPacket = 'AddVolumeEntityPacket',
|
|
85
|
+
AgentActionEventPacket = 'AgentActionEventPacket',
|
|
86
|
+
AgentAnimationPacket = 'AgentAnimationPacket',
|
|
87
|
+
AnimateEntityPacket = 'AnimateEntityPacket',
|
|
88
|
+
AnimatePacket = 'AnimatePacket',
|
|
89
|
+
AnvilDamagePacket = 'AnvilDamagePacket',
|
|
90
|
+
AutomationClientConnectPacket = 'AutomationClientConnectPacket',
|
|
91
|
+
AvailableActorIdentifiersPacket = 'AvailableActorIdentifiersPacket',
|
|
92
|
+
AvailableCommandsPacket = 'AvailableCommandsPacket',
|
|
93
|
+
AwardAchievementPacket = 'AwardAchievementPacket',
|
|
94
|
+
BiomeDefinitionListPacket = 'BiomeDefinitionListPacket',
|
|
95
|
+
BlockActorDataPacket = 'BlockActorDataPacket',
|
|
96
|
+
BlockEventPacket = 'BlockEventPacket',
|
|
97
|
+
BlockPickRequestPacket = 'BlockPickRequestPacket',
|
|
98
|
+
BookEditPacket = 'BookEditPacket',
|
|
99
|
+
BossEventPacket = 'BossEventPacket',
|
|
100
|
+
CameraAimAssistPacket = 'CameraAimAssistPacket',
|
|
101
|
+
CameraAimAssistPresetsPacket = 'CameraAimAssistPresetsPacket',
|
|
102
|
+
CameraInstructionPacket = 'CameraInstructionPacket',
|
|
103
|
+
CameraPacket = 'CameraPacket',
|
|
104
|
+
CameraPresetsPacket = 'CameraPresetsPacket',
|
|
105
|
+
CameraShakePacket = 'CameraShakePacket',
|
|
106
|
+
ChangeDimensionPacket = 'ChangeDimensionPacket',
|
|
107
|
+
ChangeMobPropertyPacket = 'ChangeMobPropertyPacket',
|
|
108
|
+
ChunkRadiusUpdatedPacket = 'ChunkRadiusUpdatedPacket',
|
|
109
|
+
ClientboundCloseFormPacket = 'ClientboundCloseFormPacket',
|
|
110
|
+
ClientboundControlSchemeSetPacket = 'ClientboundControlSchemeSetPacket',
|
|
111
|
+
ClientboundDebugRendererPacket = 'ClientboundDebugRendererPacket',
|
|
112
|
+
ClientboundMapItemDataPacket = 'ClientboundMapItemDataPacket',
|
|
113
|
+
ClientCacheBlobStatusPacket = 'ClientCacheBlobStatusPacket',
|
|
114
|
+
ClientCacheMissResponsePacket = 'ClientCacheMissResponsePacket',
|
|
115
|
+
ClientCacheStatusPacket = 'ClientCacheStatusPacket',
|
|
116
|
+
ClientCameraAimAssistPacket = 'ClientCameraAimAssistPacket',
|
|
117
|
+
ClientMovementPredictionSyncPacket = 'ClientMovementPredictionSyncPacket',
|
|
118
|
+
ClientToServerHandshakePacket = 'ClientToServerHandshakePacket',
|
|
119
|
+
CodeBuilderPacket = 'CodeBuilderPacket',
|
|
120
|
+
CodeBuilderSourcePacket = 'CodeBuilderSourcePacket',
|
|
121
|
+
CommandBlockUpdatePacket = 'CommandBlockUpdatePacket',
|
|
122
|
+
CommandOutputPacket = 'CommandOutputPacket',
|
|
123
|
+
CommandRequestPacket = 'CommandRequestPacket',
|
|
124
|
+
CompletedUsingItemPacket = 'CompletedUsingItemPacket',
|
|
125
|
+
ContainerClosePacket = 'ContainerClosePacket',
|
|
126
|
+
ContainerOpenPacket = 'ContainerOpenPacket',
|
|
127
|
+
ContainerRegistryCleanupPacket = 'ContainerRegistryCleanupPacket',
|
|
128
|
+
ContainerSetDataPacket = 'ContainerSetDataPacket',
|
|
129
|
+
CorrectPlayerMovePredictionPacket = 'CorrectPlayerMovePredictionPacket',
|
|
130
|
+
CraftingDataPacket = 'CraftingDataPacket',
|
|
131
|
+
CreatePhotoPacket = 'CreatePhotoPacket',
|
|
132
|
+
CreativeContentPacket = 'CreativeContentPacket',
|
|
133
|
+
CurrentStructureFeaturePacket = 'CurrentStructureFeaturePacket',
|
|
134
|
+
DeathInfoPacket = 'DeathInfoPacket',
|
|
135
|
+
DebugInfoPacket = 'DebugInfoPacket',
|
|
136
|
+
DimensionDataPacket = 'DimensionDataPacket',
|
|
137
|
+
DisconnectPacket = 'DisconnectPacket',
|
|
138
|
+
EditorNetworkPacket = 'EditorNetworkPacket',
|
|
139
|
+
EducationSettingsPacket = 'EducationSettingsPacket',
|
|
140
|
+
EduUriResourcePacket = 'EduUriResourcePacket',
|
|
141
|
+
EmoteListPacket = 'EmoteListPacket',
|
|
142
|
+
EmotePacket = 'EmotePacket',
|
|
143
|
+
FeatureRegistryPacket = 'FeatureRegistryPacket',
|
|
144
|
+
GameRulesChangedPacket = 'GameRulesChangedPacket',
|
|
145
|
+
GameTestRequestPacket = 'GameTestRequestPacket',
|
|
146
|
+
GameTestResultsPacket = 'GameTestResultsPacket',
|
|
147
|
+
GuiDataPickItemPacket = 'GuiDataPickItemPacket',
|
|
148
|
+
HurtArmorPacket = 'HurtArmorPacket',
|
|
149
|
+
InteractPacket = 'InteractPacket',
|
|
150
|
+
InventoryContentPacket = 'InventoryContentPacket',
|
|
151
|
+
InventorySlotPacket = 'InventorySlotPacket',
|
|
152
|
+
InventoryTransactionPacket = 'InventoryTransactionPacket',
|
|
153
|
+
ItemRegistryPacket = 'ItemRegistryPacket',
|
|
154
|
+
ItemStackRequestPacket = 'ItemStackRequestPacket',
|
|
155
|
+
ItemStackResponsePacket = 'ItemStackResponsePacket',
|
|
156
|
+
JigsawStructureDataPacket = 'JigsawStructureDataPacket',
|
|
157
|
+
LabTablePacket = 'LabTablePacket',
|
|
158
|
+
LecternUpdatePacket = 'LecternUpdatePacket',
|
|
159
|
+
LegacyTelemetryEventPacket = 'LegacyTelemetryEventPacket',
|
|
160
|
+
LessonProgressPacket = 'LessonProgressPacket',
|
|
161
|
+
LevelChunkPacket = 'LevelChunkPacket',
|
|
162
|
+
LevelEventGenericPacket = 'LevelEventGenericPacket',
|
|
163
|
+
LevelEventPacket = 'LevelEventPacket',
|
|
164
|
+
LevelSoundEventPacket = 'LevelSoundEventPacket',
|
|
165
|
+
LoginPacket = 'LoginPacket',
|
|
166
|
+
MapCreateLockedCopyPacket = 'MapCreateLockedCopyPacket',
|
|
167
|
+
MapInfoRequestPacket = 'MapInfoRequestPacket',
|
|
168
|
+
MobArmorEquipmentPacket = 'MobArmorEquipmentPacket',
|
|
169
|
+
MobEffectPacket = 'MobEffectPacket',
|
|
170
|
+
MobEquipmentPacket = 'MobEquipmentPacket',
|
|
171
|
+
ModalFormRequestPacket = 'ModalFormRequestPacket',
|
|
172
|
+
ModalFormResponsePacket = 'ModalFormResponsePacket',
|
|
173
|
+
MotionPredictionHintsPacket = 'MotionPredictionHintsPacket',
|
|
174
|
+
MoveActorAbsolutePacket = 'MoveActorAbsolutePacket',
|
|
175
|
+
MoveActorDeltaPacket = 'MoveActorDeltaPacket',
|
|
176
|
+
MovementEffectPacket = 'MovementEffectPacket',
|
|
177
|
+
MovePlayerPacket = 'MovePlayerPacket',
|
|
178
|
+
MultiplayerSettingsPacket = 'MultiplayerSettingsPacket',
|
|
179
|
+
NetworkChunkPublisherUpdatePacket = 'NetworkChunkPublisherUpdatePacket',
|
|
180
|
+
NetworkSettingsPacket = 'NetworkSettingsPacket',
|
|
181
|
+
NetworkStackLatencyPacket = 'NetworkStackLatencyPacket',
|
|
182
|
+
NpcDialoguePacket = 'NpcDialoguePacket',
|
|
183
|
+
NpcRequestPacket = 'NpcRequestPacket',
|
|
184
|
+
OnScreenTextureAnimationPacket = 'OnScreenTextureAnimationPacket',
|
|
185
|
+
OpenSignPacket = 'OpenSignPacket',
|
|
186
|
+
PacketViolationWarningPacket = 'PacketViolationWarningPacket',
|
|
187
|
+
PhotoTransferPacket = 'PhotoTransferPacket',
|
|
188
|
+
PlayerActionPacket = 'PlayerActionPacket',
|
|
189
|
+
PlayerArmorDamagePacket = 'PlayerArmorDamagePacket',
|
|
190
|
+
PlayerAuthInputPacket = 'PlayerAuthInputPacket',
|
|
191
|
+
PlayerEnchantOptionsPacket = 'PlayerEnchantOptionsPacket',
|
|
192
|
+
PlayerFogPacket = 'PlayerFogPacket',
|
|
193
|
+
PlayerHotbarPacket = 'PlayerHotbarPacket',
|
|
194
|
+
PlayerListPacket = 'PlayerListPacket',
|
|
195
|
+
PlayerLocationPacket = 'PlayerLocationPacket',
|
|
196
|
+
PlayerSkinPacket = 'PlayerSkinPacket',
|
|
197
|
+
PlayerStartItemCooldownPacket = 'PlayerStartItemCooldownPacket',
|
|
198
|
+
PlayerToggleCrafterSlotRequestPacket = 'PlayerToggleCrafterSlotRequestPacket',
|
|
199
|
+
PlayerUpdateEntityOverridesPacket = 'PlayerUpdateEntityOverridesPacket',
|
|
200
|
+
PlaySoundPacket = 'PlaySoundPacket',
|
|
201
|
+
PlayStatusPacket = 'PlayStatusPacket',
|
|
202
|
+
PositionTrackingDBClientRequestPacket = 'PositionTrackingDBClientRequestPacket',
|
|
203
|
+
PositionTrackingDBServerBroadcastPacket = 'PositionTrackingDBServerBroadcastPacket',
|
|
204
|
+
PurchaseReceiptPacket = 'PurchaseReceiptPacket',
|
|
205
|
+
RefreshEntitlementsPacket = 'RefreshEntitlementsPacket',
|
|
206
|
+
RemoveActorPacket = 'RemoveActorPacket',
|
|
207
|
+
RemoveObjectivePacket = 'RemoveObjectivePacket',
|
|
208
|
+
RemoveVolumeEntityPacket = 'RemoveVolumeEntityPacket',
|
|
209
|
+
RequestAbilityPacket = 'RequestAbilityPacket',
|
|
210
|
+
RequestChunkRadiusPacket = 'RequestChunkRadiusPacket',
|
|
211
|
+
RequestNetworkSettingsPacket = 'RequestNetworkSettingsPacket',
|
|
212
|
+
RequestPermissionsPacket = 'RequestPermissionsPacket',
|
|
213
|
+
ResourcePackChunkDataPacket = 'ResourcePackChunkDataPacket',
|
|
214
|
+
ResourcePackChunkRequestPacket = 'ResourcePackChunkRequestPacket',
|
|
215
|
+
ResourcePackClientResponsePacket = 'ResourcePackClientResponsePacket',
|
|
216
|
+
ResourcePackDataInfoPacket = 'ResourcePackDataInfoPacket',
|
|
217
|
+
ResourcePacksInfoPacket = 'ResourcePacksInfoPacket',
|
|
218
|
+
ResourcePackStackPacket = 'ResourcePackStackPacket',
|
|
219
|
+
RespawnPacket = 'RespawnPacket',
|
|
220
|
+
ScriptMessagePacket = 'ScriptMessagePacket',
|
|
221
|
+
ServerboundDiagnosticsPacket = 'ServerboundDiagnosticsPacket',
|
|
222
|
+
ServerboundLoadingScreenPacket = 'ServerboundLoadingScreenPacket',
|
|
223
|
+
ServerboundPackSettingChangePacket = 'ServerboundPackSettingChangePacket',
|
|
224
|
+
ServerPlayerPostMovePositionPacket = 'ServerPlayerPostMovePositionPacket',
|
|
225
|
+
ServerScriptDebugDrawerPacket = 'ServerScriptDebugDrawerPacket',
|
|
226
|
+
ServerSettingsRequestPacket = 'ServerSettingsRequestPacket',
|
|
227
|
+
ServerSettingsResponsePacket = 'ServerSettingsResponsePacket',
|
|
228
|
+
ServerStatsPacket = 'ServerStatsPacket',
|
|
229
|
+
ServerToClientHandshakePacket = 'ServerToClientHandshakePacket',
|
|
230
|
+
SetActorDataPacket = 'SetActorDataPacket',
|
|
231
|
+
SetActorLinkPacket = 'SetActorLinkPacket',
|
|
232
|
+
SetActorMotionPacket = 'SetActorMotionPacket',
|
|
233
|
+
SetCommandsEnabledPacket = 'SetCommandsEnabledPacket',
|
|
234
|
+
SetDefaultGameTypePacket = 'SetDefaultGameTypePacket',
|
|
235
|
+
SetDifficultyPacket = 'SetDifficultyPacket',
|
|
236
|
+
SetDisplayObjectivePacket = 'SetDisplayObjectivePacket',
|
|
237
|
+
SetHealthPacket = 'SetHealthPacket',
|
|
238
|
+
SetHudPacket = 'SetHudPacket',
|
|
239
|
+
SetLastHurtByPacket = 'SetLastHurtByPacket',
|
|
240
|
+
SetLocalPlayerAsInitializedPacket = 'SetLocalPlayerAsInitializedPacket',
|
|
241
|
+
SetPlayerGameTypePacket = 'SetPlayerGameTypePacket',
|
|
242
|
+
SetPlayerInventoryOptionsPacket = 'SetPlayerInventoryOptionsPacket',
|
|
243
|
+
SetScoreboardIdentityPacket = 'SetScoreboardIdentityPacket',
|
|
244
|
+
SetScorePacket = 'SetScorePacket',
|
|
245
|
+
SetSpawnPositionPacket = 'SetSpawnPositionPacket',
|
|
246
|
+
SetTimePacket = 'SetTimePacket',
|
|
247
|
+
SettingsCommandPacket = 'SettingsCommandPacket',
|
|
248
|
+
SetTitlePacket = 'SetTitlePacket',
|
|
249
|
+
ShowCreditsPacket = 'ShowCreditsPacket',
|
|
250
|
+
ShowProfilePacket = 'ShowProfilePacket',
|
|
251
|
+
ShowStoreOfferPacket = 'ShowStoreOfferPacket',
|
|
252
|
+
SimpleEventPacket = 'SimpleEventPacket',
|
|
253
|
+
SimulationTypePacket = 'SimulationTypePacket',
|
|
254
|
+
SpawnExperienceOrbPacket = 'SpawnExperienceOrbPacket',
|
|
255
|
+
SpawnParticleEffectPacket = 'SpawnParticleEffectPacket',
|
|
256
|
+
StartGamePacket = 'StartGamePacket',
|
|
257
|
+
StopSoundPacket = 'StopSoundPacket',
|
|
258
|
+
StructureBlockUpdatePacket = 'StructureBlockUpdatePacket',
|
|
259
|
+
StructureTemplateDataRequestPacket = 'StructureTemplateDataRequestPacket',
|
|
260
|
+
StructureTemplateDataResponsePacket = 'StructureTemplateDataResponsePacket',
|
|
261
|
+
SubChunkPacket = 'SubChunkPacket',
|
|
262
|
+
SubChunkRequestPacket = 'SubChunkRequestPacket',
|
|
263
|
+
SubClientLoginPacket = 'SubClientLoginPacket',
|
|
264
|
+
SyncActorPropertyPacket = 'SyncActorPropertyPacket',
|
|
265
|
+
TakeItemActorPacket = 'TakeItemActorPacket',
|
|
266
|
+
TextPacket = 'TextPacket',
|
|
267
|
+
TickingAreasLoadStatusPacket = 'TickingAreasLoadStatusPacket',
|
|
268
|
+
ToastRequestPacket = 'ToastRequestPacket',
|
|
269
|
+
TransferPacket = 'TransferPacket',
|
|
270
|
+
TrimDataPacket = 'TrimDataPacket',
|
|
271
|
+
UnlockedRecipesPacket = 'UnlockedRecipesPacket',
|
|
272
|
+
UpdateAbilitiesPacket = 'UpdateAbilitiesPacket',
|
|
273
|
+
UpdateAdventureSettingsPacket = 'UpdateAdventureSettingsPacket',
|
|
274
|
+
UpdateAttributesPacket = 'UpdateAttributesPacket',
|
|
275
|
+
UpdateBlockPacket = 'UpdateBlockPacket',
|
|
276
|
+
UpdateBlockSyncedPacket = 'UpdateBlockSyncedPacket',
|
|
277
|
+
UpdateClientInputLocksPacket = 'UpdateClientInputLocksPacket',
|
|
278
|
+
UpdateClientOptionsPacket = 'UpdateClientOptionsPacket',
|
|
279
|
+
UpdateEquipPacket = 'UpdateEquipPacket',
|
|
280
|
+
UpdatePlayerGameTypePacket = 'UpdatePlayerGameTypePacket',
|
|
281
|
+
UpdateSoftEnumPacket = 'UpdateSoftEnumPacket',
|
|
282
|
+
UpdateSubChunkBlocksPacket = 'UpdateSubChunkBlocksPacket',
|
|
283
|
+
UpdateTradePacket = 'UpdateTradePacket',
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @example simpleHttpRequest.ts
|
|
288
|
+
* ```typescript
|
|
289
|
+
* import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
|
|
290
|
+
*
|
|
291
|
+
* async function updateScore() {
|
|
292
|
+
* const req = new HttpRequest('http://localhost:3000/updateScore');
|
|
293
|
+
*
|
|
294
|
+
* req.body = JSON.stringify({
|
|
295
|
+
* score: 22,
|
|
296
|
+
* });
|
|
297
|
+
*
|
|
298
|
+
* req.method = HttpRequestMethod.Post;
|
|
299
|
+
* req.headers = [
|
|
300
|
+
* new HttpHeader('Content-Type', 'application/json'),
|
|
301
|
+
* new HttpHeader('auth', 'my-auth-token'),
|
|
302
|
+
* ];
|
|
303
|
+
*
|
|
304
|
+
* await http.request(req);
|
|
305
|
+
* }
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
export class HttpClient {
|
|
309
|
+
private constructor();
|
|
310
|
+
/**
|
|
311
|
+
* @remarks
|
|
312
|
+
* Cancels all pending requests.
|
|
313
|
+
*
|
|
314
|
+
* This function can be called in early-execution mode.
|
|
315
|
+
*
|
|
316
|
+
*/
|
|
317
|
+
cancelAll(reason: string): void;
|
|
318
|
+
/**
|
|
319
|
+
* @remarks
|
|
320
|
+
* Performs a simple HTTP get request.
|
|
321
|
+
*
|
|
322
|
+
* This function can be called in early-execution mode.
|
|
323
|
+
*
|
|
324
|
+
* @param uri
|
|
325
|
+
* URL to make an HTTP Request to.
|
|
326
|
+
* @returns
|
|
327
|
+
* An awaitable promise that contains the HTTP response.
|
|
328
|
+
*/
|
|
329
|
+
get(uri: string): Promise<HttpResponse>;
|
|
330
|
+
/**
|
|
331
|
+
* @remarks
|
|
332
|
+
* Performs an HTTP request.
|
|
333
|
+
*
|
|
334
|
+
* This function can be called in early-execution mode.
|
|
335
|
+
*
|
|
336
|
+
* @param config
|
|
337
|
+
* Contains an HTTP Request object with configuration data on
|
|
338
|
+
* the HTTP request.
|
|
339
|
+
* @returns
|
|
340
|
+
* An awaitable promise that contains the HTTP response.
|
|
341
|
+
* @example simpleHttpRequest.ts
|
|
342
|
+
* ```typescript
|
|
343
|
+
* import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
|
|
344
|
+
*
|
|
345
|
+
* async function updateScore() {
|
|
346
|
+
* const req = new HttpRequest('http://localhost:3000/updateScore');
|
|
347
|
+
*
|
|
348
|
+
* req.body = JSON.stringify({
|
|
349
|
+
* score: 22,
|
|
350
|
+
* });
|
|
351
|
+
*
|
|
352
|
+
* req.method = HttpRequestMethod.Post;
|
|
353
|
+
* req.headers = [
|
|
354
|
+
* new HttpHeader('Content-Type', 'application/json'),
|
|
355
|
+
* new HttpHeader('auth', 'my-auth-token'),
|
|
356
|
+
* ];
|
|
357
|
+
*
|
|
358
|
+
* await http.request(req);
|
|
359
|
+
* }
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
request(config: HttpRequest): Promise<HttpResponse>;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Represents an HTTP header - a key/value pair of
|
|
367
|
+
* meta-information about a request.
|
|
368
|
+
* @example simpleHttpRequest.ts
|
|
369
|
+
* ```typescript
|
|
370
|
+
* import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
|
|
371
|
+
*
|
|
372
|
+
* async function updateScore() {
|
|
373
|
+
* const req = new HttpRequest('http://localhost:3000/updateScore');
|
|
374
|
+
*
|
|
375
|
+
* req.body = JSON.stringify({
|
|
376
|
+
* score: 22,
|
|
377
|
+
* });
|
|
378
|
+
*
|
|
379
|
+
* req.method = HttpRequestMethod.Post;
|
|
380
|
+
* req.headers = [
|
|
381
|
+
* new HttpHeader('Content-Type', 'application/json'),
|
|
382
|
+
* new HttpHeader('auth', 'my-auth-token'),
|
|
383
|
+
* ];
|
|
384
|
+
*
|
|
385
|
+
* await http.request(req);
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
export class HttpHeader {
|
|
390
|
+
/**
|
|
391
|
+
* @remarks
|
|
392
|
+
* Key of the HTTP header.
|
|
393
|
+
*
|
|
394
|
+
* This property can be edited in early-execution mode.
|
|
395
|
+
*
|
|
396
|
+
*/
|
|
397
|
+
key: string;
|
|
398
|
+
/**
|
|
399
|
+
* @remarks
|
|
400
|
+
* Value of the HTTP header.
|
|
401
|
+
*
|
|
402
|
+
* This property can be edited in early-execution mode.
|
|
403
|
+
*
|
|
404
|
+
*/
|
|
405
|
+
value: minecraftserveradmin.SecretString | string;
|
|
406
|
+
constructor(key: string, value: minecraftserveradmin.SecretString | string);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Main object for structuring a request.
|
|
411
|
+
* @example simpleHttpRequest.ts
|
|
412
|
+
* ```typescript
|
|
413
|
+
* import { HttpRequest, HttpHeader, HttpRequestMethod, http } from '@minecraft/server-net';
|
|
414
|
+
*
|
|
415
|
+
* async function updateScore() {
|
|
416
|
+
* const req = new HttpRequest('http://localhost:3000/updateScore');
|
|
417
|
+
*
|
|
418
|
+
* req.body = JSON.stringify({
|
|
419
|
+
* score: 22,
|
|
420
|
+
* });
|
|
421
|
+
*
|
|
422
|
+
* req.method = HttpRequestMethod.Post;
|
|
423
|
+
* req.headers = [
|
|
424
|
+
* new HttpHeader('Content-Type', 'application/json'),
|
|
425
|
+
* new HttpHeader('auth', 'my-auth-token'),
|
|
426
|
+
* ];
|
|
427
|
+
*
|
|
428
|
+
* await http.request(req);
|
|
429
|
+
* }
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
export class HttpRequest {
|
|
433
|
+
/**
|
|
434
|
+
* @remarks
|
|
435
|
+
* Content of the body of the HTTP request.
|
|
436
|
+
*
|
|
437
|
+
* This property can be edited in early-execution mode.
|
|
438
|
+
*
|
|
439
|
+
*/
|
|
440
|
+
body: string;
|
|
441
|
+
/**
|
|
442
|
+
* @remarks
|
|
443
|
+
* A collection of HTTP headers to add to the outbound request.
|
|
444
|
+
*
|
|
445
|
+
* This property can be edited in early-execution mode.
|
|
446
|
+
*
|
|
447
|
+
*/
|
|
448
|
+
headers: HttpHeader[];
|
|
449
|
+
/**
|
|
450
|
+
* @remarks
|
|
451
|
+
* HTTP method (e.g., GET or PUT or PATCH) to use for making
|
|
452
|
+
* the request.
|
|
453
|
+
*
|
|
454
|
+
* This property can be edited in early-execution mode.
|
|
455
|
+
*
|
|
456
|
+
*/
|
|
457
|
+
method: HttpRequestMethod;
|
|
458
|
+
/**
|
|
459
|
+
* @remarks
|
|
460
|
+
* Amount of time, in seconds, before the request times out and
|
|
461
|
+
* is abandoned.
|
|
462
|
+
*
|
|
463
|
+
* This property can be edited in early-execution mode.
|
|
464
|
+
*
|
|
465
|
+
*/
|
|
466
|
+
timeout: number;
|
|
467
|
+
/**
|
|
468
|
+
* @remarks
|
|
469
|
+
* The HTTP resource to access.
|
|
470
|
+
*
|
|
471
|
+
* This property can be edited in early-execution mode.
|
|
472
|
+
*
|
|
473
|
+
*/
|
|
474
|
+
uri: string;
|
|
475
|
+
constructor(uri: string);
|
|
476
|
+
/**
|
|
477
|
+
* @remarks
|
|
478
|
+
* Adds an additional header to the overall list of headers
|
|
479
|
+
* used in the corresponding HTTP request.
|
|
480
|
+
*
|
|
481
|
+
* This function can be called in early-execution mode.
|
|
482
|
+
*
|
|
483
|
+
*/
|
|
484
|
+
addHeader(key: string, value: minecraftserveradmin.SecretString | string): HttpRequest;
|
|
485
|
+
/**
|
|
486
|
+
* @remarks
|
|
487
|
+
* Updates the content of the body of the HTTP request.
|
|
488
|
+
*
|
|
489
|
+
* This function can be called in early-execution mode.
|
|
490
|
+
*
|
|
491
|
+
*/
|
|
492
|
+
setBody(body: string): HttpRequest;
|
|
493
|
+
/**
|
|
494
|
+
* @remarks
|
|
495
|
+
* Replaces and applies a set of HTTP Headers for the request.
|
|
496
|
+
*
|
|
497
|
+
* This function can be called in early-execution mode.
|
|
498
|
+
*
|
|
499
|
+
*/
|
|
500
|
+
setHeaders(headers: HttpHeader[]): HttpRequest;
|
|
501
|
+
/**
|
|
502
|
+
* @remarks
|
|
503
|
+
* Sets the desired HTTP method (e.g., GET or PUT or PATCH) to
|
|
504
|
+
* use for making the request.
|
|
505
|
+
*
|
|
506
|
+
* This function can be called in early-execution mode.
|
|
507
|
+
*
|
|
508
|
+
*/
|
|
509
|
+
setMethod(method: HttpRequestMethod): HttpRequest;
|
|
510
|
+
/**
|
|
511
|
+
* @remarks
|
|
512
|
+
* This function can be called in early-execution mode.
|
|
513
|
+
*
|
|
514
|
+
*/
|
|
515
|
+
setTimeout(timeout: number): HttpRequest;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Main object that contains result information from a request.
|
|
520
|
+
*/
|
|
521
|
+
export class HttpResponse {
|
|
522
|
+
private constructor();
|
|
523
|
+
/**
|
|
524
|
+
* @remarks
|
|
525
|
+
* Body content of the HTTP response.
|
|
526
|
+
*
|
|
527
|
+
*/
|
|
528
|
+
readonly body: string;
|
|
529
|
+
/**
|
|
530
|
+
* @remarks
|
|
531
|
+
* A collection of HTTP response headers returned from the
|
|
532
|
+
* request.
|
|
533
|
+
*
|
|
534
|
+
*/
|
|
535
|
+
readonly headers: HttpHeader[];
|
|
536
|
+
/**
|
|
537
|
+
* @remarks
|
|
538
|
+
* Information that was used to formulate the HTTP response
|
|
539
|
+
* that this object represents.
|
|
540
|
+
*
|
|
541
|
+
*/
|
|
542
|
+
readonly request: HttpRequest;
|
|
543
|
+
/**
|
|
544
|
+
* @remarks
|
|
545
|
+
* HTTP response code for the request. For example, 404
|
|
546
|
+
* represents resource not found, and 500 represents an
|
|
547
|
+
* internal server error.
|
|
548
|
+
*
|
|
549
|
+
*/
|
|
550
|
+
readonly status: number;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export class NetworkBeforeEvents {
|
|
554
|
+
private constructor();
|
|
555
|
+
/**
|
|
556
|
+
* @remarks
|
|
557
|
+
* This property can be read in early-execution mode.
|
|
558
|
+
*
|
|
559
|
+
*/
|
|
560
|
+
readonly packetReceive: PacketReceiveBeforeEventSignal;
|
|
561
|
+
/**
|
|
562
|
+
* @remarks
|
|
563
|
+
* This property can be read in early-execution mode.
|
|
564
|
+
*
|
|
565
|
+
*/
|
|
566
|
+
readonly packetSend: PacketSendBeforeEventSignal;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
export class PacketReceiveBeforeEventSignal {
|
|
570
|
+
private constructor();
|
|
571
|
+
/**
|
|
572
|
+
* @remarks
|
|
573
|
+
* This function can't be called in read-only mode.
|
|
574
|
+
*
|
|
575
|
+
* This function can be called in early-execution mode.
|
|
576
|
+
*
|
|
577
|
+
*/
|
|
578
|
+
subscribe(
|
|
579
|
+
callback: (arg0: PacketReceivedBeforeEvent) => void,
|
|
580
|
+
options?: PacketEventOptions,
|
|
581
|
+
): (arg0: PacketReceivedBeforeEvent) => void;
|
|
582
|
+
/**
|
|
583
|
+
* @remarks
|
|
584
|
+
* This function can't be called in read-only mode.
|
|
585
|
+
*
|
|
586
|
+
* This function can be called in early-execution mode.
|
|
587
|
+
*
|
|
588
|
+
*/
|
|
589
|
+
unsubscribe(callback: (arg0: PacketReceivedBeforeEvent) => void): void;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Sent as the server receives a network packet from a client.
|
|
594
|
+
* If cancelled, the server will not parse the network packet
|
|
595
|
+
* and will silently ignore it.
|
|
596
|
+
*/
|
|
597
|
+
export class PacketReceivedBeforeEvent {
|
|
598
|
+
private constructor();
|
|
599
|
+
cancel: boolean;
|
|
600
|
+
/**
|
|
601
|
+
* @remarks
|
|
602
|
+
* The type of network packet.
|
|
603
|
+
*
|
|
604
|
+
*/
|
|
605
|
+
readonly packetId: PacketId;
|
|
606
|
+
/**
|
|
607
|
+
* @remarks
|
|
608
|
+
* The size of the network packet in bytes.
|
|
609
|
+
*
|
|
610
|
+
*/
|
|
611
|
+
readonly packetSize: number;
|
|
612
|
+
/**
|
|
613
|
+
* @remarks
|
|
614
|
+
* Which client sent the network packet to the game server.
|
|
615
|
+
*
|
|
616
|
+
*/
|
|
617
|
+
readonly sender?: minecraftserver.Player;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Sent as the server sends a network packet to clients. If
|
|
622
|
+
* cancelled, the server will not send the network packet to
|
|
623
|
+
* the receiving clients.
|
|
624
|
+
*/
|
|
625
|
+
export class PacketSendBeforeEvent {
|
|
626
|
+
private constructor();
|
|
627
|
+
cancel: boolean;
|
|
628
|
+
/**
|
|
629
|
+
* @remarks
|
|
630
|
+
* The type of network packet.
|
|
631
|
+
*
|
|
632
|
+
*/
|
|
633
|
+
readonly packetId: PacketId;
|
|
634
|
+
/**
|
|
635
|
+
* @remarks
|
|
636
|
+
* Which clients the network packet is being sent to.
|
|
637
|
+
*
|
|
638
|
+
*/
|
|
639
|
+
readonly recipients: (minecraftserver.Player | undefined)[];
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
export class PacketSendBeforeEventSignal {
|
|
643
|
+
private constructor();
|
|
644
|
+
/**
|
|
645
|
+
* @remarks
|
|
646
|
+
* This function can't be called in read-only mode.
|
|
647
|
+
*
|
|
648
|
+
* This function can be called in early-execution mode.
|
|
649
|
+
*
|
|
650
|
+
*/
|
|
651
|
+
subscribe(
|
|
652
|
+
callback: (arg0: PacketSendBeforeEvent) => void,
|
|
653
|
+
options?: PacketEventOptions,
|
|
654
|
+
): (arg0: PacketSendBeforeEvent) => void;
|
|
655
|
+
/**
|
|
656
|
+
* @remarks
|
|
657
|
+
* This function can't be called in read-only mode.
|
|
658
|
+
*
|
|
659
|
+
* This function can be called in early-execution mode.
|
|
660
|
+
*
|
|
661
|
+
*/
|
|
662
|
+
unsubscribe(callback: (arg0: PacketSendBeforeEvent) => void): void;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Options for events triggered by network packets.
|
|
667
|
+
*/
|
|
668
|
+
export interface PacketEventOptions {
|
|
669
|
+
/**
|
|
670
|
+
* @remarks
|
|
671
|
+
* If provided, packet IDs in this list will not trigger the
|
|
672
|
+
* event subscriptions.
|
|
673
|
+
*
|
|
674
|
+
*/
|
|
675
|
+
ignoredPacketIds?: PacketId[];
|
|
676
|
+
/**
|
|
677
|
+
* @remarks
|
|
678
|
+
* If provided only packet IDs in this list will trigger the
|
|
679
|
+
* event subscriptions.
|
|
680
|
+
*
|
|
681
|
+
*/
|
|
682
|
+
monitoredPacketIds?: PacketId[];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* An error thrown when a platform-level HTTP error occurs.
|
|
687
|
+
* Information provided in this class may be useful for
|
|
688
|
+
* diagnostics purposes but will differ from platform to
|
|
689
|
+
* platform.
|
|
690
|
+
*/
|
|
691
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
692
|
+
export class InternalHttpRequestError extends Error {
|
|
693
|
+
private constructor();
|
|
694
|
+
/**
|
|
695
|
+
* @remarks
|
|
696
|
+
* The platform-provided numeric error code for the error.
|
|
697
|
+
*
|
|
698
|
+
* This property can be read in early-execution mode.
|
|
699
|
+
*
|
|
700
|
+
*/
|
|
701
|
+
code: number;
|
|
702
|
+
/**
|
|
703
|
+
* @remarks
|
|
704
|
+
* The platform-provided message for the error.
|
|
705
|
+
*
|
|
706
|
+
* This property can be read in early-execution mode.
|
|
707
|
+
*
|
|
708
|
+
*/
|
|
709
|
+
message: string;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* An error thrown when a malformed HTTP request is attempted
|
|
714
|
+
* to be sent.
|
|
715
|
+
*/
|
|
716
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
717
|
+
export class MalformedHttpRequestError extends Error {
|
|
718
|
+
private constructor();
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
export const beforeEvents: NetworkBeforeEvents;
|
|
722
|
+
export const http: HttpClient;
|
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@minecraft/server-net",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "",
|
|
5
|
-
"contributors": [
|
|
6
|
-
{
|
|
7
|
-
"name": "Jake Shirley",
|
|
8
|
-
"email": "jake@xbox.com"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "Mike Ammerlaan",
|
|
12
|
-
"email": "mikeam@microsoft.com"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"
|
|
16
|
-
"@minecraft/
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@minecraft/server-net",
|
|
3
|
+
"version": "1.0.0-beta.1.12.111-stable",
|
|
4
|
+
"description": "",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Jake Shirley",
|
|
8
|
+
"email": "jake@xbox.com"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Mike Ammerlaan",
|
|
12
|
+
"email": "mikeam@microsoft.com"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@minecraft/common": "^1.0.0",
|
|
17
|
+
"@minecraft/server": "^1.17.0 || ^2.0.0",
|
|
18
|
+
"@minecraft/server-admin": "^1.0.0-beta.1.12.111-stable"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT"
|
|
19
21
|
}
|
package/.eslintrc.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es2021": true
|
|
5
|
-
},
|
|
6
|
-
"extends": [
|
|
7
|
-
"eslint:recommended",
|
|
8
|
-
"plugin:@typescript-eslint/recommended"
|
|
9
|
-
],
|
|
10
|
-
"overrides": [
|
|
11
|
-
],
|
|
12
|
-
"parser": "@typescript-eslint/parser",
|
|
13
|
-
"parserOptions": {
|
|
14
|
-
"ecmaVersion": "latest",
|
|
15
|
-
"sourceType": "module"
|
|
16
|
-
},
|
|
17
|
-
"plugins": [
|
|
18
|
-
"@typescript-eslint"
|
|
19
|
-
],
|
|
20
|
-
"rules": {
|
|
21
|
-
"@typescript-eslint/no-explicit-any": "off"
|
|
22
|
-
}
|
|
23
|
-
}
|
package/tests.ts
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import * as mc from '@minecraft/server';
|
|
2
|
-
import * as mcnet from '@minecraft/server-net';
|
|
3
|
-
|
|
4
|
-
export async function updateScore() {
|
|
5
|
-
const req = new mcnet.HttpRequest('http://localhost:3000/updateScore');
|
|
6
|
-
|
|
7
|
-
req.body = JSON.stringify({
|
|
8
|
-
score: 22,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
req.method = mcnet.HttpRequestMethod.POST;
|
|
12
|
-
req.headers = [
|
|
13
|
-
new mcnet.HttpHeader('Content-Type', 'application/json'),
|
|
14
|
-
new mcnet.HttpHeader('auth', 'my-auth-token'),
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
await mcnet.http.request(req);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default class SampleManager {
|
|
21
|
-
tickCount = 0;
|
|
22
|
-
|
|
23
|
-
_availableFuncs: {
|
|
24
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
pendingFuncs: Array<{
|
|
28
|
-
name: string;
|
|
29
|
-
func: (log: (message: string, status?: number) => void, location: mc.Location) => void;
|
|
30
|
-
location: mc.Location;
|
|
31
|
-
}> = [];
|
|
32
|
-
|
|
33
|
-
gameplayLogger(message: string, status?: number) {
|
|
34
|
-
if (status !== undefined && status > 0) {
|
|
35
|
-
message = 'SUCCESS: ' + message;
|
|
36
|
-
} else if (status !== undefined && status < 0) {
|
|
37
|
-
message = 'FAIL: ' + message;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.say(message);
|
|
41
|
-
}
|
|
42
|
-
say(message: string) {
|
|
43
|
-
mc.world.getDimension('overworld').runCommand('say ' + message);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
newChatMessage(chatEvent: mc.ChatEvent) {
|
|
47
|
-
const message = chatEvent.message.toLowerCase();
|
|
48
|
-
|
|
49
|
-
if (message.startsWith('howto') && chatEvent.sender) {
|
|
50
|
-
const nearbyBlock = chatEvent.sender.getBlockFromViewVector();
|
|
51
|
-
if (!nearbyBlock) {
|
|
52
|
-
this.gameplayLogger('Please look at the block where you want me to run this.');
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const nearbyBlockLoc = nearbyBlock.location;
|
|
57
|
-
const nearbyLoc = new mc.Location(nearbyBlockLoc.x, nearbyBlockLoc.y + 1, nearbyBlockLoc.z);
|
|
58
|
-
|
|
59
|
-
const sampleId = message.substring(5).trim();
|
|
60
|
-
|
|
61
|
-
if (sampleId.length < 2) {
|
|
62
|
-
let availableFuncStr = 'Here is my list of available samples:';
|
|
63
|
-
|
|
64
|
-
for (const sampleFuncKey in this._availableFuncs) {
|
|
65
|
-
availableFuncStr += ' ' + sampleFuncKey;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
this.say(availableFuncStr);
|
|
69
|
-
} else {
|
|
70
|
-
for (const sampleFuncKey in this._availableFuncs) {
|
|
71
|
-
if (sampleFuncKey.toLowerCase() === sampleId) {
|
|
72
|
-
const sampleFunc = this._availableFuncs[sampleFuncKey];
|
|
73
|
-
|
|
74
|
-
this.runSample(sampleFuncKey + this.tickCount, sampleFunc, nearbyLoc);
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
this.say(`I couldn't find the sample '${sampleId}"'`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
runSample(
|
|
86
|
-
sampleId: string,
|
|
87
|
-
snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>,
|
|
88
|
-
targetLocation: mc.Location,
|
|
89
|
-
) {
|
|
90
|
-
for (let i = snippetFunctions.length - 1; i >= 0; i--) {
|
|
91
|
-
this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation });
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
worldTick() {
|
|
96
|
-
if (this.tickCount % 10 === 0) {
|
|
97
|
-
if (this.pendingFuncs.length > 0) {
|
|
98
|
-
const funcSet = this.pendingFuncs.pop();
|
|
99
|
-
|
|
100
|
-
if (funcSet) {
|
|
101
|
-
funcSet.func(this.gameplayLogger, funcSet.location);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this.tickCount++;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
constructor() {
|
|
110
|
-
this._availableFuncs = {};
|
|
111
|
-
|
|
112
|
-
this.gameplayLogger = this.gameplayLogger.bind(this);
|
|
113
|
-
|
|
114
|
-
mc.world.events.tick.subscribe(this.worldTick.bind(this));
|
|
115
|
-
mc.world.events.chat.subscribe(this.newChatMessage.bind(this));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
registerSamples(sampleSet: {
|
|
119
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Location) => void>;
|
|
120
|
-
}) {
|
|
121
|
-
for (const sampleKey in sampleSet) {
|
|
122
|
-
if (sampleKey.length > 1 && sampleSet[sampleKey]) {
|
|
123
|
-
this._availableFuncs[sampleKey] = sampleSet[sampleKey];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "commonjs",
|
|
4
|
-
"lib": ["es6"],
|
|
5
|
-
"target": "es6",
|
|
6
|
-
"forceConsistentCasingInFileNames": true,
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
"noImplicitAny": true,
|
|
9
|
-
"noImplicitThis": true,
|
|
10
|
-
"strictFunctionTypes": true,
|
|
11
|
-
"strictNullChecks": true,
|
|
12
|
-
"baseUrl": "../",
|
|
13
|
-
"typeRoots": ["../"],
|
|
14
|
-
"types": []
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"index.d.ts",
|
|
18
|
-
"tests.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|