specprotocol 1.0.0 → 1.2.0
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 +1 -5
- package/bin/specprotocol.js +0 -136
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specprotocol",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A Minecraft bot framework built from scratch in TypeScript — Mineflayer alternative with full protocol support for Java Edition 1.21.4",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"specprotocol": "./bin/specprotocol.js"
|
|
8
|
-
},
|
|
9
6
|
"types": "dist/index.d.ts",
|
|
10
7
|
"type": "commonjs",
|
|
11
8
|
"scripts": {
|
|
@@ -47,7 +44,6 @@
|
|
|
47
44
|
},
|
|
48
45
|
"files": [
|
|
49
46
|
"dist/",
|
|
50
|
-
"bin/",
|
|
51
47
|
"docs/",
|
|
52
48
|
"README.md",
|
|
53
49
|
"LICENSE"
|
package/bin/specprotocol.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* SpecProtocol CLI — Start a bot directly from the terminal.
|
|
5
|
-
*
|
|
6
|
-
* After `npm install specprotocol`, just run:
|
|
7
|
-
* specprotocol
|
|
8
|
-
*
|
|
9
|
-
* Or with arguments:
|
|
10
|
-
* specprotocol --host localhost --port 25565 --username MyBot
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const { createBot } = require('../dist/index.js');
|
|
14
|
-
const readline = require('readline');
|
|
15
|
-
|
|
16
|
-
const args = process.argv.slice(2);
|
|
17
|
-
|
|
18
|
-
function getArg(name) {
|
|
19
|
-
const idx = args.indexOf(`--${name}`);
|
|
20
|
-
if (idx !== -1 && args[idx + 1]) return args[idx + 1];
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function ask(question) {
|
|
25
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
26
|
-
return new Promise((resolve) => {
|
|
27
|
-
rl.question(question, (answer) => {
|
|
28
|
-
rl.close();
|
|
29
|
-
resolve(answer);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function main() {
|
|
35
|
-
console.log('');
|
|
36
|
-
console.log(' ╔═══════════════════════════════════╗');
|
|
37
|
-
console.log(' ║ 🎮 SpecProtocol v1.0 ║');
|
|
38
|
-
console.log(' ║ Minecraft Bot Framework (1.21.4) ║');
|
|
39
|
-
console.log(' ╚═══════════════════════════════════╝');
|
|
40
|
-
console.log('');
|
|
41
|
-
|
|
42
|
-
// Get config from args or ask interactively
|
|
43
|
-
const host = getArg('host') || await ask(' Sunucu adresi (localhost): ') || 'localhost';
|
|
44
|
-
const port = parseInt(getArg('port') || await ask(' Port (25565): ') || '25565');
|
|
45
|
-
const username = getArg('username') || await ask(' Bot adı (SpecBot): ') || 'SpecBot';
|
|
46
|
-
const auth = getArg('auth') || 'offline';
|
|
47
|
-
|
|
48
|
-
console.log('');
|
|
49
|
-
console.log(` → ${host}:${port} adresine "${username}" olarak bağlanılıyor...`);
|
|
50
|
-
console.log('');
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const bot = await createBot({
|
|
54
|
-
host,
|
|
55
|
-
port,
|
|
56
|
-
username,
|
|
57
|
-
auth,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
bot.on('spawn', () => {
|
|
61
|
-
console.log(` ✅ Dünyada doğuldu! Pozisyon: ${bot.position}`);
|
|
62
|
-
console.log('');
|
|
63
|
-
console.log(' Komutlar:');
|
|
64
|
-
console.log(' say <mesaj> — Chat mesajı gönder');
|
|
65
|
-
console.log(' pos — Pozisyonu göster');
|
|
66
|
-
console.log(' health — Sağlık bilgisi');
|
|
67
|
-
console.log(' quit — Çıkış');
|
|
68
|
-
console.log('');
|
|
69
|
-
startRepl(bot);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
bot.on('chat', (message, isOverlay) => {
|
|
73
|
-
if (!isOverlay) {
|
|
74
|
-
console.log(` 💬 ${message}`);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
bot.on('health', (health, food) => {
|
|
79
|
-
if (health <= 0) console.log(' 💀 Bot öldü!');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
bot.on('kicked', (reason) => {
|
|
83
|
-
console.log(` 🚫 Sunucudan atıldı: ${reason}`);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
bot.on('error', (err) => {
|
|
88
|
-
console.error(` ❌ Hata: ${err.message}`);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
bot.on('end', () => {
|
|
92
|
-
console.log(' 🔌 Bağlantı kesildi');
|
|
93
|
-
process.exit(0);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.error(` ❌ Bağlantı kurulamadı: ${err.message}`);
|
|
98
|
-
process.exit(1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function startRepl(bot) {
|
|
103
|
-
const rl = readline.createInterface({
|
|
104
|
-
input: process.stdin,
|
|
105
|
-
output: process.stdout,
|
|
106
|
-
prompt: ' > ',
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
rl.prompt();
|
|
110
|
-
|
|
111
|
-
rl.on('line', (line) => {
|
|
112
|
-
const input = line.trim();
|
|
113
|
-
|
|
114
|
-
if (input.startsWith('say ')) {
|
|
115
|
-
bot.chat(input.substring(4));
|
|
116
|
-
} else if (input === 'pos') {
|
|
117
|
-
console.log(` 📍 ${bot.position}`);
|
|
118
|
-
} else if (input === 'health') {
|
|
119
|
-
console.log(` ❤️ Can: ${bot.health}/20 | 🍖 Açlık: ${bot.food}/20`);
|
|
120
|
-
} else if (input === 'quit' || input === 'exit') {
|
|
121
|
-
bot.disconnect();
|
|
122
|
-
process.exit(0);
|
|
123
|
-
} else if (input) {
|
|
124
|
-
console.log(' Bilinmeyen komut. Komutlar: say, pos, health, quit');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
rl.prompt();
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
rl.on('close', () => {
|
|
131
|
-
bot.disconnect();
|
|
132
|
-
process.exit(0);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
main();
|