Giter VIP home page Giter VIP logo

lunarbukkitapi's Introduction

LunarBukkitAPI

GitHub Workflow Status GitHub npm (scoped)

Defines the Lunar Client Bukkit protocol

Documentation

Installation

Install the package:

$ npm install @minecraft-js/lunarbukkitapi

And then import it in your JavaScript/TypeScript file

const LunarClient = require('@minecraft-js/lunarbukkitapi'); // CommonJS

import * as LunarClient from '@minecraft-js/lunarbukkitapi'; // ES6

High level API

This library comes with a high level API for a player which means you can easily set cooldowns, set waypoints without even touching any packets!

For now since there's no MinecraftJS client/server library you need to set your own packet sending/receiving handling.

At the time of writing, the biggest client/server library is PrismarineJS and here is a simple example with that library

// PrismarineJS
const mc = require('minecraft-protocol');
const server = mc.createServer({ ... });

server.on('login', (client) => {
  ...

  let playerChannel = '';
  const lunarPlayer = new LunarClient.LunarClientPlayer({
    customHandling: {
      registerPluginChannel(channel) {
        playerChannel = channel;

        // PrismarineJS way of sending packets
        client.write('custom_payload', {
          channel: 'REGISTER',
          data: Buffer.from(channel + '\0')
        });
      },

      sendPacket(buffer) {
        // PrismarineJS way of sending packets
        client.write('custom_payload', {
          channel: playerChannel,
          data: buffer
        })
      }
    }
  });

  // Sending a cooldown
  // with id of `pearl`
  // for 15s and an ender
  // pearl as item (368)
  lunarPlayer.addCooldown('pearl', 15000, 368);
});

Benchmarks

Packet used in the benchmark: CooldownPacket

Computer specs: Ryzen 5 3600 - 16GB at 2100MHz

Reading x 836,146 ops/sec ±0.28% (97 runs sampled)
Writing x 432,880 ops/sec ±1.23% (95 runs sampled)

Run this command to run the benchmarks on your machine

$ npm run benchmark

lunarbukkitapi's People

Contributors

dependabot[bot] avatar richarddorian avatar

Stargazers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.