npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iron-golem

v0.2.3

Published

A robust Minecraft bot built upon mineflayer

Downloads

21

Readme

iron-golem

A robust Minecraft bot + lib built upon mineflayer

Find this module on npm.

Usage

Once you've actually installed iron-golem, it's pretty simple to get started.

const { Client } = require('iron-golem');

const client = new Client({
    username: 'myuser',
    password: 'mypass',
    server: 'ip',
    port: 'port',
    // other settings here,
    // look inside Client.js
    // for all the possible settings
    // (or by the time you read this I
    // might actually have some jsdocs)
});

// this is async (returns a promise)
// but we'll ignore that for now
client.init();

// do stuff with your client here

It's pretty easy as you can see. Depending on your use case, you'll probably also want some server-specific functionality without having to bend over backwards. That's pretty easy to do.

Inside the client settings, add an option called serverConfigs, which is an Array.

new Client({serverConfigs: []})

A server config is a key/value object which has any of the following properties:

  • server, which is a regular expression used to match the server ip (not port) so the client knows which pattern(s) to use
  • name, readable name for the server
  • version, the number version to use (for example, 1.8 is the one used for Mineplex)
  • chatDelay, pretty obvious. In ms. This is 1200 for Mineplex, try something similar for most big servers.
  • chat, which is an array of more objects you can use to automatically parse chat. If you are using chat parsing, events will be emitted from the client whose name equals the name of the chat object. Try not to use existing event names (like "spawn"), because eventually you'll run into some unexpected behavior.
    • Each chat object should have a name (readable name), regex (the regex used to match this chat type),
    • and an array called matches which contains strings that are used to name each match. This is probably pretty confusing, but here's an example:
      • If your regex is /^I have a (dog|cat|bird)$/, and you want to store what kind of animal the person has, your matches would look like ['fullText', 'animal']. fullText would be the first because regular expression matching in JS always has the index 0 equal to the fully matched text. Next, animal is the name of the first match group. The resulting object created from this chat (a MinecraftMessage) will now have the property "animal", so you can use msg.animal and it will have a value.
    • additionally, you can have a replyFormatter function which takes (text, sender) and returns a string that is used to format a reply chat message.