This commit is contained in:
ChomeNS 2022-08-19 08:39:59 +07:00
parent 5ac0112cc7
commit e6ecfcc7eb
4 changed files with 17 additions and 2 deletions

View file

@ -4,7 +4,7 @@
"cbot ",
"/cbot "
],
"useChat": false,
"useChat": true,
"core": {
"layers": 1
},

View file

@ -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) {

View file

@ -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();

View 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};