Skip to content

mineflayer-swarm 1.2.0

Install from the command line:
Learn more about npm packages
$ npm install @Pandapip1/mineflayer-swarm@1.2.0
Install via package.json:
"@Pandapip1/mineflayer-swarm": "1.2.0"

About this version

mineflayer-swarm

NPM version Build Status Try it on gitpod

Allows you to control an entire mineflayer bot swarm with minimal additional code. The API isn't final, so minor versions might introduce breaking changes. Here be dragons!

Moving from a single bot to a swarm

It's easier than you'd think!

- const mineflayer = require('mineflayer')
+ const mineflayerSwarm = require('mineflayer-swarm')

- const bot = mineflayer.createBot({
-   username: '[email protected]',
-   password: 'P@ssword0!',
-   host: 'localhost',
-   port: 25565
- })
+ const swarm = mineflayerSwarm.createSwarm([
+   {
+     username: '[email protected]',
+     password: 'P@ssword1!',
+     auth: 'mojang'
+   }, {
+     username: '[email protected]',
+     password: 'P@ssword2!',
+     auth: 'microsoft'
+   }
+ ], {
+   host: 'localhost',
+   port: 25565
+ })

- bot.on('chat', (username, message) => {
-   if (username === bot.username) return
-   bot.chat(message)
- })
+ swarm.on('chat', (bot, username, message) => {
+   if (swarm.isSwarmMember(username)) return
+   bot.chat(message)
+ })

Just the code:

const mineflayerSwarm = require('mineflayer-swarm')

const swarm = mineflayerSwarm.createSwarm([
  { // I reccomend you put this in a json file and add it to your gitignore. Suggested name: auth.json
    username: '[email protected]',
    password: 'P@ssword1!',
    auth: 'mojang'
  }, {
    username: '[email protected]',
    password: 'P@ssword2!',
    auth: 'microsoft'
  }
], {
  host: 'localhost',
  port: 25565
})

swarm.on('chat', (bot, username, message) => {
  if (swarm.isSwarmMember(username)) return
  bot.chat(message)
})

API

createSwarm(auths, options = {})

Creates a new swarm object. Bots are removed from the swarm on disconnect.

async swarm.addSwarmMember(auth)

Adds a member to a swarm dynamically.

swarm.isSwarmMember(username)

Returns true if the given username is part of the swarm, otherwise returns false.

async swarm.execAll(function)

Evaluates the given function (or async function) in the context of each bot, and returns the result.

swarm.loadPlugin(plugin)

Loads a plugin in all bots in the swarm.

swarm.loadPlugins(plugins)

Loads multiple plugins in all bots in the swarm.

swarm.hasPlugin(plugin)

Returns true if the given plugin is loaded in the swarm, otherwise returns false.

Details


Assets

  • mineflayer-swarm-1.2.0-npm.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all