Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.server = function (serv, options) {
const version = options.version
const mobsById = require('minecraft-data')(version).mobs
const objectsById = require('minecraft-data')(version).objects
serv.initEntity = (type, entityType, world, position) => {
if (Object.keys(serv.entities).length > options['max-entities']) { throw new Error('Too many mobs !') }
serv.entityMaxId++
const entity = new Entity(serv.entityMaxId)
Object.keys(plugins)
.filter(pluginName => plugins[pluginName].entity !== undefined)
.forEach(pluginName => plugins[pluginName].entity(entity, serv, options))
entity.initEntity(type, entityType, world, position)
serv.emit('newEntity', entity)
return entity
}
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()
}