create-yeow 0.1.7 → 0.1.8
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
CHANGED
|
Binary file
|
|
@@ -9,24 +9,25 @@ const cfg = JSON.parse(readFileSync(resolve(root, 'yeow.config.json'), 'utf-8'))
|
|
|
9
9
|
const { name, version } = cfg;
|
|
10
10
|
const entry = existsSync(resolve(root, 'src', 'index.ts')) ? 'src/index.ts' : 'src/index.js';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
const outDir = resolve(root, 'dist', '.yeow');
|
|
13
|
+
mkdirSync(outDir, { recursive: true });
|
|
14
|
+
|
|
15
|
+
esbuild.build({
|
|
16
|
+
entryPoints: [resolve(root, entry)],
|
|
17
|
+
outfile: resolve(outDir, 'main.js'),
|
|
18
|
+
bundle: true,
|
|
19
|
+
format: 'iife',
|
|
20
|
+
target: 'es2023',
|
|
21
|
+
platform: 'neutral',
|
|
22
|
+
mainFields: ['module', 'main'],
|
|
23
|
+
conditions: ['import', 'browser'],
|
|
24
|
+
treeShaking: true,
|
|
25
|
+
minify: false,
|
|
26
|
+
}).then(() => {
|
|
24
27
|
const size = statSync(resolve(outDir, 'main.js')).size;
|
|
25
|
-
console.log(` ✓ Bundled (${(size/1024).toFixed(1)} KB)`);
|
|
28
|
+
console.log(` ✓ Bundled (${(size / 1024).toFixed(1)} KB)`);
|
|
26
29
|
|
|
27
30
|
const tmplJar = resolve(root, '.yeow', 'assets', 'yeow-template-0.1.0.jar');
|
|
28
|
-
if (!existsSync(tmplJar)) { console.error(' ✗ Template JAR not found'); process.exit(1); }
|
|
29
|
-
|
|
30
31
|
const zip = new AdmZip(tmplJar);
|
|
31
32
|
zip.updateFile('plugin.yml', Buffer.from(`name: ${name}\nversion: ${version}\nmain: yeow.template.Bootstrap\napi-version: '1.21'\ndepend:\n - Yeow-Runtime\n`));
|
|
32
33
|
zip.addFile('.yeow/main.js', readFileSync(resolve(outDir, 'main.js')));
|
|
@@ -34,6 +35,4 @@ async function build() {
|
|
|
34
35
|
const outJar = resolve(root, 'dist', `${name}-${version}.jar`);
|
|
35
36
|
zip.writeZip(outJar);
|
|
36
37
|
console.log(` ✓ Packaged ${outJar}\n`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
build().catch(e => { console.error(e); process.exit(1); });
|
|
38
|
+
}).catch(e => { console.error(e); process.exit(1); });
|
|
@@ -1,32 +1,16 @@
|
|
|
1
|
-
import { Player,
|
|
1
|
+
import { Player, registerCommand, broadcastSync } from 'yeow-api';
|
|
2
2
|
|
|
3
|
-
// ── Commands ────────────────────────
|
|
4
3
|
registerCommand('hello', {
|
|
5
4
|
description: 'Say hello',
|
|
6
5
|
executor: (p) => p.sender.sendMessage(`Hello, ${p.args[0] || 'World'}!`),
|
|
7
6
|
});
|
|
8
7
|
|
|
9
8
|
registerCommand('ping', {
|
|
10
|
-
description: 'Check
|
|
9
|
+
description: 'Check ping',
|
|
11
10
|
executor: (p) => {
|
|
12
11
|
const player = Player.get(p.sender.uuid);
|
|
13
12
|
if (player) p.sender.sendMessage(`Ping: ${player.ping}ms`);
|
|
14
13
|
},
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
eventOn('playerJoin', (e) => {
|
|
19
|
-
const player = Player.get(e.player);
|
|
20
|
-
if (player) player.sendMessageSync(`Welcome, ${player.displayName}!`);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
eventOn('blockBreak', (e) => {
|
|
24
|
-
if (e.block === 'minecraft:bedrock') e.cancelled = true;
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
// ── Startup ─────────────────────────
|
|
28
|
-
const world = World.get('world');
|
|
29
|
-
if (world) {
|
|
30
|
-
console.log(`[init] World: ${world.name} | Time: ${world.time} | Difficulty: ${world.difficulty}`);
|
|
31
|
-
console.log(`[init] Plugin ready`);
|
|
32
|
-
}
|
|
16
|
+
console.log('[init] Plugin loaded successfully');
|