remove proxy + still don't know the cause

This commit is contained in:
ChomeNS 2022-11-17 16:10:10 +07:00
parent d8234b10d5
commit c7606db516
7 changed files with 6 additions and 197 deletions

1
bot.js
View file

@ -49,7 +49,6 @@ async function createBot(server, config, getBots, dcclient) {
bot.removeAllListeners();
bot._client.end();
bot._client.removeAllListeners();
process.removeAllListeners();
};
bot.visibility = false;
bot.getBots = getBots;

View file

@ -11,7 +11,6 @@ module.exports = {
'normalKey': '<27>iB_D<5F><44><EFBFBD>k<EFBFBD><6B>j8H<38>{?[/ڭ<>f<EFBFBD><>^-=<3D>Ț<EFBFBD><C89A>v]<5D><>g><3E><>=c',
'ownerHashKey': 'b)R<><52>nF<6E>CW<43><57><EFBFBD>#<23>\\[<5B>S*8"t^eia<69>Z<EFBFBD><5A>k<EFBFBD><6B><EFBFBD><EFBFBD>K1<4B>8zȢ<7A>',
},
'proxy': true,
'console': true,
'useChat': false,
'core': {

View file

@ -1,14 +1,14 @@
/* eslint-disable max-len */
/* eslint-disable require-jsdoc */
const nbt = require('prismarine-nbt');
const mcData = require('minecraft-data')('1.18.2');
const sleep = require('sleep-promise');
const chatMessage = require('prismarine-chat')('1.18.2');
const Vec3 = require('vec3');
const relativePosition = new Vec3(0, 0, 0);
function inject(bot, dcclient, config) {
const mcData = require('minecraft-data')(bot.version);
const chatMessage = require('prismarine-chat')(bot.version);
const core = {
isCore(position) {
return position.x >= core.start.x && position.x <= core.end.x && position.y >= core.start.y && position.y <= core.end.y && position.z >= core.start.z && position.z <= core.end.z;
@ -40,13 +40,16 @@ function inject(bot, dcclient, config) {
relativePosition.z = 0;
}
const impulseMode = !bot.options.kaboom;
const location = {
x: core.start.x + relativePosition.x,
y: core.start.y + relativePosition.y,
z: core.start.z + relativePosition.z,
};
bot.write('update_command_block', {location, command: command.substring(0, 32767), mode: 2, flags: 0b101});
if (impulseMode) bot.write('update_command_block', {location, command: command.substring(0, 32767), mode: 0, flags: 0});
bot.write('update_command_block', {location, command: command.substring(0, 32767), mode: impulseMode ? 2 : 1, flags: 0b100});
} catch (e) {
bot.console.error(e);
}

View file

@ -1,96 +0,0 @@
/* eslint-disable require-jsdoc */
const mc = require('minecraft-protocol');
const {loadPlugins} = require('../util/loadPlugins');
function inject(bot, dcclient, config) {
if (!config.proxy) return;
let index;
config.servers.forEach((server, _index) => {
if (bot.options.host !== server.host) return;
index = _index;
});
const version = bot.version;
const srv = mc.createServer({
'online-mode': false,
'port': 25566 + index,
'keepAlive': false,
version,
});
srv.on('login', function(client) {
bot.console.info(`[Proxy] ${client.username} connected to proxy`);
let endedClient = false;
let endedTarget = false;
const targetClient = mc.createClient({
username: client.username,
host: bot.options.host,
version,
});
targetClient.chat = function(message) {
targetClient.write('chat', {message});
};
targetClient.on('login', (packet) => {
targetClient.entityId = packet.entityId;
loadPlugins(bot, null, config, null, targetClient, client, true);
});
targetClient.on('packet', (data, meta) => {
if (!endedClient &&
meta.state === mc.states.PLAY &&
client.state === mc.states.PLAY
) client.write(meta.name, data);
});
targetClient.on('error', () => {});
targetClient.on('end', () => {
targetClient.end();
endedTarget = true;
});
client.on('end', function() {
endedClient = true;
targetClient.end();
targetClient.removeAllListeners();
client.removeAllListeners();
bot.console.info(`[Proxy] ${client.username} ended`);
});
client.on('error', function() {
endedClient = true;
targetClient.removeAllListeners();
client.removeAllListeners();
bot.console.info(`[Proxy] ${client.username} got error`);
});
client.on('packet', (data, meta) => {
if (meta.name === 'chat' && !data.message?.startsWith('/')) {
if (data.message.startsWith('.')) {
return bot.command_handler.run(
client.username,
client.username,
'*' + data.message.substring(1),
client.uuid,
null,
'h',
'o',
client.username,
);
}
return;
}
targetClient.write(meta.name, data);
});
});
bot.once('end', () => {
srv.close();
srv.removeAllListeners();
});
};
module.exports = {inject};

View file

@ -1,15 +0,0 @@
/* eslint-disable require-jsdoc */
const {chatPacketListener, parsePlayerMessages} = require('../../util/chat');
function inject(bot, client, targetClient) {
const ChatMessage = require('prismarine-chat')(bot.version);
targetClient.on('chat', (packet) => {
chatPacketListener(packet, ChatMessage, '', targetClient);
});
targetClient.on('parsed_chat', (message, packet) => {
parsePlayerMessages(message, packet, targetClient);
});
};
module.exports = {inject};

View file

@ -1,32 +0,0 @@
/* eslint-disable require-jsdoc */
function inject(bot, client, targetClient) {
const {MessageBuilder} = require('prismarine-chat')(bot.version);
client.on('packet', (data, meta) => {
if (meta.name === 'chat' &&
!data.message?.startsWith('/') &&
!data.message?.startsWith('.')
) {
bot.tellraw('@a', {
color: 'dark_gray',
translate: '[%s] [%s] %s \u203a %s',
with: [
{
text: 'Chat',
color: 'gray',
},
{
text: 'Proxy',
color: 'gray',
},
{
text: client.username,
color: 'green',
},
MessageBuilder.fromString('&7' + data.message),
],
});
}
});
};
module.exports = {inject};

View file

@ -1,49 +0,0 @@
/* eslint-disable max-len */
/* eslint-disable require-jsdoc */
function inject(bot, client, targetClient, config) {
let cspy = false;
let op = true;
let gameMode = 1;
targetClient.on('parsed_chat', (data) => {
if (data.toString() === 'Successfully enabled CommandSpy' || data.toString() === ' Enabled your command spy.' || data.toString() === ' Your command spy is already enabled.') cspy = true;
if (data.toString() === 'Successfully disabled CommandSpy' || data.toString() === ' Disabled your command spy.') cspy = false;
});
targetClient.on('entity_status', (data) => {
if (data.entityId !== targetClient.entityId) return;
switch (data.entityStatus) {
case 24:
op = false;
break;
case 28:
op = true;
break;
}
});
targetClient.on('game_state_change', (data) => {
if (data.reason !== 3) return;
gameMode = data.gameMode;
});
targetClient.once('login', (data) => {
gameMode = data.gameMode;
});
const interval = setInterval(() => {
if (bot.options.kaboom) {
if (!op && config.self_care.op) targetClient.chat('/minecraft:op @s[type=player]');
if (!cspy && config.self_care.cspy) targetClient.chat('/commandspy:commandspy on');
}
if (gameMode !== 1 && config.self_care.gamemode) targetClient.chat('/minecraft:gamemode creative @s[type=player]');
}, config.self_care_check_interval);
bot.once('end', () => {
clearInterval(interval);
});
};
module.exports = {inject};