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

node-legacy-smp

v1.0.3

Published

This is an api for the legacy SMP minecraft server

Downloads

9

Readme

Node Legacy SMP

Features

Get the latest new advancement
Get the advancement leaderboard
Get advancements by category
Get vote options
Get previous vote result
Set cache time

Installing

npm i node-legacy-smp

Examples

Get advencements progression

const LegacySMP = require("node-legacy-smp");
const LegacySMPAdvancements = new LegacySMP.Advancements();

async function main() {
    advancementsMainPage = await LegacySMPAdvancements.fetchAdvancementsProgression(); // Fetch advancements progression
    console.log(advancementsMainPage);
    /*
    {
        percentage: '49.6%',
        completed: '405',
        latestAdvancementTitle: "There's yolk on my head",
        latestAdvancementCondition: 'Catapult an egg onto a zombie's head',
        latestAdvancementPlayerName: 'PearlescentMoon',
        latestAdvancementPlayerImageRef: 'https://legacysmp.com/packs/media/images/avatars/100/pearlescentmoon-b6982f72e87c10427b18fd4ced6d2e35.png',
        latestAdvancementTimeCompleted: ' First accomplished about 19 hours ago'
        leaderboard : [{
            position: '1',
            name: 'MythicalSausage',
            imageRef: 'https://legacysmp.com/packs/media/images/avatars/100/mythicalsausage-dfe0cc0ed2a233147602ea48cc3af8ff.png',
            advancementsMade: '274'
        }...]
    }
    */

    
   console.log(advancementsMainPage.leaderboard[0]);
    /*{
        position: '1',
        name: 'MythicalSausage',
        imageRef: 'https://legacysmp.com/packs/media/images/avatars/100/mythicalsausage-dfe0cc0ed2a233147602ea48cc3af8ff.png',
        advancementsMade: '274'
    }*/
}

main();

Get advancements by category


const LegacySMP = require("node-legacy-smp");
const LegacySMPAdvancements = new LegacySMP.Advancements();
const categories = LegacySMPAdvancements.advancementCategories;

async function main() {
    adventureAdvancements = await LegacySMPAdvancements.fetchAdvancementCategory(categories.ADVENTURE);
    console.log(adventureAdvancements);
    /*
    {
        completedAdvancements: [
            {
                completed: true,
                name: 'Artillery',
                condition: 'Have nine loaded crossbows in your hotbar. All set!',
                playerName: 'JermsyBoy',
                imageRef: 'https://legacysmp.com/packs/media/images/avatars/100/jermsyboy-0af0472e653350ce26e99901b8294c41.png',
                timeCompleted: ' First accomplished 6 days ago
            },
            ...
        ],
        notCompletedAdvancements: [
            {
                completed: false,
                name: 'A Complete Catalogue',
                condition: 'Tame all cat variants!'
            },
            {
                completed: false,
                name: 'All chained up',
                condition: 'Trade for a piece of chain armor from an armorer villager'
            },
            ...
        ]
    }
    */
}

main();

const LegacySMP = require("node-legacy-smp");
const LegacySMPAdvancements = new LegacySMP.Advancements();
const categories = LegacySMPAdvancements.advancementCategories;

async function main() {
    adventureAdvancements = await LegacySMPAdvancements.fetchAdvancementCategory(categories.ADVENTURE);
    console.log(adventureAdvancements.completedAdvancements[0]);
    /*
    {
        completed: true,
        name: 'Artillery',
        condition: 'Have nine loaded crossbows in your hotbar. All set!',
        playerName: 'JermsyBoy',
        imageRef: 'https://legacysmp.com/packs/media/images/avatars/100/jermsyboy-0af0472e653350ce26e99901b8294c41.png',
        timeCompleted: ' First accomplished 6 days ago'
    }
    */
}

main();

Get vote options

const LegacySMP = require("node-legacy-smp");
const LegacySMPVotes = new LegacySMP.Votes();

async function main() {
    var votePage = await LegacySMPVotes.fetchVotes();
    console.log(votePage.voteOptions)
    /*
    [
        {
            name: 'Drop Your Wallet!',
            description: 'Must carry all your diamonds on you at all times',
            votePercentage: 15.342465753424658,
            nbOfVotes: 56
        },
        {
            name: 'Face-Off',
            description: 'Always wear the last head you got as a drop',
            votePercentage: 10.41095890410959,
            nbOfVotes: 38
        }...
    ]
    */

   console.log(votePage.voteTimeLeft); // '14 days to go'
   console.log(votePage.nbOfVotes); // 362
   console.log(votePage.question); // 'Next vote...'
}

main();

Get previous vote result

const LegacySMP = require("node-legacy-smp");
const LegacySMPVotes = new LegacySMP.Votes();

async function main() {
    var votePage = await LegacySMPVotes.fetchVotes();
    console.log(votePage.previousResults)
    /*
    [
        {
            question: 'How evil do you feel?',
            name: 'Blood Nights',
            description: 'You must fight anyone you see at night.... to the death!',
            nbOfVotes: 5332,
            timeClosed: 'Closed about 11 hours ago'
        }
    ]
    */
}

main();

Set cache time

const LegacySMP = require("node-legacy-smp");
const LegacySMPVotes = new LegacySMP.Votes();
const LegacySMPAdvancements = new LegacySMP.Advancements();

async function main() {
    LegacySMPVotes.setCacheMinutes(5);
    LegacySMPAdvancements.setCacheMinutes(7);
}

main();