mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 09:35:35 -05:00
add unused target packet blacklist
This commit is contained in:
parent
08d07b23e2
commit
b9fd9a56fc
2 changed files with 9 additions and 4 deletions
|
@ -31,6 +31,8 @@ function inject (bot, dcclient, config) {
|
||||||
version
|
version
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const targetPacketBlacklist = []
|
||||||
|
|
||||||
target.chat = function (message) {
|
target.chat = function (message) {
|
||||||
target.write('chat', { message })
|
target.write('chat', { message })
|
||||||
}
|
}
|
||||||
|
@ -38,13 +40,14 @@ function inject (bot, dcclient, config) {
|
||||||
target.on('login', (packet) => {
|
target.on('login', (packet) => {
|
||||||
bot.console.info(`[Proxy] ${client.username} target logged in`)
|
bot.console.info(`[Proxy] ${client.username} target logged in`)
|
||||||
target.entityId = packet.entityId
|
target.entityId = packet.entityId
|
||||||
loadPlugins(bot, null, config, null, target, client, true)
|
loadPlugins(bot, null, config, null, target, client, true, targetPacketBlacklist)
|
||||||
})
|
})
|
||||||
|
|
||||||
target.on('packet', (data, meta) => {
|
target.on('packet', (data, meta) => {
|
||||||
if (!clientEnded &&
|
if (!clientEnded &&
|
||||||
meta.state === mc.states.PLAY &&
|
meta.state === mc.states.PLAY &&
|
||||||
client.state === mc.states.PLAY
|
client.state === mc.states.PLAY &&
|
||||||
|
!targetPacketBlacklist.includes(meta.name)
|
||||||
) client.write(meta.name, data)
|
) client.write(meta.name, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -88,6 +91,7 @@ function inject (bot, dcclient, config) {
|
||||||
}
|
}
|
||||||
target.write(meta.name, data)
|
target.write(meta.name, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
function endListener (reason) {
|
function endListener (reason) {
|
||||||
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
client.end(`Bot disconnected with reason: ${util.inspect(reason)}`)
|
||||||
bot.off('end', endListener)
|
bot.off('end', endListener)
|
||||||
|
|
|
@ -11,8 +11,9 @@ const path = require('path')
|
||||||
* @param {object} target proxy target
|
* @param {object} target proxy target
|
||||||
* @param {object} client proxy client
|
* @param {object} client proxy client
|
||||||
* @param {boolean} proxy is proxy
|
* @param {boolean} proxy is proxy
|
||||||
|
* @param {array} targetPacketBlacklist target packet blacklist
|
||||||
*/
|
*/
|
||||||
async function loadPlugins (bot, dcclient, config, rl, target, client, proxy) {
|
async function loadPlugins (bot, dcclient, config, rl, target, client, proxy, targetPacketBlacklist) {
|
||||||
const dir = path.join(__dirname, '..', 'plugins', proxy ? 'proxy' : '')
|
const dir = path.join(__dirname, '..', 'plugins', proxy ? 'proxy' : '')
|
||||||
const plugins = await fs.readdir(dir)
|
const plugins = await fs.readdir(dir)
|
||||||
plugins.forEach((plugin) => {
|
plugins.forEach((plugin) => {
|
||||||
|
@ -20,7 +21,7 @@ async function loadPlugins (bot, dcclient, config, rl, target, client, proxy) {
|
||||||
try {
|
try {
|
||||||
const plug = require(path.join(dir, plugin))
|
const plug = require(path.join(dir, plugin))
|
||||||
if (!proxy) plug.inject(bot, dcclient, config, rl)
|
if (!proxy) plug.inject(bot, dcclient, config, rl)
|
||||||
else plug.inject(bot, client, target, config)
|
else plug.inject(bot, client, target, config, targetPacketBlacklist)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Plugin ${plugin} is having exception loading the plugin:`)
|
console.log(`Plugin ${plugin} is having exception loading the plugin:`)
|
||||||
console.log(util.inspect(e))
|
console.log(util.inspect(e))
|
||||||
|
|
Loading…
Reference in a new issue