create-yeow 0.2.7 → 0.2.9
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/package.json +2 -3
- package/templates/default/.yeow/assets/yeow-runtime-0.1.0.jar +0 -0
- package/templates/default/.yeow/assets/yeow-template-0.1.0.jar +0 -0
- package/templates/default/.yeow/build.js +13 -1
- package/templates/default/assets/.gitkeep +0 -0
- package/templates/default/package.json +1 -1
- package/templates/default/src/index.ts +9 -16
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as esbuild from 'esbuild';
|
|
2
|
-
import { readFileSync, mkdirSync, existsSync, statSync } from 'fs';
|
|
2
|
+
import { readFileSync, mkdirSync, existsSync, statSync, readdirSync } from 'fs';
|
|
3
3
|
import { resolve } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
import AdmZip from 'adm-zip';
|
|
@@ -33,6 +33,18 @@ esbuild.build({
|
|
|
33
33
|
zip.addFile('.yeow/main.js', readFileSync(resolve(outDir, 'main.js')));
|
|
34
34
|
zip.addFile('yeow.json', Buffer.from(JSON.stringify(cfg)));
|
|
35
35
|
|
|
36
|
+
// Include assets/ directory
|
|
37
|
+
const assetsDir = resolve(root, 'assets');
|
|
38
|
+
if (existsSync(assetsDir)) {
|
|
39
|
+
for (const f of readdirSync(assetsDir, { recursive: true })) {
|
|
40
|
+
const fp = resolve(assetsDir, f);
|
|
41
|
+
if (statSync(fp).isFile()) {
|
|
42
|
+
zip.addFile('assets/' + f, readFileSync(fp));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
console.log(' ✓ Assets included');
|
|
46
|
+
}
|
|
47
|
+
|
|
36
48
|
const outJar = resolve(root, 'dist', `${name}-${version}.jar`);
|
|
37
49
|
zip.writeZip(outJar);
|
|
38
50
|
console.log(` ✓ Packaged ${outJar}\n`);
|
|
File without changes
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Player, registerCommand, eventOn,
|
|
1
|
+
import { Player, registerCommand, broadcast, eventOn, onInit, onLoad } from 'yeow-api';
|
|
2
|
+
import type { PlayerJoinEvent, BlockBreakEvent } from 'yeow-api';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
onInit(() => {
|
|
4
5
|
console.log('[init] Plugin loaded');
|
|
5
|
-
}
|
|
6
|
+
});
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
onLoad(() => {
|
|
8
9
|
console.log('[load] Ready');
|
|
9
|
-
}
|
|
10
|
+
});
|
|
10
11
|
|
|
11
12
|
registerCommand('hello', {
|
|
12
13
|
description: 'Say hello',
|
|
@@ -21,19 +22,11 @@ registerCommand('ping', {
|
|
|
21
22
|
},
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
executor: (p) => {
|
|
27
|
-
const t = call('world.getTime', { world: 'world' });
|
|
28
|
-
p.sender.sendMessage(`<aqua>Time: ${t}</aqua>`);
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
eventOn('playerJoin', (e) => {
|
|
33
|
-
console.log(`Player joined: ${e.player}`);
|
|
25
|
+
eventOn('playerJoin', (e: PlayerJoinEvent) => {
|
|
26
|
+
console.log(`Player joined: ${e.player.name}`);
|
|
34
27
|
broadcast(e.joinMessage);
|
|
35
28
|
});
|
|
36
29
|
|
|
37
|
-
eventOn('blockBreak', (e) => {
|
|
30
|
+
eventOn('blockBreak', (e: BlockBreakEvent) => {
|
|
38
31
|
if (e.block === 'minecraft:bedrock') e.cancelled = true;
|
|
39
32
|
});
|