Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function inject (bot, { version }) {
const objects = require('minecraft-data')(version).objects
const mobs = require('minecraft-data')(version).mobs
const entitiesArray = require('minecraft-data')(version).entitiesArray
const Item = require('prismarine-item')(version)
const ChatMessage = require('../chat_message')(version)
bot.findPlayer = bot.findPlayers = (filter) => {
const filterFn = (entity) => {
if (entity.type !== 'player') return false
if (filter === null) return true
if (typeof filter === 'object' && filter instanceof RegExp) {
return entity.username.search(filter) !== -1
} else if (typeof filter === 'function') {
return filter(entity)
} else if (typeof filter === 'string') {
return entity.username.toLowerCase() === filter.toLowerCase()
}
return false
}