mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
a
This commit is contained in:
parent
5ac0112cc7
commit
e6ecfcc7eb
4 changed files with 17 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
|||
"cbot ",
|
||||
"/cbot "
|
||||
],
|
||||
"useChat": false,
|
||||
"useChat": true,
|
||||
"core": {
|
||||
"layers": 1
|
||||
},
|
||||
|
|
4
index.js
4
index.js
|
@ -8,6 +8,7 @@ const mc = require('minecraft-protocol');
|
|||
const crypto = require('crypto');
|
||||
const colorConvert = require('color-convert');
|
||||
const chatMessage = require('prismarine-chat')('1.18.2');
|
||||
const {containsIllegalCharacters} = require('./util/containsIllegalCharacters');
|
||||
const generateEaglerUsername = require('./util/generateEaglerUsername');
|
||||
const {EventEmitter} = require('events');
|
||||
const fs = require('fs');
|
||||
|
@ -155,10 +156,11 @@ function main() {
|
|||
try {
|
||||
if (bot.queue[0]) {
|
||||
try {
|
||||
if (containsIllegalCharacters(bot.queue[0])) return;
|
||||
bot.write('chat', {message: bot.queue[0].substring(0, 256)});
|
||||
bot.queue.shift();
|
||||
} catch (e) {
|
||||
return;
|
||||
console.log(e.message);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
@ -71,6 +71,10 @@ function inject(bot) {
|
|||
if (core.isCore(packet.location) && packet.type===0) fillCore();
|
||||
});
|
||||
|
||||
bot._client.on('multi_block_change', (packet) => {
|
||||
if (core.isCore(packet.chunkCoordinates)) fillCore();
|
||||
});
|
||||
|
||||
bot.on('position', fillCore);
|
||||
|
||||
fillCore();
|
||||
|
|
9
util/containsIllegalCharacters.js
Normal file
9
util/containsIllegalCharacters.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* eslint-disable max-len */
|
||||
function isAllowedCharacter(character) {
|
||||
return character !== '\xa7' && character >= ' ' && character !== '\x7f';
|
||||
}
|
||||
function containsIllegalCharacters(string) {
|
||||
for (let i = 0; i < string.length; i++) if (!isAllowedCharacter(string[i])) return true;
|
||||
}
|
||||
|
||||
module.exports = {containsIllegalCharacters};
|
Loading…
Reference in a new issue