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

@esploratori/bedrock

v1.0.0

Published

This pack provides a library that can be used to send messages and embeds to discord form a bedrock bds server.

Downloads

7

Readme

BridgeDirect

This pack provides a library that can be used to send messages and embeds to discord form a bedrock bds server.

[!NOTE]
This class is intended to be used inside a Minecraft Bedrock scripting addon. Despite the class being able to run on any minecraft world, it will work only when run along with BedrockBridge, which is currently available for bds server (and not realms or local worlds).

[!NOTE]
This library works for all BedrockBridge versions since v1.4.2, which runs on Minecraft Bedrock Edition v1.21.30. Previous versions are not supported.

What does the library do?

With this library you have access to a BridgeDirect instance. A simple class that handles sending messages to BedrockBridge through scriptevents. BedrockBridge will handle the discord connection part.

How to use it?

You can either copy the code of the class to your project, or install the npm package and then bundle your pack.

import { bridgeDirect } from "@esploratori/bedrock";

bridgeDirect.events.directInitialize.subscribe(() => {

    bridgeDirect.sendMessage("Welcome from bedrock!")

})

If you copy the file, the first line of this code will probably look like this import { bridgeDirect } from "./index.js".

direct_example

Be careful when using the library that the directInitialize event has been sent, otherwise trying to send messages will result in an error.

  1. A possible approach to this problem could be checking if the connection is ready before sending logs.
// ...
import { world } from "@minecraft/server"

world.afterEvents.itemUse.subscribe(e=>{
    if (e.itemStack.nameTag==="legendary-item"){

        if (bridgeDirect.ready){ // making sure that the bridge is active
            bridgeDirect.sendMessage(e.source.name + " used a legendary item", "Legendary News")
        }
    }
})
  1. While another approach could be including your pack logic inside the bridgeInitialize event.
// ...
bridgeDirect.events.directInitialize.subscribe(()=>{

    world.afterEvents.itemUse.subscribe(e => {
        if (e.itemStack.nameTag === "legendary-item") {
            bridgeDirect.sendMessage(e.source.name + " used a legendary item", "Legendary News")
        }
    })
    
})

Of course which solution to use depends on the purpose of your pack. If your pack wants to provide additional discord capabilities to a well pre-established in-game mechanic then it would make sense to use the first solution. If you are developing a pack mostly focused on the discord connection then probably the second solution is preferable.

It is however advisable to handle the connection delay, or the possibility that BedrockBridge is not installed, by e.g. caching the messages untill the bridge is ready, or sending logs to the users if the connection hasn't been established for a long time (which means that there is something wrong). A typical setup delay would be 2-5 seconds.

Releasing your addon

Here comes the sensitive part. This library is opensource. It can be used, copied, included in your addon and modified without restrictions. However it's not the same for BedrockBridge. You can add a link to our download page on your page.

[!WARNING]
You cannot include BedrockBridge in your pack or add a direct download link to BedrockBridge.