@hotbunny/hackhub-content-sdk 0.1.0 → 0.1.1
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 -120
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,43 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Type definitions and API reference for creating HackHub mods.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Quick Start
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The easiest way to create a new mod is with the interactive CLI:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm
|
|
10
|
+
npm create hackhub-mod
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
This will scaffold a ready-to-go project with templates, build config, and everything set up.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Manual Installation
|
|
16
16
|
|
|
17
|
+
```bash
|
|
18
|
+
npm install @hotbunny/hackhub-content-sdk --save-dev
|
|
17
19
|
```
|
|
18
|
-
mods/
|
|
19
|
-
my-first-mod/
|
|
20
|
-
manifest.json
|
|
21
|
-
mod.js
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### manifest.json
|
|
25
|
-
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"id": "my-first-mod",
|
|
29
|
-
"name": "My First Mod",
|
|
30
|
-
"version": "1.0.0",
|
|
31
|
-
"author": "YourName",
|
|
32
|
-
"description": "A simple HackHub mod",
|
|
33
|
-
"entry": "mod.js",
|
|
34
|
-
"permissions": ["network", "files", "events"],
|
|
35
|
-
"dependencies": []
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### Source Code (TypeScript)
|
|
40
20
|
|
|
41
|
-
|
|
21
|
+
## Example
|
|
42
22
|
|
|
43
23
|
```typescript
|
|
44
24
|
import {
|
|
@@ -134,119 +114,28 @@ class MyQuest extends Quest {
|
|
|
134
114
|
### Listening to Game Events
|
|
135
115
|
|
|
136
116
|
```typescript
|
|
137
|
-
import { Events } from "@hotbunny/hackhub-content-sdk";
|
|
138
|
-
|
|
139
117
|
Events.on("Terminal.NmapScan", (data) => {
|
|
140
118
|
console.log(`Player scanned ${data.ip}`);
|
|
141
119
|
});
|
|
142
|
-
|
|
143
|
-
Events.on("Kisscord.Messaging", (data) => {
|
|
144
|
-
console.log(`Message on channel ${data.channel}`);
|
|
145
|
-
});
|
|
146
120
|
```
|
|
147
121
|
|
|
148
122
|
### Custom Cross-Mod Events
|
|
149
123
|
|
|
150
|
-
Register and emit your own typed events that other mods can listen to:
|
|
151
|
-
|
|
152
124
|
```typescript
|
|
153
|
-
// In your mod's type declarations
|
|
154
125
|
declare module "@hotbunny/hackhub-content-sdk" {
|
|
155
126
|
interface ModEventMap {
|
|
156
127
|
"MyMod.BossDefeated": { bossName: string; reward: number };
|
|
157
128
|
}
|
|
158
129
|
}
|
|
159
130
|
|
|
160
|
-
// Emit
|
|
161
131
|
Events.register("MyMod.BossDefeated");
|
|
162
132
|
Events.emit("MyMod.BossDefeated", { bossName: "Hydra", reward: 500 });
|
|
163
133
|
|
|
164
|
-
// Another mod can listen (with full type safety)
|
|
165
134
|
Events.on("MyMod.BossDefeated", (data) => {
|
|
166
|
-
console.log(`Boss ${data.bossName} defeated
|
|
167
|
-
});
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
## Messaging APIs
|
|
171
|
-
|
|
172
|
-
### Twotter (in-game Twitter)
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
import { Twotter } from "@hotbunny/hackhub-content-sdk";
|
|
176
|
-
|
|
177
|
-
const user = Twotter.createUser({
|
|
178
|
-
username: "darknet_hacker",
|
|
179
|
-
bio: "I hack things.",
|
|
180
|
-
verified: true,
|
|
181
|
-
});
|
|
182
|
-
Twotter.addUser(user);
|
|
183
|
-
|
|
184
|
-
Twotter.postTweet({
|
|
185
|
-
id: "my-tweet-1",
|
|
186
|
-
userId: user.id,
|
|
187
|
-
content: "Just breached the mainframe!",
|
|
188
|
-
interaction: { comments: 5, share: 2, likes: 42, views: 1000 },
|
|
189
|
-
showInTimeline: true,
|
|
135
|
+
console.log(`Boss ${data.bossName} defeated!`);
|
|
190
136
|
});
|
|
191
137
|
```
|
|
192
138
|
|
|
193
|
-
### Kisscord (in-game Discord)
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
import { Kisscord, KisscordStatus } from "@hotbunny/hackhub-content-sdk";
|
|
197
|
-
|
|
198
|
-
const npc = Kisscord.createUser({
|
|
199
|
-
username: "informant",
|
|
200
|
-
firstName: "John",
|
|
201
|
-
lastName: "Doe",
|
|
202
|
-
isFriend: true,
|
|
203
|
-
status: KisscordStatus.Online,
|
|
204
|
-
});
|
|
205
|
-
Kisscord.addUser(npc);
|
|
206
|
-
Kisscord.sendMessage(npc.id, "I have the files you need.");
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### WeeChat (in-game IRC)
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
import { WeeChat } from "@hotbunny/hackhub-content-sdk";
|
|
213
|
-
|
|
214
|
-
WeeChat.createServer("irc.darknet.org", "secret123");
|
|
215
|
-
WeeChat.sendMessage({
|
|
216
|
-
host: "irc.darknet.org",
|
|
217
|
-
username: "informant",
|
|
218
|
-
message: "The target IP is 45.33.32.156",
|
|
219
|
-
});
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## Building Your Mod
|
|
223
|
-
|
|
224
|
-
Use [esbuild](https://esbuild.github.io/) to compile your TypeScript source into a single `mod.js`:
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
npx esbuild src/index.ts --bundle --outfile=mod.js --format=cjs --platform=browser --target=es2020 --external:@hotbunny/hackhub-content-sdk
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
The `--external` flag is important: the game provides the SDK at runtime, so it must not be bundled into your mod.
|
|
231
|
-
|
|
232
|
-
### tsconfig.json (recommended)
|
|
233
|
-
|
|
234
|
-
```json
|
|
235
|
-
{
|
|
236
|
-
"compilerOptions": {
|
|
237
|
-
"target": "ES2020",
|
|
238
|
-
"module": "ESNext",
|
|
239
|
-
"moduleResolution": "bundler",
|
|
240
|
-
"strict": true,
|
|
241
|
-
"experimentalDecorators": true,
|
|
242
|
-
"emitDecoratorMetadata": true,
|
|
243
|
-
"esModuleInterop": true,
|
|
244
|
-
"skipLibCheck": true
|
|
245
|
-
},
|
|
246
|
-
"include": ["src/**/*.ts"]
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
139
|
## License
|
|
251
140
|
|
|
252
141
|
MIT
|