Skip to content

Mineflayer plugin manager that can reload plugins. Achieved through low-level Node.js API.

License

Notifications You must be signed in to change notification settings

JungleDome/mineflayer-plugin-manager

Repository files navigation

mineflayer-plugin-manager

A plugin manager that is capable of hot-reloading Mineflayer plugin.


Installation

npm install mineflayer-plugin-manager

Usage

Simple example:

  • Run npm install mineflayer-plugin-manager.
  • Place all Mineflayer plugins inside ./plugins folder.
  • Import mineflayer-plugin-manager: const { plugin as PluginManager } = require('mineflayer-plugin-manager').
  • Call bot.loadPlugin(PluginManager).
  • Make changes to your plugins.
  • Call bot.pluginManager.reload().
  • Enjoy new changes.
const Mineflayer = require("mineflayer");
const { plugin as PluginManager } = require("mineflayer-plugin-manager");
const gui = require("mineflayer-gui");

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25565,
  username: 'bot',
});

//Load all remote plugins that is installed from npm
bot.loadPlugin(gui.plugin);

//Loads plugin manager, it will automatically load all local plugins inside './myFolder' folder
bot.loadPlugin(PluginManager);

///Reload all plugins with latest content
bot.on('chat', (message) => {
  if (message == 'reload')
    bot.pluginManager.reload();
})

Advanced usage (refer API):

const Mineflayer = require("mineflayer");
const { plugin as PluginManager } = require("mineflayer-plugin-manager");
const gui = require("mineflayer-gui");

const bot = mineflayer.createBot({
  host: 'localhost',
  port: 25565,
  username: 'bot',
  pluginManager: {
    logDebug: true, //Enable debug logging
    pluginDir: './myFolder', //Override default plugin folder path
    removeListener: true,
    removeAttributes: true,
    onlyLoadJsPlugin: true,
    whitelistFileTypes: ['.js', '.json']
  }
});

//Load all remote plugins that is installed from npm
bot.loadPlugin(gui.plugin);

//Loads plugin manager, it will automatically load all local plugins inside './myFolder' folder
bot.loadPlugin(PluginManager);

//Reload all plugins with latest content
bot.on('chat', (message) => {
  if (message == 'reload')
    bot.pluginManager.reload();
})

Documentation

API

License

This project uses the MIT license.

Contributions

This project is accepting PRs and Issues. See something you think can be improved? Go for it! Any and all help is highly appreciated!

For larger changes, it is recommended to discuss these changes in the issues tab before writing any code. It's also preferred to make many smaller PRs than one large one, where applicable.

About

Mineflayer plugin manager that can reload plugins. Achieved through low-level Node.js API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published